Add spec for client_credentials being used with /api/v1/apps/verify_credentials (#37195)

This commit is contained in:
Emelia Smith 2025-12-11 17:40:22 +01:00 committed by GitHub
parent addeb28292
commit d730f6b0c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -75,6 +75,33 @@ RSpec.describe 'Credentials' do
end
end
context 'with client credentials' do
let(:application) { Fabricate(:application, scopes: 'read admin:write') }
let(:token) { Fabricate(:client_credentials_token, application: application, scopes: 'read admin:write') }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
it 'returns http success and returns app information' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body).to match(
a_hash_including(
id: token.application.id.to_s,
name: token.application.name,
website: token.application.website,
scopes: token.application.scopes.map(&:to_s),
redirect_uris: token.application.redirect_uris,
# Deprecated properties as of 4.3:
redirect_uri: token.application.redirect_uri.split.first,
vapid_key: Rails.configuration.x.vapid.public_key
)
)
end
end
context 'without an oauth token' do
let(:headers) { {} }