Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ app.use(slackRouter);
*/

const handler = (req, res, next) =>
createHandler({ schema, context: req})(req, res, next);
createHandler({ schema, context: req })(req, res, next);

// Component: Client API
app.use('/graphql', appAuth, handler);
Expand Down
2 changes: 1 addition & 1 deletion src/routers/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ router.get('/config/:id', auth, [
let config = await Services.getConfigById(req.params.id);
config = await verifyOwnership(req.admin, config, config.domain, ActionTypes.READ, RouterTypes.CONFIG, true);

if (req.query.resolveComponents) {
if (req.query.resolveComponents === 'true') {
await config.populate({ path: 'component_list' });
}

Expand Down
31 changes: 14 additions & 17 deletions tests/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {
configId1,
config1Document,
configId2,
configStrategyId
configStrategyId,
component1
} from './fixtures/db_api';

afterAll(async () => {
Expand Down Expand Up @@ -138,34 +139,30 @@ describe('Testing fetch configuration info', () => {
.send().expect(422);
});

test('CONFIG_SUITE - Should get Config information by Id', async () => {
let response = await request(app)
.get('/config/' + configId1 + '?resolveComponents=true')
test('CONFIG_SUITE - Should get Config information by Id - resolveComponents as true', async () => {
const response = await request(app)
.get(`/config/${configId1}?resolveComponents=true`)
.set('Authorization', `Bearer ${adminMasterAccountToken}`)
.send().expect(200);

expect(String(response.body._id)).toEqual(String(config1Document._id));
expect(response.body.key).toEqual(config1Document.key);
expect(String(response.body.group)).toEqual(String(config1Document.group));
expect(response.body.activated[EnvType.DEFAULT]).toEqual(config1Document.activated.get(EnvType.DEFAULT));
expect(response.body.components[0].name).toEqual(component1.name);
});

// Adding new Config
response = await request(app)
.post('/config/create')
.set('Authorization', `Bearer ${adminMasterAccountToken}`)
.send({
key: 'NEW_CONFIG456',
description: 'Description of my new Config',
group: groupConfigId
}).expect(201);

await request(app)
.get('/config/' + response.body._id)
test('CONFIG_SUITE - Should get Config information by Id - resolveComponents as false', async () => {
const response = await request(app)
.get(`/config/${configId1}?resolveComponents=false`)
.set('Authorization', `Bearer ${adminMasterAccountToken}`)
.send().expect(200);

expect(String(response.body._id)).toEqual(String(config1Document._id));
expect(response.body.components[0].name).toEqual(undefined);
});

test('CONFIG_SUITE - Should not found Config information by Id', async () => {
test('CONFIG_SUITE - Should not find Config information by Id', async () => {
await request(app)
.get('/config/' + 'NOTEXIST')
.set('Authorization', `Bearer ${adminMasterAccountToken}`)
Expand Down