Improve tests

This commit is contained in:
Emelia Smith 2024-02-14 19:16:44 +01:00
parent 3409f76901
commit b17d3379e1
No known key found for this signature in database
1 changed files with 17 additions and 6 deletions

View File

@ -3,6 +3,12 @@
require 'rails_helper'
describe 'The /.well-known/oauth-authorization-server request' do
let(:protocol) { ENV.fetch('LOCAL_HTTPS', true) ? :https : :http }
before do
host! ENV.fetch('LOCAL_DOMAIN')
end
it 'returns http success with valid JSON response' do
get '/.well-known/oauth-authorization-server'
@ -12,12 +18,17 @@ describe 'The /.well-known/oauth-authorization-server request' do
media_type: 'application/json'
)
expect(body_as_json).to match(
a_hash_including(
# FIXME: Include tests for the important URLs (for some reason routing
# was generating mismatching URLs between the serializer and the tests)
scopes_supported: Doorkeeper.configuration.scopes.map(&:to_s)
)
grant_types_supported = Doorkeeper.configuration.grant_flows.dup
grant_types_supported << 'refresh_token' if Doorkeeper.configuration.refresh_token_enabled?
expect(body_as_json).to include(
authorization_endpoint: oauth_authorization_url(protocol: protocol),
token_endpoint: oauth_token_url(protocol: protocol),
registration_endpoint: api_v1_apps_url(protocol: protocol),
revocation_endpoint: oauth_revoke_url(protocol: protocol),
scopes_supported: Doorkeeper.configuration.scopes.map(&:to_s),
response_types_supported: Doorkeeper.configuration.authorization_response_types,
grant_types_supported: grant_types_supported
)
end
end