Skip to content

Commit c8b2c1b

Browse files
authored
GitOps Account - fixes feature flag param verification (#533)
1 parent e517526 commit c8b2c1b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/middleware/gitops.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const CONTENT_TYPE_ARRAY = ['COMPONENT'];
2626
export async function featureFlag(req, res, next) {
2727
try {
2828
const domainId = req.path === '/gitops/v1/push' ?
29-
req.domain : req.body?.domain.id | req.params.domain;
30-
29+
req.domain : req.body?.domain.id || req.params.domain;
30+
3131
await checkGitopsIntegration(domainId);
3232
next();
3333
} catch (e) {

tests/gitops-account.test.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('GitOps Account - Feature Toggle', () => {
2727
process.env.SWITCHER_API_ENABLE = false;
2828
});
2929

30-
test('GITOPS_ACCOUNT_SUITE - Should return error when feature is disabled', async () => {
30+
test('GITOPS_ACCOUNT_SUITE - Should return error when feature is disabled - body domainId', async () => {
3131
const req = await request(app)
3232
.post('/gitops/v1/account/subscribe')
3333
.set('Authorization', `Bearer ${adminMasterAccountToken}`)
@@ -50,6 +50,15 @@ describe('GitOps Account - Feature Toggle', () => {
5050

5151
expect(req.body.error).toBe('GitOps Integration is not available.');
5252
});
53+
54+
test('GITOPS_ACCOUNT_SUITE - Should return error when feature is disabled - param domainId', async () => {
55+
const req = await request(app)
56+
.get(`/gitops/v1/account/${domainId}`)
57+
.set('Authorization', `Bearer ${adminMasterAccountToken}`)
58+
.expect(400);
59+
60+
expect(req.body.error).toBe('GitOps Integration is not available.');
61+
});
5362
});
5463

5564
describe('GitOps Account - Subscribe', () => {

0 commit comments

Comments
 (0)