diff --git a/src/middleware/gitops.js b/src/middleware/gitops.js index 2d202cd..bbd6dbd 100644 --- a/src/middleware/gitops.js +++ b/src/middleware/gitops.js @@ -26,8 +26,8 @@ const CONTENT_TYPE_ARRAY = ['COMPONENT']; export async function featureFlag(req, res, next) { try { const domainId = req.path === '/gitops/v1/push' ? - req.domain : req.body?.domain.id | req.params.domain; - + req.domain : req.body?.domain.id || req.params.domain; + await checkGitopsIntegration(domainId); next(); } catch (e) { diff --git a/tests/gitops-account.test.js b/tests/gitops-account.test.js index ada3991..f9fa125 100644 --- a/tests/gitops-account.test.js +++ b/tests/gitops-account.test.js @@ -27,7 +27,7 @@ describe('GitOps Account - Feature Toggle', () => { process.env.SWITCHER_API_ENABLE = false; }); - test('GITOPS_ACCOUNT_SUITE - Should return error when feature is disabled', async () => { + test('GITOPS_ACCOUNT_SUITE - Should return error when feature is disabled - body domainId', async () => { const req = await request(app) .post('/gitops/v1/account/subscribe') .set('Authorization', `Bearer ${adminMasterAccountToken}`) @@ -50,6 +50,15 @@ describe('GitOps Account - Feature Toggle', () => { expect(req.body.error).toBe('GitOps Integration is not available.'); }); + + test('GITOPS_ACCOUNT_SUITE - Should return error when feature is disabled - param domainId', async () => { + const req = await request(app) + .get(`/gitops/v1/account/${domainId}`) + .set('Authorization', `Bearer ${adminMasterAccountToken}`) + .expect(400); + + expect(req.body.error).toBe('GitOps Integration is not available.'); + }); }); describe('GitOps Account - Subscribe', () => {