Adds auth_tests_spec and validated that it is generating valid 3.0 security related swagger

This commit is contained in:
Jay Danielian 2019-07-17 20:18:12 -04:00
parent 28bcc121ba
commit 5e71651d6d
2 changed files with 136 additions and 61 deletions

View File

@ -1,61 +1,61 @@
# # frozen_string_literal: true # frozen_string_literal: true
#
# require 'swagger_helper' require 'swagger_helper'
#
# describe 'Auth Tests API', type: :request, swagger_doc: 'v1/swagger.json' do describe 'Auth Tests API', type: :request, swagger_doc: 'v1/swagger.json' do
# path '/auth-tests/basic' do path '/auth-tests/basic' do
# post 'Authenticates with basic auth' do post 'Authenticates with basic auth' do
# tags 'Auth Tests' tags 'Auth Tests'
# operationId 'testBasicAuth' operationId 'testBasicAuth'
# security [basic_auth: []] security [basic_auth: []]
#
# response '204', 'Valid credentials' do response '204', 'Valid credentials' do
# let(:Authorization) { "Basic #{::Base64.strict_encode64('jsmith:jspass')}" } let(:Authorization) { "Basic #{::Base64.strict_encode64('jsmith:jspass')}" }
# run_test! run_test!
# end end
#
# response '401', 'Invalid credentials' do response '401', 'Invalid credentials' do
# let(:Authorization) { "Basic #{::Base64.strict_encode64('foo:bar')}" } let(:Authorization) { "Basic #{::Base64.strict_encode64('foo:bar')}" }
# run_test! run_test!
# end end
# end end
# end end
#
# path '/auth-tests/api-key' do path '/auth-tests/api-key' do
# post 'Authenticates with an api key' do post 'Authenticates with an api key' do
# tags 'Auth Tests' tags 'Auth Tests'
# operationId 'testApiKey' operationId 'testApiKey'
# security [api_key: []] security [api_key: []]
#
# response '204', 'Valid credentials' do response '204', 'Valid credentials' do
# let(:api_key) { 'foobar' } let(:api_key) { 'foobar' }
# run_test! run_test!
# end end
#
# response '401', 'Invalid credentials' do response '401', 'Invalid credentials' do
# let(:api_key) { 'barfoo' } let(:api_key) { 'barfoo' }
# run_test! run_test!
# end end
# end end
# end end
#
# path '/auth-tests/basic-and-api-key' do path '/auth-tests/basic-and-api-key' do
# post 'Authenticates with basic auth and api key' do post 'Authenticates with basic auth and api key' do
# tags 'Auth Tests' tags 'Auth Tests'
# operationId 'testBasicAndApiKey' operationId 'testBasicAndApiKey'
# security [{ basic_auth: [], api_key: [] }] security [{ basic_auth: [], api_key: [] }]
#
# response '204', 'Valid credentials' do response '204', 'Valid credentials' do
# let(:Authorization) { "Basic #{::Base64.strict_encode64('jsmith:jspass')}" } let(:Authorization) { "Basic #{::Base64.strict_encode64('jsmith:jspass')}" }
# let(:api_key) { 'foobar' } let(:api_key) { 'foobar' }
# run_test! run_test!
# end end
#
# response '401', 'Invalid credentials' do response '401', 'Invalid credentials' do
# let(:Authorization) { "Basic #{::Base64.strict_encode64('jsmith:jspass')}" } let(:Authorization) { "Basic #{::Base64.strict_encode64('jsmith:jspass')}" }
# let(:api_key) { 'barfoo' } let(:api_key) { 'barfoo' }
# run_test! run_test!
# end end
# end end
# end end
# end end

View File

@ -5,6 +5,81 @@
"version": "v1" "version": "v1"
}, },
"paths": { "paths": {
"/auth-tests/basic": {
"post": {
"summary": "Authenticates with basic auth",
"tags": [
"Auth Tests"
],
"operationId": "testBasicAuth",
"security": [
{
"basic_auth": [
]
}
],
"responses": {
"204": {
"description": "Valid credentials"
},
"401": {
"description": "Invalid credentials"
}
}
}
},
"/auth-tests/api-key": {
"post": {
"summary": "Authenticates with an api key",
"tags": [
"Auth Tests"
],
"operationId": "testApiKey",
"security": [
{
"api_key": [
]
}
],
"responses": {
"204": {
"description": "Valid credentials"
},
"401": {
"description": "Invalid credentials"
}
}
}
},
"/auth-tests/basic-and-api-key": {
"post": {
"summary": "Authenticates with basic auth and api key",
"tags": [
"Auth Tests"
],
"operationId": "testBasicAndApiKey",
"security": [
{
"basic_auth": [
],
"api_key": [
]
}
],
"responses": {
"204": {
"description": "Valid credentials"
},
"401": {
"description": "Invalid credentials"
}
}
}
},
"/blogs": { "/blogs": {
"post": { "post": {
"summary": "Creates a blog", "summary": "Creates a blog",