oauth_metadata_spec.rb 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe 'The /.well-known/oauth-authorization-server request' do
  4. it 'returns http success with valid JSON response' do
  5. get '/.well-known/oauth-authorization-server'
  6. expect(response)
  7. .to have_http_status(200)
  8. .and have_attributes(
  9. media_type: 'application/json'
  10. )
  11. grant_types_supported = Doorkeeper.configuration.grant_flows.dup
  12. grant_types_supported << 'refresh_token' if Doorkeeper.configuration.refresh_token_enabled?
  13. expect(response.parsed_body).to include(
  14. issuer: root_url,
  15. service_documentation: 'https://docs.joinmastodon.org/',
  16. authorization_endpoint: oauth_authorization_url,
  17. token_endpoint: oauth_token_url,
  18. userinfo_endpoint: oauth_userinfo_url,
  19. revocation_endpoint: oauth_revoke_url,
  20. scopes_supported: Doorkeeper.configuration.scopes.map(&:to_s),
  21. response_types_supported: Doorkeeper.configuration.authorization_response_types,
  22. response_modes_supported: Doorkeeper.configuration.authorization_response_flows.flat_map(&:response_mode_matches).uniq,
  23. token_endpoint_auth_methods_supported: %w(client_secret_basic client_secret_post),
  24. grant_types_supported: grant_types_supported,
  25. code_challenge_methods_supported: ['S256'],
  26. # non-standard extension:
  27. app_registration_endpoint: api_v1_apps_url
  28. )
  29. end
  30. end