diff --git a/spec/requests/well_known/oauth_metadata_spec.rb b/spec/requests/well_known/oauth_metadata_spec.rb index d9df21f792..1e9c60fa64 100644 --- a/spec/requests/well_known/oauth_metadata_spec.rb +++ b/spec/requests/well_known/oauth_metadata_spec.rb @@ -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