mirror of
https://github.com/mastodon/mastodon.git
synced 2025-05-11 20:21:10 +00:00
Change /oauth/token request specs to use client_secret_basic authentication
This commit is contained in:
parent
6463415e06
commit
5a5f1a3718
|
@ -1,21 +1,28 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
require 'debug'
|
||||||
|
|
||||||
RSpec.describe 'Managing OAuth Tokens' do
|
RSpec.describe 'Managing OAuth Tokens' do
|
||||||
describe 'POST /oauth/token' do
|
describe 'POST /oauth/token' do
|
||||||
subject do
|
subject do
|
||||||
post '/oauth/token', params: params
|
post '/oauth/token', params: params, headers: headers
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:application) do
|
let(:application) do
|
||||||
Fabricate(:application, scopes: 'read write follow', redirect_uri: 'urn:ietf:wg:oauth:2.0:oob')
|
Fabricate(:application, scopes: 'read write follow', redirect_uri: 'urn:ietf:wg:oauth:2.0:oob')
|
||||||
end
|
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
|
let(:params) do
|
||||||
{
|
{
|
||||||
grant_type: grant_type,
|
grant_type: grant_type,
|
||||||
client_id: application.uid,
|
|
||||||
client_secret: application.secret,
|
|
||||||
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
|
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
|
||||||
code: code,
|
code: code,
|
||||||
scope: scope,
|
scope: scope,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user