diff --git a/test/definitions/3.0.0/security/apiKey/apiKey.js b/test/definitions/3.0.0/security/apiKey/apiKey.js index 2401093c..b0b3e1bb 100644 --- a/test/definitions/3.0.0/security/apiKey/apiKey.js +++ b/test/definitions/3.0.0/security/apiKey/apiKey.js @@ -13,6 +13,7 @@ const ajv = new Ajv({ }); addFormats(ajv); +const jsonSchemaName = 'API Key'; const jsonSchema = require('../../../../../definitions/3.0.0/apiKey.json'); const validator = ajv .addMetaSchema(require('../../../../../definitions/3.0.0/schema.json')) @@ -20,6 +21,13 @@ const validator = ajv .compile(jsonSchema); describe('API Key', () => { + it('example', () => { + const info = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); + const validationResult = validator(info); + + assert(validationResult === true, `${jsonSchemaName} example MUST be valid`); + }); + it('empty', () => { const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); const validationResult = validator(model); diff --git a/test/definitions/3.0.0/security/apiKey/example.json b/test/definitions/3.0.0/security/apiKey/example.json new file mode 100644 index 00000000..36ca4473 --- /dev/null +++ b/test/definitions/3.0.0/security/apiKey/example.json @@ -0,0 +1,5 @@ +{ + "type": "apiKey", + "description": "apiKey", + "in": "user" +} diff --git a/test/definitions/3.0.0/security/asymmetricEncryption/asymmetricEncryption.js b/test/definitions/3.0.0/security/asymmetricEncryption/asymmetricEncryption.js index ca1762aa..ff5d7d69 100644 --- a/test/definitions/3.0.0/security/asymmetricEncryption/asymmetricEncryption.js +++ b/test/definitions/3.0.0/security/asymmetricEncryption/asymmetricEncryption.js @@ -13,6 +13,7 @@ const ajv = new Ajv({ }); addFormats(ajv); +const jsonSchemaName = 'Asymmetric Encryption'; const jsonSchema = require('../../../../../definitions/3.0.0/asymmetricEncryption.json'); const validator = ajv .addMetaSchema(require('../../../../../definitions/3.0.0/schema.json')) @@ -20,6 +21,13 @@ const validator = ajv .compile(jsonSchema); describe('Asymmetric Encryption', () => { + it('example', () => { + const info = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); + const validationResult = validator(info); + + assert(validationResult === true, `${jsonSchemaName} example MUST be valid`); + }); + it('empty', () => { const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); const validationResult = validator(model); diff --git a/test/definitions/3.0.0/security/asymmetricEncryption/example.json b/test/definitions/3.0.0/security/asymmetricEncryption/example.json new file mode 100644 index 00000000..d4fe745c --- /dev/null +++ b/test/definitions/3.0.0/security/asymmetricEncryption/example.json @@ -0,0 +1,4 @@ +{ + "type": "asymmetricEncryption", + "description": "asymmetricEncryption" +} diff --git a/test/definitions/3.0.0/security/gssapi/example.json b/test/definitions/3.0.0/security/gssapi/example.json new file mode 100644 index 00000000..f2784402 --- /dev/null +++ b/test/definitions/3.0.0/security/gssapi/example.json @@ -0,0 +1,4 @@ +{ + "type": "gssapi", + "description": "gssapi" +} diff --git a/test/definitions/3.0.0/security/gssapi/gssapi.js b/test/definitions/3.0.0/security/gssapi/gssapi.js index 80d89c42..6a6b9a9d 100644 --- a/test/definitions/3.0.0/security/gssapi/gssapi.js +++ b/test/definitions/3.0.0/security/gssapi/gssapi.js @@ -13,6 +13,7 @@ const ajv = new Ajv({ }); addFormats(ajv); +const jsonSchemaName = 'GSS-API'; const jsonSchema = require('../../../../../definitions/3.0.0/SaslGssapiSecurityScheme.json'); const validator = ajv .addMetaSchema(require('../../../../../definitions/3.0.0/schema.json')) @@ -20,6 +21,13 @@ const validator = ajv .compile(jsonSchema); describe('GSS-API', () => { + it('example', () => { + const info = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); + const validationResult = validator(info); + + assert(validationResult === true, `${jsonSchemaName} example MUST be valid`); + }); + it('empty', () => { const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); const validationResult = validator(model); diff --git a/test/definitions/3.0.0/security/httpApiKey/example.json b/test/definitions/3.0.0/security/httpApiKey/example.json new file mode 100644 index 00000000..467469f5 --- /dev/null +++ b/test/definitions/3.0.0/security/httpApiKey/example.json @@ -0,0 +1,6 @@ +{ + "type": "httpApiKey", + "description": "httpApiKey", + "name": "api_key", + "in": "header" +} diff --git a/test/definitions/3.0.0/security/httpApiKey/httpApiKey.js b/test/definitions/3.0.0/security/httpApiKey/httpApiKey.js index 3c3518d8..eb407749 100644 --- a/test/definitions/3.0.0/security/httpApiKey/httpApiKey.js +++ b/test/definitions/3.0.0/security/httpApiKey/httpApiKey.js @@ -13,6 +13,7 @@ const ajv = new Ajv({ }); addFormats(ajv); +const jsonSchemaName = 'HTTP API Key'; const jsonSchema = require('../../../../../definitions/3.0.0/APIKeyHTTPSecurityScheme.json'); const validator = ajv .addMetaSchema(require('../../../../../definitions/3.0.0/schema.json')) @@ -20,6 +21,13 @@ const validator = ajv .compile(jsonSchema); describe('HTTP API Key', () => { + it('example', () => { + const info = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); + const validationResult = validator(info); + + assert(validationResult === true, `${jsonSchemaName} example MUST be valid`); + }); + it('empty', () => { const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); const validationResult = validator(model); diff --git a/test/definitions/3.0.0/security/httpBasic/example.json b/test/definitions/3.0.0/security/httpBasic/example.json new file mode 100644 index 00000000..38f712e1 --- /dev/null +++ b/test/definitions/3.0.0/security/httpBasic/example.json @@ -0,0 +1,5 @@ +{ + "type": "http", + "description": "http", + "scheme": "basic" +} diff --git a/test/definitions/3.0.0/security/httpBasic/httpBasic.js b/test/definitions/3.0.0/security/httpBasic/httpBasic.js index c23ebc97..7da90bbe 100644 --- a/test/definitions/3.0.0/security/httpBasic/httpBasic.js +++ b/test/definitions/3.0.0/security/httpBasic/httpBasic.js @@ -13,6 +13,7 @@ const ajv = new Ajv({ }); addFormats(ajv); +const jsonSchemaName = 'HTTP Basic'; const jsonSchema = require('../../../../../definitions/3.0.0/NonBearerHTTPSecurityScheme.json'); const validator = ajv .addMetaSchema(require('../../../../../definitions/3.0.0/schema.json')) @@ -20,6 +21,13 @@ const validator = ajv .compile(jsonSchema); describe('HTTP Basic', () => { + it('example', () => { + const info = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); + const validationResult = validator(info); + + assert(validationResult === true, `${jsonSchemaName} example MUST be valid`); + }); + it('empty', () => { const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); const validationResult = validator(model); diff --git a/test/definitions/3.0.0/security/httpBearer/example.json b/test/definitions/3.0.0/security/httpBearer/example.json new file mode 100644 index 00000000..68da22ef --- /dev/null +++ b/test/definitions/3.0.0/security/httpBearer/example.json @@ -0,0 +1,6 @@ +{ + "type": "http", + "description": "http", + "scheme": "bearer", + "bearerFormat": "JWT" +} diff --git a/test/definitions/3.0.0/security/httpBearer/httpBearer.js b/test/definitions/3.0.0/security/httpBearer/httpBearer.js index b8f1c7f9..eada3401 100644 --- a/test/definitions/3.0.0/security/httpBearer/httpBearer.js +++ b/test/definitions/3.0.0/security/httpBearer/httpBearer.js @@ -13,6 +13,7 @@ const ajv = new Ajv({ }); addFormats(ajv); +const jsonSchemaName = 'HTTP Bearer'; const jsonSchema = require('../../../../../definitions/3.0.0/BearerHTTPSecurityScheme.json'); const validator = ajv .addMetaSchema(require('../../../../../definitions/3.0.0/schema.json')) @@ -20,6 +21,13 @@ const validator = ajv .compile(jsonSchema); describe('HTTP Bearer', () => { + it('example', () => { + const info = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); + const validationResult = validator(info); + + assert(validationResult === true, `${jsonSchemaName} example MUST be valid`); + }); + it('empty', () => { const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); const validationResult = validator(model); diff --git a/test/definitions/3.0.0/security/openIdconnect/example.json b/test/definitions/3.0.0/security/openIdconnect/example.json new file mode 100644 index 00000000..71a624c1 --- /dev/null +++ b/test/definitions/3.0.0/security/openIdconnect/example.json @@ -0,0 +1,9 @@ +{ + "type": "openIdConnect", + "description": "openIdConnect", + "openIdConnectUrl": "https://server.com/.well-known/openid-configuration", + "scopes": [ + "write:pets", + "read:pets" + ] +} diff --git a/test/definitions/3.0.0/security/openIdconnect/openIdconnect.js b/test/definitions/3.0.0/security/openIdconnect/openIdconnect.js index 5a1abce2..239465fe 100644 --- a/test/definitions/3.0.0/security/openIdconnect/openIdconnect.js +++ b/test/definitions/3.0.0/security/openIdconnect/openIdconnect.js @@ -13,6 +13,7 @@ const ajv = new Ajv({ }); addFormats(ajv); +const jsonSchemaName = 'OpenID Connect'; const jsonSchema = require('../../../../../definitions/3.0.0/openIdConnect.json'); const validator = ajv .addMetaSchema(require('../../../../../definitions/3.0.0/schema.json')) @@ -20,6 +21,13 @@ const validator = ajv .compile(jsonSchema); describe('OpenID Connect', () => { + it('example', () => { + const info = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); + const validationResult = validator(info); + + assert(validationResult === true, `${jsonSchemaName} example MUST be valid`); + }); + it('empty', () => { const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); const validationResult = validator(model); diff --git a/test/definitions/3.0.0/security/plain/example.json b/test/definitions/3.0.0/security/plain/example.json new file mode 100644 index 00000000..5a3f8a63 --- /dev/null +++ b/test/definitions/3.0.0/security/plain/example.json @@ -0,0 +1,4 @@ +{ + "type": "plain", + "description": "plain" +} diff --git a/test/definitions/3.0.0/security/plain/plain.js b/test/definitions/3.0.0/security/plain/plain.js index 340535d7..ef437e0b 100644 --- a/test/definitions/3.0.0/security/plain/plain.js +++ b/test/definitions/3.0.0/security/plain/plain.js @@ -13,6 +13,7 @@ const ajv = new Ajv({ }); addFormats(ajv); +const jsonSchemaName = 'Plain'; const jsonSchema = require('../../../../../definitions/3.0.0/SaslPlainSecurityScheme.json'); const validator = ajv .addMetaSchema(require('../../../../../definitions/3.0.0/schema.json')) @@ -20,6 +21,13 @@ const validator = ajv .compile(jsonSchema); describe('Plain', () => { + it('example', () => { + const info = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); + const validationResult = validator(info); + + assert(validationResult === true, `${jsonSchemaName} example MUST be valid`); + }); + it('empty', () => { const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); const validationResult = validator(model); diff --git a/test/definitions/3.0.0/security/scramSha256/example.json b/test/definitions/3.0.0/security/scramSha256/example.json new file mode 100644 index 00000000..120e37e8 --- /dev/null +++ b/test/definitions/3.0.0/security/scramSha256/example.json @@ -0,0 +1,4 @@ +{ + "type": "scramSha256", + "description": "scramSha256" +} diff --git a/test/definitions/3.0.0/security/scramSha256/scramSha256.js b/test/definitions/3.0.0/security/scramSha256/scramSha256.js index 6a90a37e..4e7efb9a 100644 --- a/test/definitions/3.0.0/security/scramSha256/scramSha256.js +++ b/test/definitions/3.0.0/security/scramSha256/scramSha256.js @@ -13,6 +13,7 @@ const ajv = new Ajv({ }); addFormats(ajv); +const jsonSchemaName = 'SCRAM-SHA-256'; const jsonSchema = require('../../../../../definitions/3.0.0/SaslScramSecurityScheme.json'); const validator = ajv .addMetaSchema(require('../../../../../definitions/3.0.0/schema.json')) @@ -20,6 +21,13 @@ const validator = ajv .compile(jsonSchema); describe('SCRAM-SHA-256', () => { + it('example', () => { + const info = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); + const validationResult = validator(info); + + assert(validationResult === true, `${jsonSchemaName} example MUST be valid`); + }); + it('empty', () => { const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); const validationResult = validator(model); diff --git a/test/definitions/3.0.0/security/scramSha512/example.json b/test/definitions/3.0.0/security/scramSha512/example.json new file mode 100644 index 00000000..82ab450c --- /dev/null +++ b/test/definitions/3.0.0/security/scramSha512/example.json @@ -0,0 +1,4 @@ +{ + "type": "scramSha512", + "description": "scramSha512" +} diff --git a/test/definitions/3.0.0/security/scramSha512/scramSha512.js b/test/definitions/3.0.0/security/scramSha512/scramSha512.js index 322ecd7f..cd99a635 100644 --- a/test/definitions/3.0.0/security/scramSha512/scramSha512.js +++ b/test/definitions/3.0.0/security/scramSha512/scramSha512.js @@ -13,6 +13,7 @@ const ajv = new Ajv({ }); addFormats(ajv); +const jsonSchemaName = 'SCRAM-SHA-512'; const jsonSchema = require('../../../../../definitions/3.0.0/SaslScramSecurityScheme.json'); const validator = ajv .addMetaSchema(require('../../../../../definitions/3.0.0/schema.json')) @@ -20,6 +21,13 @@ const validator = ajv .compile(jsonSchema); describe('SCRAM-SHA-512', () => { + it('example', () => { + const info = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); + const validationResult = validator(info); + + assert(validationResult === true, `${jsonSchemaName} example MUST be valid`); + }); + it('empty', () => { const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); const validationResult = validator(model); diff --git a/test/definitions/3.0.0/security/symmetricEncryption/example.json b/test/definitions/3.0.0/security/symmetricEncryption/example.json new file mode 100644 index 00000000..4596ab1e --- /dev/null +++ b/test/definitions/3.0.0/security/symmetricEncryption/example.json @@ -0,0 +1,4 @@ +{ + "type": "symmetricEncryption", + "description": "symmetricEncryption" +} diff --git a/test/definitions/3.0.0/security/symmetricEncryption/symmetricEncryption.js b/test/definitions/3.0.0/security/symmetricEncryption/symmetricEncryption.js index ccc9e912..6c6b4116 100644 --- a/test/definitions/3.0.0/security/symmetricEncryption/symmetricEncryption.js +++ b/test/definitions/3.0.0/security/symmetricEncryption/symmetricEncryption.js @@ -13,6 +13,7 @@ const ajv = new Ajv({ }); addFormats(ajv); +const jsonSchemaName = 'Symmetric Encryption'; const jsonSchema = require('../../../../../definitions/3.0.0/symmetricEncryption.json'); const validator = ajv .addMetaSchema(require('../../../../../definitions/3.0.0/schema.json')) @@ -20,6 +21,13 @@ const validator = ajv .compile(jsonSchema); describe('Symmetric Encryption', () => { + it('example', () => { + const info = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); + const validationResult = validator(info); + + assert(validationResult === true, `${jsonSchemaName} example MUST be valid`); + }); + it('empty', () => { const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); const validationResult = validator(model); diff --git a/test/definitions/3.0.0/security/userPassword/example.json b/test/definitions/3.0.0/security/userPassword/example.json new file mode 100644 index 00000000..35dc563f --- /dev/null +++ b/test/definitions/3.0.0/security/userPassword/example.json @@ -0,0 +1,4 @@ +{ + "type": "userPassword", + "description": "userPassword" +} diff --git a/test/definitions/3.0.0/security/userPassword/userPassword.js b/test/definitions/3.0.0/security/userPassword/userPassword.js index 1ff7ef0e..0303e4e0 100644 --- a/test/definitions/3.0.0/security/userPassword/userPassword.js +++ b/test/definitions/3.0.0/security/userPassword/userPassword.js @@ -13,6 +13,7 @@ const ajv = new Ajv({ }); addFormats(ajv); +const jsonSchemaName = 'User Password'; const jsonSchema = require('../../../../../definitions/3.0.0/userPassword.json'); const validator = ajv .addMetaSchema(require('../../../../../definitions/3.0.0/schema.json')) @@ -20,6 +21,13 @@ const validator = ajv .compile(jsonSchema); describe('User Password', () => { + it('example', () => { + const info = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); + const validationResult = validator(info); + + assert(validationResult === true, `${jsonSchemaName} example MUST be valid`); + }); + it('empty', () => { const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); const validationResult = validator(model); diff --git a/test/definitions/3.0.0/security/x509/example.json b/test/definitions/3.0.0/security/x509/example.json new file mode 100644 index 00000000..b3399241 --- /dev/null +++ b/test/definitions/3.0.0/security/x509/example.json @@ -0,0 +1,4 @@ +{ + "type": "X509", + "description": "X509" +} diff --git a/test/definitions/3.0.0/security/x509/x509.js b/test/definitions/3.0.0/security/x509/x509.js index 65e1a867..3685e243 100644 --- a/test/definitions/3.0.0/security/x509/x509.js +++ b/test/definitions/3.0.0/security/x509/x509.js @@ -13,6 +13,7 @@ const ajv = new Ajv({ }); addFormats(ajv); +const jsonSchemaName = 'X509'; const jsonSchema = require('../../../../../definitions/3.0.0/X509.json'); const validator = ajv .addMetaSchema(require('../../../../../definitions/3.0.0/schema.json')) @@ -20,6 +21,13 @@ const validator = ajv .compile(jsonSchema); describe('X509', () => { + it('example', () => { + const info = JSON.parse(fs.readFileSync(`${__dirname}/example.json`, 'utf-8')); + const validationResult = validator(info); + + assert(validationResult === true, `${jsonSchemaName} example MUST be valid`); + }); + it('empty', () => { const model = JSON.parse(fs.readFileSync(`${__dirname}/empty.json`, 'utf-8')); const validationResult = validator(model);