discourse/plugins/discourse-ai/spec/requests/mcp_oauth_controller_spec.rb
Sam a9bf76af1c
FIX: Improve MCP OAuth callback error handling (#38889)
This gets OAuth MCP into a more final state 

- Handles dynamic registration RFC
- Makes it easier to debug
- Allows the work "mcp" to find the mcp section in the app in admin
search
- Compresses UI a bit so we are not bombarded with noise
2026-03-27 07:34:24 +11:00

28 lines
1,015 B
Ruby

# frozen_string_literal: true
RSpec.describe DiscourseAi::McpOauthController do
before { enable_current_plugin }
describe "GET #client_metadata" do
it "returns a client metadata document" do
get "/discourse-ai/mcp/oauth/client-metadata.json"
expect(response).to be_successful
expect(response.parsed_body["client_name"]).to eq("Discourse AI MCP Client")
expect(response.parsed_body["redirect_uris"]).to include(
"#{Discourse.base_url}/admin/plugins/discourse-ai/ai-mcp-servers/oauth/callback",
)
expect(response.parsed_body["grant_types"]).to eq(%w[authorization_code refresh_token])
expect(response.parsed_body["token_endpoint_auth_method"]).to eq("none")
end
it "is accessible when login is required" do
SiteSetting.login_required = true
get "/discourse-ai/mcp/oauth/client-metadata.json"
expect(response).to be_successful
expect(response.parsed_body["client_name"]).to eq("Discourse AI MCP Client")
end
end
end