Skip to content

Commit 864a54a

Browse files
authored
Fixes #538 - allow empty GitOps path (#539)
1 parent 13633e7 commit 864a54a

File tree

6 files changed

+36
-5
lines changed

6 files changed

+36
-5
lines changed

npm-shrinkwrap.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "switcher-api",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Feature Flag/Toggle API",
55
"main": "src/start.js",
66
"type": "module",

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
sonar.projectKey=switcherapi_switcher-api
22
sonar.projectName=switcher-api
33
sonar.organization=switcherapi
4-
sonar.projectVersion=1.3.0
4+
sonar.projectVersion=1.3.1
55
sonar.links.homepage=https://github.com/switcherapi/switcher-api
66

77
sonar.testExecutionReportPaths=test-report.xml

src/api-docs/swagger-info.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default {
22
title: 'Switcher API',
3-
version: 'v1.3.0',
3+
version: 'v1.3.1',
44
description: 'Switcher API is a Feature Flag API focused on toggling features over different environments and applications.',
55
contact: {
66
name: 'Roger Floriano (petruki)',

src/routers/gitops.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ const windowValidation = (value) => {
3434
};
3535

3636
const pathValidation = (value) => {
37+
if (value.length === 0) {
38+
return true;
39+
}
40+
3741
if (value.startsWith('/') || value.endsWith('/') || value.includes('//')) {
3842
throw new Error('Invalid path value - cannot start or end with / or contain //');
3943
}

tests/gitops-account.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,33 @@ describe('GitOps Account - Subscribe', () => {
157157
Client.forget('GITOPS_SUBSCRIPTION');
158158
});
159159

160+
161+
test('GITOPS_ACCOUNT_SUITE - Should subscribe account - with blank path', async () => {
162+
// given
163+
const requestPayload = JSON.parse(JSON.stringify(VALID_SUBSCRIPTION_REQUEST));
164+
requestPayload.path = '';
165+
166+
const expectedResponse = JSON.parse(JSON.stringify(requestPayload));
167+
expectedResponse.token = '...123';
168+
169+
const postStub = sinon.stub(axios, 'post').resolves({
170+
status: 201,
171+
data: expectedResponse
172+
});
173+
174+
// test
175+
const req = await request(app)
176+
.post('/gitops/v1/account/subscribe')
177+
.set('Authorization', `Bearer ${adminAccountToken}`)
178+
.send(requestPayload)
179+
.expect(201);
180+
181+
// assert
182+
expect(req.body).toMatchObject(expectedResponse);
183+
184+
postStub.restore();
185+
});
186+
160187
test('GITOPS_ACCOUNT_SUITE - Should return error - error creating account', async () => {
161188
// given
162189
const postStub = sinon.stub(axios, 'post').resolves({

0 commit comments

Comments
 (0)