2024-05-06 23:17:56 +10:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-09-04 15:12:25 +10:00
|
|
|
RSpec.describe 'The /.well-known/oauth-authorization-server request' do
|
2024-05-06 23:17:56 +10:00
|
|
|
let(:protocol) { ENV.fetch('LOCAL_HTTPS', true) ? :https : :http }
|
|
|
|
|
|
|
|
before do
|
2024-06-03 19:15:58 +10:00
|
|
|
host! Rails.configuration.x.local_domain
|
2024-05-06 23:17:56 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http success with valid JSON response' do
|
|
|
|
get '/.well-known/oauth-authorization-server'
|
|
|
|
|
|
|
|
expect(response)
|
|
|
|
.to have_http_status(200)
|
|
|
|
.and have_attributes(
|
|
|
|
media_type: 'application/json'
|
|
|
|
)
|
|
|
|
|
|
|
|
grant_types_supported = Doorkeeper.configuration.grant_flows.dup
|
|
|
|
grant_types_supported << 'refresh_token' if Doorkeeper.configuration.refresh_token_enabled?
|
|
|
|
|
2024-09-06 19:58:46 +10:00
|
|
|
expect(response.parsed_body).to include(
|
2024-05-06 23:17:56 +10:00
|
|
|
issuer: root_url(protocol: protocol),
|
|
|
|
service_documentation: 'https://docs.joinmastodon.org/',
|
|
|
|
authorization_endpoint: oauth_authorization_url(protocol: protocol),
|
|
|
|
token_endpoint: oauth_token_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,
|
2024-07-26 18:53:10 +10:00
|
|
|
response_modes_supported: Doorkeeper.configuration.authorization_response_flows.flat_map(&:response_mode_matches).uniq,
|
|
|
|
token_endpoint_auth_methods_supported: %w(client_secret_basic client_secret_post),
|
2024-05-06 23:17:56 +10:00
|
|
|
grant_types_supported: grant_types_supported,
|
2024-07-26 18:53:10 +10:00
|
|
|
code_challenge_methods_supported: ['S256'],
|
2024-05-06 23:17:56 +10:00
|
|
|
# non-standard extension:
|
|
|
|
app_registration_endpoint: api_v1_apps_url(protocol: protocol)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|