2019-08-08 10:41:05 +02:00
|
|
|
const { registerAndLogin } = require('../../../../test/helpers/auth');
|
|
|
|
const createModelsUtils = require('../../../../test/helpers/models');
|
|
|
|
const { createAuthRequest } = require('../../../../test/helpers/request');
|
|
|
|
|
|
|
|
let modelsUtils;
|
|
|
|
let rq;
|
|
|
|
|
|
|
|
describe('Test type password', () => {
|
|
|
|
beforeAll(async () => {
|
|
|
|
const token = await registerAndLogin();
|
|
|
|
rq = createAuthRequest(token);
|
|
|
|
|
|
|
|
modelsUtils = createModelsUtils({ rq });
|
|
|
|
|
2019-12-12 10:15:25 +01:00
|
|
|
await modelsUtils.createContentTypeWithType('withpassword', 'password');
|
2019-08-08 10:41:05 +02:00
|
|
|
}, 60000);
|
|
|
|
|
|
|
|
afterAll(async () => {
|
2019-12-12 10:15:25 +01:00
|
|
|
await modelsUtils.deleteContentType('withpassword');
|
2019-08-08 10:41:05 +02:00
|
|
|
}, 60000);
|
|
|
|
|
|
|
|
test('Create entry with value input JSON', async () => {
|
2020-02-17 16:14:29 +01:00
|
|
|
const res = await rq.post('/content-manager/explorer/application::withpassword.withpassword', {
|
|
|
|
body: {
|
|
|
|
field: 'somePassword',
|
|
|
|
},
|
|
|
|
});
|
2019-08-08 10:41:05 +02:00
|
|
|
|
|
|
|
expect(res.statusCode).toBe(200);
|
2020-07-08 13:53:56 +02:00
|
|
|
expect(res.body.field).toBeUndefined();
|
2019-08-08 10:41:05 +02:00
|
|
|
});
|
|
|
|
|
2019-08-08 10:55:22 +02:00
|
|
|
test.todo('Should be private by default');
|
|
|
|
|
2019-08-08 10:47:53 +02:00
|
|
|
test('Create entry with value input Formdata', async () => {
|
2020-02-17 16:14:29 +01:00
|
|
|
const res = await rq.post('/content-manager/explorer/application::withpassword.withpassword', {
|
|
|
|
body: {
|
|
|
|
field: '1234567',
|
|
|
|
},
|
|
|
|
});
|
2019-08-08 10:47:53 +02:00
|
|
|
|
|
|
|
expect(res.statusCode).toBe(200);
|
2020-07-08 13:53:56 +02:00
|
|
|
expect(res.body.field).toBeUndefined();
|
2019-08-08 10:47:53 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
test('Reading entry returns correct value', async () => {
|
2020-02-17 16:14:29 +01:00
|
|
|
const res = await rq.get('/content-manager/explorer/application::withpassword.withpassword');
|
2019-08-08 10:47:53 +02:00
|
|
|
|
|
|
|
expect(res.statusCode).toBe(200);
|
|
|
|
expect(Array.isArray(res.body)).toBe(true);
|
2020-07-08 13:53:56 +02:00
|
|
|
|
|
|
|
res.body.forEach(element => {
|
|
|
|
expect(element.field).toBeUndefined();
|
|
|
|
});
|
2019-08-08 10:47:53 +02:00
|
|
|
});
|
2019-08-08 10:41:05 +02:00
|
|
|
|
2019-08-08 10:47:53 +02:00
|
|
|
test('Updating entry sets the right value and format', async () => {
|
2020-02-17 16:14:29 +01:00
|
|
|
const res = await rq.post('/content-manager/explorer/application::withpassword.withpassword', {
|
|
|
|
body: {
|
|
|
|
field: 'somePassword',
|
|
|
|
},
|
|
|
|
});
|
2019-08-08 10:47:53 +02:00
|
|
|
|
|
|
|
const updateRes = await rq.put(
|
2019-11-15 11:49:32 +01:00
|
|
|
`/content-manager/explorer/application::withpassword.withpassword/${res.body.id}`,
|
2019-08-08 10:47:53 +02:00
|
|
|
{
|
|
|
|
body: {
|
|
|
|
field: 'otherPwd',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(updateRes.statusCode).toBe(200);
|
|
|
|
expect(updateRes.body).toMatchObject({
|
|
|
|
id: res.body.id,
|
|
|
|
});
|
2020-07-08 13:53:56 +02:00
|
|
|
expect(res.body.field).toBeUndefined();
|
2019-08-08 10:47:53 +02:00
|
|
|
});
|
2019-08-08 10:41:05 +02:00
|
|
|
});
|