-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,096 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = '-----BEGIN RSA PUBLIC KEY-----\n' + | ||
'MIICCgKCAgEA0YjRFQg5J3qNOM/OuxZYcJq4vmGO6hZpgrHBHDSs0TCwLIuDylI6\n' + | ||
'nrBFWaflSCgoIRzNVHvV6NxO+Ucu4ORoEbCjea47bW6UTItyAt82s1aLNWQ0sSkI\n' + | ||
'29N7qynPCT8+9flfgnh959G6Rh20P6pfM98rg/0kTEfI31dTo5pdd8coDoX98V1+\n' + | ||
'pHUpdMBICr37p6HjX8SyXRNyfLUg6tRE/58pIMyCZTEYwarwIZCOUDm0QEZbCFpF\n' + | ||
'D5d7EJTAKD3Al9Q97B5XZbYrTyR6RrnvK9/HeyUuj0RmXiaEt6cbcjzBTrcmoqju\n' + | ||
'uVnrqxpejEXxVK1+xwBsRxBZqhvBiaPZj+R+TCQVeUVq9Uw0BxkGPaq70Dl2uOVO\n' + | ||
'fsrMdVzDYNA5UOE2i6Kf5nKlAxhZh9ZubBoYCeZquw7vghbB3q/hbq+xQtedqUbL\n' + | ||
'yYFhFzpAl+5BtI/g1zr6Ew5tQJx6OPSXZEJmDE/h9jmPc122iQJZbjaRJLM44sa6\n' + | ||
'+fJIoWms+hZjqkeCd2yaBg7FE0nOj4ZJb8i5Xz+QKOd3pr2xPr7q+tMuhaf/9dLf\n' + | ||
'gTwZmZHp6Iu8LfzllIl+4MGXgnH76eyoOESvhha0aD4GbEW7a6AiRBlZWmuQQJF3\n' + | ||
'yTfnHPDetKI87hmzVbLTmZ6hjKOfsfUqOvqC1UQdH8HNfT4TM2+vQYkCAwEAAQ==\n' + | ||
'-----END RSA PUBLIC KEY-----\n' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
const condition = require('../../../conditions/regex-path-method') | ||
const assert = require('chai').assert | ||
|
||
describe('Condition: regex-path-method', () => { | ||
describe('Integrity', () => { | ||
it('Field "name" is type valid', () => { | ||
assert.typeOf(condition.name, 'string', '"name" is not string type') | ||
assert.equal(condition.name, 'regex-path-method', 'Condition name other than expected') | ||
}) | ||
it('Field "handler" is type valid', () => { | ||
assert.typeOf(condition.handler, 'function', '"handler" is not function type') | ||
}) | ||
it('Field "schema" is type valid', () => { | ||
assert.typeOf(condition.schema, 'object', '"schema" is not object type') | ||
}) | ||
it('Field "schema.$id" is type valid', () => { | ||
assert.typeOf(condition.schema.$id, 'string', '"schema.$id" is not string type') | ||
assert.equal(condition.schema.$id, 'http://express-gateway.io/schemas/conditions/regex-path-method.json', '"schema.$id" different than expected') | ||
}) | ||
it('Field "schema.type" is type valid', () => { | ||
assert.typeOf(condition.schema.type, 'string', '"schema.type" is not object type') | ||
assert.equal(condition.schema.type, 'object', '"schema.type" different than expected') | ||
}) | ||
it('Field "schema.properties" is type valid', () => { | ||
assert.typeOf(condition.schema.properties, 'object', '"schema.properties" is not object type') | ||
}) | ||
it('Field "schema.properties.regexpath" is type valid', () => { | ||
assert.typeOf(condition.schema.properties.regexPath, 'object', '"schema.properties.regexpath" is not object type') | ||
assert.typeOf(condition.schema.properties.regexPath.type, 'string', '"schema.properties.regexpath" is not object string type') | ||
}) | ||
it('Field "schema.properties.method" is type valid', () => { | ||
assert.typeOf(condition.schema.properties.method, 'object', '"schema.properties.method" is not object type') | ||
assert.typeOf(condition.schema.properties.method.type, 'string', '"schema.properties.method" is not object string type') | ||
}) | ||
it('Field "schema.required" is type valid', () => { | ||
assert.typeOf(condition.schema.required, 'array', '"schema.required" is not array type') | ||
assert.equal(condition.schema.required[0], 'regexPath', '"schema.required" different than expected') | ||
}) | ||
|
||
}) | ||
|
||
describe('Functionality', () => { | ||
it('When the request matches the all settings', () => { | ||
const req = { | ||
url: '/v1/auth', | ||
method: 'POST' | ||
} | ||
const conditionConfig = { | ||
regexPath: '^(/v1/auth)$', | ||
method: 'POST' | ||
} | ||
assert.equal(true, condition.handler(req, conditionConfig), 'Handler should return "true"') | ||
}) | ||
it('When the request matches the regexPath but not the method', () => { | ||
const req = { | ||
url: '/v1/auth', | ||
method: 'GET' | ||
} | ||
const conditionConfig = { | ||
regexPath: '^(/v1/auth)$', | ||
method: 'POST' | ||
} | ||
assert.equal(false, condition.handler(req, conditionConfig), 'Handler should return "false"') | ||
}) | ||
it('When the request not matches the any settings', () => { | ||
const req = { | ||
url: '/users/fakeid', | ||
method: 'GET' | ||
} | ||
const conditionConfig = { | ||
regexPath: '^(/v1/auth)$', | ||
method: 'POST' | ||
} | ||
assert.equal(false, condition.handler(req, conditionConfig), 'Handler should return "false"') | ||
}) | ||
|
||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--reporter spec | ||
--slow 5000 | ||
--timeout 5000 | ||
--exit |
Oops, something went wrong.