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 npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "switcher-api",
"version": "1.3.0",
"version": "1.3.1",
"description": "Feature Flag/Toggle API",
"main": "src/start.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sonar.projectKey=switcherapi_switcher-api
sonar.projectName=switcher-api
sonar.organization=switcherapi
sonar.projectVersion=1.3.0
sonar.projectVersion=1.3.1
sonar.links.homepage=https://github.com/switcherapi/switcher-api

sonar.testExecutionReportPaths=test-report.xml
Expand Down
2 changes: 1 addition & 1 deletion src/api-docs/swagger-info.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
title: 'Switcher API',
version: 'v1.3.0',
version: 'v1.3.1',
description: 'Switcher API is a Feature Flag API focused on toggling features over different environments and applications.',
contact: {
name: 'Roger Floriano (petruki)',
Expand Down
4 changes: 4 additions & 0 deletions src/routers/gitops.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ const windowValidation = (value) => {
};

const pathValidation = (value) => {
if (value.length === 0) {
return true;
}

if (value.startsWith('/') || value.endsWith('/') || value.includes('//')) {
throw new Error('Invalid path value - cannot start or end with / or contain //');
}
Expand Down
27 changes: 27 additions & 0 deletions tests/gitops-account.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,33 @@ describe('GitOps Account - Subscribe', () => {
Client.forget('GITOPS_SUBSCRIPTION');
});


test('GITOPS_ACCOUNT_SUITE - Should subscribe account - with blank path', async () => {
// given
const requestPayload = JSON.parse(JSON.stringify(VALID_SUBSCRIPTION_REQUEST));
requestPayload.path = '';

const expectedResponse = JSON.parse(JSON.stringify(requestPayload));
expectedResponse.token = '...123';

const postStub = sinon.stub(axios, 'post').resolves({
status: 201,
data: expectedResponse
});

// test
const req = await request(app)
.post('/gitops/v1/account/subscribe')
.set('Authorization', `Bearer ${adminAccountToken}`)
.send(requestPayload)
.expect(201);

// assert
expect(req.body).toMatchObject(expectedResponse);

postStub.restore();
});

test('GITOPS_ACCOUNT_SUITE - Should return error - error creating account', async () => {
// given
const postStub = sinon.stub(axios, 'post').resolves({
Expand Down