Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Adds a test in case the /me endpoint fails.

Marcello Rocha0654dcb0f7df
diff --git a/spec/services/oauth_clients/one_drive_connection_manager_spec.rb b/spec/services/oauth_clients/one_drive_connection_manager_spec.rb
index c44a0503fe4..74402d40a25 100644
--- a/spec/services/oauth_clients/one_drive_connection_manager_spec.rb
+++ b/spec/services/oauth_clients/one_drive_connection_manager_spec.rb
@@ -86,6 +86,18 @@ RSpec.describe OAuthClients::ConnectionManager, :webmock, type: :model do
expect(last_token.origin_user_id).to eq('87d349ed-44d7-43e1-9a83-5f2406dee5bd')
end
+
+ context 'when the identification request fails' do
+ before do
+ stub_request(:get, 'https://graph.microsoft.com/v1.0/me')
+ .with(headers: { Authorization: "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik5HVEZ2ZEstZnl0aEV1Q..." })
+ .to_return(status: 404)
+ end
+
+ it 'raises an error' do
+ expect { subject.code_to_token(code) }.to raise_error(HTTPX::HTTPError)
+ end
+ end
end
describe '#get_authorization_uri' do