Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tests for security schemes prefixed with x- and X- #188

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 9 additions & 1 deletion datamodel/high/v3/document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func TestNewDocument_Components_Responses(t *testing.T) {
func TestNewDocument_Components_SecuritySchemes(t *testing.T) {
initTest()
h := NewDocument(lowDoc)
assert.Len(t, h.Components.SecuritySchemes, 3)
assert.Len(t, h.Components.SecuritySchemes, 5)

api := h.Components.SecuritySchemes["APIKeyScheme"]
assert.Equal(t, "an apiKey security scheme", api.Description)
Expand All @@ -295,6 +295,14 @@ func TestNewDocument_Components_SecuritySchemes(t *testing.T) {
assert.Equal(t, "read all burgers", oAuth.Flows.Implicit.Scopes["read:burgers"])
assert.Equal(t, "https://pb33f.io/oauth", oAuth.Flows.AuthorizationCode.AuthorizationUrl)

basic := h.Components.SecuritySchemes["x-basic"]
assert.NotNil(t, basic)
assert.Equal(t, "a basic security scheme", basic.Description)

bearer := h.Components.SecuritySchemes["X-Bearer"]
assert.NotNil(t, bearer)
assert.Equal(t, "a bearer security scheme", bearer.Description)

// check the lowness is low.
assert.Equal(t, 380, oAuth.Flows.GoLow().Implicit.Value.Scopes.KeyNode.Line)
assert.Equal(t, 11, oAuth.Flows.GoLow().Implicit.Value.Scopes.KeyNode.Column)
Expand Down
10 changes: 9 additions & 1 deletion datamodel/low/v3/create_document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ func TestCreateDocument_Components_SecuritySchemes(t *testing.T) {
initTest()
components := doc.Components.Value
securitySchemes := components.SecuritySchemes.Value
assert.Len(t, securitySchemes, 3)
assert.Len(t, securitySchemes, 5)

apiKey := components.FindSecurityScheme("APIKeyScheme").Value
assert.NotNil(t, apiKey)
Expand All @@ -473,6 +473,14 @@ func TestCreateDocument_Components_SecuritySchemes(t *testing.T) {
assert.NotNil(t, oAuth.Flows.Value.Implicit.Value)
assert.NotNil(t, oAuth.Flows.Value.AuthorizationCode.Value)

basic := components.FindSecurityScheme("x-basic").Value
assert.NotNil(t, basic)
assert.Equal(t, "a basic security scheme", basic.Description.Value)

bearer := components.FindSecurityScheme("X-Bearer").Value
assert.NotNil(t, bearer)
assert.Equal(t, "a bearer security scheme", bearer.Description.Value)

scopes := oAuth.Flows.Value.Implicit.Value.Scopes.Value
assert.NotNil(t, scopes)

Expand Down
8 changes: 8 additions & 0 deletions test_specs/burgershop.openapi-modified.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,14 @@ components:
scopes:
write:burgers: modify burgers and stuff
read:burgers: read all the burgers
x-basic:
description: a basic security scheme
type: http
scheme: basic
X-Bearer:
description: a bearer security scheme
type: http
scheme: bearer
parameters:
BurgerHeader:
in: header
Expand Down
8 changes: 8 additions & 0 deletions test_specs/burgershop.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,14 @@ components:
scopes:
write:burgers: modify burgers and stuff
read:burgers: read all the burgers
x-basic:
description: a basic security scheme
type: http
scheme: basic
X-Bearer:
description: a bearer security scheme
type: http
scheme: bearer
parameters:
BurgerHeader:
in: header
Expand Down
Loading