-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rulesets): validate channel servers, server securities and opera…
…tion securities (#2122)
- Loading branch information
1 parent
a31d34c
commit 9accd31
Showing
7 changed files
with
1,058 additions
and
0 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
141 changes: 141 additions & 0 deletions
141
packages/rulesets/src/asyncapi/__tests__/asyncapi-channel-servers.test.ts
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,141 @@ | ||
import { DiagnosticSeverity } from '@stoplight/types'; | ||
import testRule from './__helpers__/tester'; | ||
|
||
testRule('asyncapi-channel-servers', [ | ||
{ | ||
name: 'valid case', | ||
document: { | ||
asyncapi: '2.2.0', | ||
servers: { | ||
development: {}, | ||
production: {}, | ||
}, | ||
channels: { | ||
channel: { | ||
servers: ['development'], | ||
}, | ||
}, | ||
}, | ||
errors: [], | ||
}, | ||
|
||
{ | ||
name: 'valid case - without defined servers', | ||
document: { | ||
asyncapi: '2.2.0', | ||
servers: { | ||
development: {}, | ||
production: {}, | ||
}, | ||
channels: { | ||
channel: {}, | ||
}, | ||
}, | ||
errors: [], | ||
}, | ||
|
||
{ | ||
name: 'valid case - without defined servers in the root', | ||
document: { | ||
asyncapi: '2.2.0', | ||
channels: { | ||
channel: {}, | ||
}, | ||
}, | ||
errors: [], | ||
}, | ||
|
||
{ | ||
name: 'valid case - without defined channels in the root', | ||
document: { | ||
asyncapi: '2.2.0', | ||
servers: { | ||
development: {}, | ||
production: {}, | ||
}, | ||
}, | ||
errors: [], | ||
}, | ||
|
||
{ | ||
name: 'valid case - with empty array', | ||
document: { | ||
asyncapi: '2.2.0', | ||
servers: { | ||
development: {}, | ||
production: {}, | ||
}, | ||
channels: { | ||
channel: { | ||
servers: [], | ||
}, | ||
}, | ||
}, | ||
errors: [], | ||
}, | ||
|
||
{ | ||
name: 'invalid case', | ||
document: { | ||
asyncapi: '2.2.0', | ||
servers: { | ||
development: {}, | ||
production: {}, | ||
}, | ||
channels: { | ||
channel: { | ||
servers: ['another-server'], | ||
}, | ||
}, | ||
}, | ||
errors: [ | ||
{ | ||
message: 'Channel contains server that are not defined on the "servers" object.', | ||
path: ['channels', 'channel', 'servers', '0'], | ||
severity: DiagnosticSeverity.Error, | ||
}, | ||
], | ||
}, | ||
|
||
{ | ||
name: 'invalid case - one server is defined, another one not', | ||
document: { | ||
asyncapi: '2.2.0', | ||
servers: { | ||
development: {}, | ||
production: {}, | ||
}, | ||
channels: { | ||
channel: { | ||
servers: ['production', 'another-server'], | ||
}, | ||
}, | ||
}, | ||
errors: [ | ||
{ | ||
message: 'Channel contains server that are not defined on the "servers" object.', | ||
path: ['channels', 'channel', 'servers', '1'], | ||
severity: DiagnosticSeverity.Error, | ||
}, | ||
], | ||
}, | ||
|
||
{ | ||
name: 'invalid case - without defined servers', | ||
document: { | ||
asyncapi: '2.2.0', | ||
channels: { | ||
channel: { | ||
servers: ['production'], | ||
}, | ||
}, | ||
}, | ||
errors: [ | ||
{ | ||
message: 'Channel contains server that are not defined on the "servers" object.', | ||
path: ['channels', 'channel', 'servers', '0'], | ||
severity: DiagnosticSeverity.Error, | ||
}, | ||
], | ||
}, | ||
]); |
Oops, something went wrong.