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
67 changes: 30 additions & 37 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
Expand Up @@ -59,7 +59,7 @@
},
"devDependencies": {
"env-cmd": "^10.1.0",
"eslint": "^9.14.0",
"eslint": "^9.15.0",
"jest": "^29.7.0",
"jest-sonar-reporter": "^2.0.0",
"node-notifier": "^10.0.1",
Expand Down
4 changes: 2 additions & 2 deletions src/models/config-strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ const StrategyRequirementDefinition = [
{
strategy: StrategiesType.DATE,
operations: [OperationsType.BETWEEN, OperationsType.LOWER, OperationsType.GREATER],
format: 'YYYY-MM-DD or YYYY-MM-DDTHH:mm',
validator: '([12][0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]))(T(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9])?$'
format: 'YYYY-MM-DD or YYYY-MM-DD HH:mm',
validator: '([12][0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]))( (0[0-9]|1[0-9]|2[0-3]):[0-5][0-9])?$'
},
{
strategy: StrategiesType.REGEX,
Expand Down
27 changes: 24 additions & 3 deletions tests/config-strategy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ afterAll(async () => {
describe('Testing strategy creation #1', () => {
beforeAll(setupDatabase);

test('STRATEGY_SUITE - Should create a new Config Strategy', async () => {
test('STRATEGY_SUITE - Should create a new Config Strategy - NETWORK', async () => {
const response = await request(app)
.post('/configstrategy/create')
.set('Authorization', `Bearer ${adminMasterAccountToken}`)
.send({
description: 'Description of my new Config Strategy',
description: 'Description of my new Config Strategy - NETWORK',
strategy: StrategiesType.NETWORK,
operation: OperationsType.EXIST,
values: ['192.168.0.1/16'],
Expand All @@ -47,7 +47,28 @@ describe('Testing strategy creation #1', () => {
expect(configStrategy).not.toBeNull();

// Response validation
expect(response.body.description).toBe('Description of my new Config Strategy');
expect(response.body.description).toBe('Description of my new Config Strategy - NETWORK');
});

test('STRATEGY_SUITE - Should create a new Config Strategy - DATE/TIME', async () => {
const response = await request(app)
.post('/configstrategy/create')
.set('Authorization', `Bearer ${adminMasterAccountToken}`)
.send({
description: 'Description of my new Config Strategy - DATE',
strategy: StrategiesType.DATE,
operation: OperationsType.GREATER,
values: ['2019-12-12 00:00'],
config: configId2,
env: EnvType.DEFAULT
}).expect(201);

// DB validation - document created
const configStrategy = await ConfigStrategy.findById(response.body._id).lean().exec();
expect(configStrategy).not.toBeNull();

// Response validation
expect(response.body.description).toBe('Description of my new Config Strategy - DATE');
});

test('STRATEGY_SUITE - Should NOT create a new Config Strategy - Config not found', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/db_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const configStrategyTIME_GREATDocument = {
config: configId,
operation: OperationsType.GREATER,
strategy: StrategiesType.DATE,
values: ['2019-12-01T13:00'],
values: ['2019-12-01 13:00'],
domain: domainId
};

Expand Down
8 changes: 4 additions & 4 deletions tests/graphql-utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const expected101 = `
"strategy":"DATE_VALIDATION",
"activated":false,
"operation":"GREATER",
"values":["2019-12-01T13:00"]
"values":["2019-12-01 13:00"]
}
]
}
Expand Down Expand Up @@ -260,7 +260,7 @@ export const expected103 = `
"activated":false,
"operation":"GREATER",
"values":[
"2019-12-01T13:00"
"2019-12-01 13:00"
]}
]}
]}
Expand Down Expand Up @@ -315,7 +315,7 @@ export const expected106 = `
{"strategy":"VALUE_VALIDATION","statusByEnv":[{"env":"default","value":true}],"operation":"EXIST","values":["USER_1","USER_2","USER_3"]},
{"strategy":"NETWORK_VALIDATION","statusByEnv":[{"env":"default","value":true}],"operation":"EXIST","values":["10.0.0.0/24"]},
{"strategy":"TIME_VALIDATION","statusByEnv":[{"env":"default","value":false}],"operation":"BETWEEN","values":["13:00","14:00"]},
{"strategy":"DATE_VALIDATION","statusByEnv":[{"env":"default","value":false}],"operation":"GREATER","values":["2019-12-01T13:00"]}]},
{"strategy":"DATE_VALIDATION","statusByEnv":[{"env":"default","value":false}],"operation":"GREATER","values":["2019-12-01 13:00"]}]},
{"key":"TEST_CONFIG_KEY_PRD_QA","description":"Test config 2 - Off in PRD and ON in QA","statusByEnv":[{"env":"default","value":false},{"env":"QA","value":true}],
"strategies":[]}]}]}}}`;

Expand Down Expand Up @@ -364,7 +364,7 @@ export const expected108 = `
{"strategy":"VALUE_VALIDATION","operation":"EXIST","values":["USER_1","USER_2","USER_3"],"statusByEnv":[{"env":"default","value":true}]},
{"strategy":"NETWORK_VALIDATION","operation":"EXIST","values":["10.0.0.0/24"],"statusByEnv":[{"env":"default","value":true}]},
{"strategy":"TIME_VALIDATION","operation":"BETWEEN","values":["13:00","14:00"],"statusByEnv":[{"env":"default","value":false}]},
{"strategy":"DATE_VALIDATION","operation":"GREATER","values":["2019-12-01T13:00"],"statusByEnv":[{"env":"default","value":false}]}]}}}`;
{"strategy":"DATE_VALIDATION","operation":"GREATER","values":["2019-12-01 13:00"],"statusByEnv":[{"env":"default","value":false}]}]}}}`;

export const expected109 = `
{"data":
Expand Down