Merge branch 'dev' into feature/2-welcome_mails

This commit is contained in:
2021-03-03 17:55:06 +01:00
6 changed files with 183 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
import axios from 'axios';
import { config } from '../config';
const base = "http://localhost:" + config.internal_port
describe('GET /docs/openapi.json', () => {
it('OpenAPI Spec is availdable 200', async () => {
const res = await axios.get(base + '/docs/openapi.json');
expect(res.status).toEqual(200);
});
});
describe('GET /docs/swagger.json', () => {
it('OpenAPI Spec is availdable 200', async () => {
const res = await axios.get(base + '/docs/swagger.json');
expect(res.status).toEqual(200);
});
});
describe('GET /docs/swaggerui', () => {
it('swaggerui is availdable 200', async () => {
const res = await axios.get(base + '/docs/swaggerui');
expect(res.status).toEqual(200);
});
});
describe('GET /docs/redoc', () => {
it('redoc is availdable 200', async () => {
const res = await axios.get(base + '/docs/redoc');
expect(res.status).toEqual(200);
});
});
describe('GET /docs/rapidoc', () => {
it('rapidoc is availdable 200', async () => {
const res = await axios.get(base + '/docs/rapidoc');
expect(res.status).toEqual(200);
});
});

View File

@@ -0,0 +1,72 @@
import axios from 'axios';
import { config } from '../config';
const base = "http://localhost:" + config.internal_port
const axios_config = {
validateStatus: undefined
};
describe('POST /reset without auth', () => {
it('Post without auth should return 401', async () => {
const res = await axios.post(base + '/reset', null, axios_config);
expect(res.status).toEqual(401);
});
});
describe('POST /reset with auth but wrong body', () => {
it('Post with auth but no body should return 400', async () => {
const res = await axios.post(base + '/reset?key=' + config.api_key, null, axios_config);
expect(res.status).toEqual(400);
});
it('Post with auth but no mail should return 400', async () => {
const res = await axios.post(base + '/reset?key=' + config.api_key, { resetKey: "test" }, axios_config);
expect(res.status).toEqual(400);
});
it('Post with auth but no reset key should return 400', async () => {
const res = await axios.post(base + '/reset?key=' + config.api_key, { address: "test@dev.lauf-fuer-kaya.de" }, axios_config);
expect(res.status).toEqual(400);
});
it('Post with auth but invalid mail should return 400', async () => {
const res = await axios.post(base + '/reset?key=' + config.api_key, { resetKey: "test", address: "testdev.l.de" }, axios_config);
expect(res.status).toEqual(400);
});
});
describe('POST /reset with auth and vaild body', () => {
it('Post with auth, body and no locale should return 200', async () => {
const res = await axios.post(base + '/reset?key=' + config.api_key, {
resetKey: "test",
address: "test@dev.lauf-fuer-kaya.de"
}, axios_config);
expect(res.status).toEqual(200);
expect(res.data).toEqual({
success: true,
message: "Sent!",
locale: "en"
})
});
it('Post with auth, body and locale=en should return 200', async () => {
const res = await axios.post(base + '/reset?locale=en&key=' + config.api_key, {
resetKey: "test",
address: "test@dev.lauf-fuer-kaya.de"
}, axios_config);
expect(res.status).toEqual(200);
expect(res.data).toEqual({
success: true,
message: "Sent!",
locale: "en"
})
});
it('Post with auth, body and locale=de should return 200', async () => {
const res = await axios.post(base + '/reset?locale=de&key=' + config.api_key, {
resetKey: "test",
address: "test@dev.lauf-fuer-kaya.de"
}, axios_config);
expect(res.status).toEqual(200);
expect(res.data).toEqual({
success: true,
message: "Sent!",
locale: "de"
})
});
});

View File

@@ -0,0 +1,44 @@
import axios from 'axios';
import { config } from '../config';
const base = "http://localhost:" + config.internal_port
const axios_config = {
validateStatus: undefined
};
describe('POST /test without auth', () => {
it('Post without auth should return 401', async () => {
const res = await axios.post(base + '/test', null, axios_config);
expect(res.status).toEqual(401);
});
});
describe('POST /test with auth', () => {
it('Post with auth and no locale should return 200', async () => {
const res = await axios.post(base + '/test?key=' + config.api_key, null, axios_config);
expect(res.status).toEqual(200);
expect(res.data).toEqual({
success: true,
message: "Sent!",
locale: "en"
})
});
it('Post with auth and locale=en should return 200', async () => {
const res = await axios.post(base + '/test?locale=en&key=' + config.api_key, null, axios_config);
expect(res.status).toEqual(200);
expect(res.data).toEqual({
success: true,
message: "Sent!",
locale: "en"
})
});
it('Post with auth and locale=de should return 200', async () => {
const res = await axios.post(base + '/test?locale=de&key=' + config.api_key, null, axios_config);
expect(res.status).toEqual(200);
expect(res.data).toEqual({
success: true,
message: "Sent!",
locale: "de"
})
});
});