From 5a5f1a371819b65f66bd4d629d2780bedbf39c93 Mon Sep 17 00:00:00 2001 From: Emelia Smith Date: Wed, 16 Apr 2025 22:07:30 +0200 Subject: [PATCH] Change /oauth/token request specs to use client_secret_basic authentication --- spec/requests/oauth/token_spec.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/spec/requests/oauth/token_spec.rb b/spec/requests/oauth/token_spec.rb index 7be65e7ab3..b10e912012 100644 --- a/spec/requests/oauth/token_spec.rb +++ b/spec/requests/oauth/token_spec.rb @@ -1,21 +1,28 @@ # frozen_string_literal: true require 'rails_helper' +require 'debug' RSpec.describe 'Managing OAuth Tokens' do describe 'POST /oauth/token' do subject do - post '/oauth/token', params: params + post '/oauth/token', params: params, headers: headers end let(:application) do Fabricate(:application, scopes: 'read write follow', redirect_uri: 'urn:ietf:wg:oauth:2.0:oob') end + + # This is using the OAuth client_secret_basic client authentication method + let(:headers) do + { + Authorization: ActionController::HttpAuthentication::Basic.encode_credentials(application.uid, application.secret), + } + end + let(:params) do { grant_type: grant_type, - client_id: application.uid, - client_secret: application.secret, redirect_uri: 'urn:ietf:wg:oauth:2.0:oob', code: code, scope: scope,