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
4 changes: 2 additions & 2 deletions src/middleware/gitops.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 10 additions & 1 deletion tests/gitops-account.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand All @@ -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', () => {
Expand Down