2024-05-06 13:17:56 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-09-04 05:12:25 +00:00
|
|
|
RSpec.describe 'The /.well-known/oauth-authorization-server request' do
|
2024-05-06 13:17:56 +00:00
|
|
|
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 09:58:46 +00:00
|
|
|
expect(response.parsed_body).to include(
|
2024-10-30 14:38:10 +00:00
|
|
|
issuer: root_url,
|
2024-05-06 13:17:56 +00:00
|
|
|
service_documentation: 'https://docs.joinmastodon.org/',
|
2024-10-30 14:38:10 +00:00
|
|
|
authorization_endpoint: oauth_authorization_url,
|
|
|
|
token_endpoint: oauth_token_url,
|
|
|
|
userinfo_endpoint: oauth_userinfo_url,
|
|
|
|
revocation_endpoint: oauth_revoke_url,
|
2024-05-06 13:17:56 +00:00
|
|
|
scopes_supported: Doorkeeper.configuration.scopes.map(&:to_s),
|
|
|
|
response_types_supported: Doorkeeper.configuration.authorization_response_types,
|
2024-07-26 08:53:10 +00: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 13:17:56 +00:00
|
|
|
grant_types_supported: grant_types_supported,
|
2024-11-21 13:48:30 +00:00
|
|
|
code_challenge_methods_supported: Doorkeeper.configuration.pkce_code_challenge_methods_supported,
|
2024-05-06 13:17:56 +00:00
|
|
|
# non-standard extension:
|
2024-10-30 14:38:10 +00:00
|
|
|
app_registration_endpoint: api_v1_apps_url
|
2024-05-06 13:17:56 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|