-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from amuslija/chore/support-multiple-propertie…
…s-types Chore: Support multiple properties types
- Loading branch information
Showing
8 changed files
with
6,277 additions
and
8 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,11 @@ | ||
plugins: | ||
- serverless-reqvalidator-plugin | ||
service: my-service-b | ||
functions: | ||
hello: | ||
handler: handler.myHandler | ||
events: | ||
- http: | ||
path: hello | ||
reqValidatorName: | ||
Fn::ImportValue: 'myReqValidator' |
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,11 @@ | ||
plugins: | ||
- serverless-reqvalidator-plugin | ||
service: my-service-d | ||
functions: | ||
hello: | ||
handler: handler.myHandler | ||
events: | ||
- http: | ||
path: hello | ||
reqValidatorName: | ||
data: 123 |
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,27 @@ | ||
plugins: | ||
- serverless-reqvalidator-plugin | ||
service: my-service-a | ||
functions: | ||
hello: | ||
handler: handler.myHandler | ||
events: | ||
- http: | ||
path: hello | ||
reqValidatorName: 'myReqValidator' | ||
|
||
resources: | ||
Resources: | ||
xMyRequestValidator: | ||
Type: "AWS::ApiGateway::RequestValidator" | ||
Properties: | ||
Name: 'my-req-validator' | ||
RestApiId: | ||
Ref: ApiGatewayRestApi | ||
ValidateRequestBody: true | ||
ValidateRequestParameters: false | ||
Outputs: | ||
xMyRequestValidator: | ||
Value: | ||
Ref: my-req-validator | ||
Export: | ||
Name: myReqValidator |
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,9 @@ | ||
plugins: | ||
- serverless-reqvalidator-plugin | ||
service: my-service-c | ||
functions: | ||
hello: | ||
handler: handler.myHandler | ||
events: | ||
- http: | ||
path: hello |
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,41 @@ | ||
const Ajv = require('ajv'); | ||
const yaml = require('js-yaml'); | ||
const fs = require('fs'); | ||
|
||
const { ServerlessReqValidatorPluginConfigSchema } = require('../src/index'); | ||
|
||
const ajv = new Ajv(); | ||
|
||
const validateConfig = ajv.compile({ | ||
type: 'object', | ||
...ServerlessReqValidatorPluginConfigSchema, | ||
}); | ||
|
||
describe('serverless-reqvalidator-plugin schema', () => { | ||
it('should validate a configuration without reqValidatorName property', () => { | ||
const config = yaml.load(fs.readFileSync('./test/fixtures/noValidatorFunction.yaml', 'utf8')); | ||
|
||
const valid = validateConfig(config.functions.hello.events[0].http); | ||
expect(valid).toBeTruthy(); | ||
}); | ||
|
||
it('should validate a configuration with a local reqValidatorName property', () => { | ||
const config = yaml.load(fs.readFileSync('./test/fixtures/localValidatorFunction.yaml', 'utf8')); | ||
|
||
const valid = validateConfig(config.functions.hello.events[0].http); | ||
expect(valid).toBeTruthy(); | ||
}); | ||
|
||
it('should validate a configuration with an external reqValidatorName property', () => { | ||
const config = yaml.load(fs.readFileSync('./test/fixtures/externalValidatorFunction.yaml', 'utf8')); | ||
|
||
const valid = validateConfig(config.functions.hello.events[0].http); | ||
expect(valid).toBeTruthy(); | ||
}); | ||
|
||
it('should not validate a configuration with an invalid reqValidatorName property', () => { | ||
const config = yaml.load(fs.readFileSync('./test/fixtures/invalidValidatorFunction.yaml', 'utf8')); | ||
const valid = validateConfig(config.functions.hello.events[0].http); | ||
expect(valid).toBeFalsy(); | ||
}); | ||
}); |