Created
January 9, 2020 17:20
-
-
Save dcorking/489f7008e874a30c0ec88638ee4fda4e to your computer and use it in GitHub Desktop.
testing a doorkeeper token request via a password grant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
RSpec.describe '/oauth/', type: :request do | |
let(:application) { create(:doorkeeper_application, confidential: false) } | |
let(:user) { create(:user, email: 'joe@example.com', password: "PASSWORD") } | |
let(:valid_params) do | |
{ | |
username: user.email, | |
password: "PASSWORD", | |
grant_type: 'password', | |
client_id: application.uid, | |
} | |
end | |
describe '#POST /oauth/token/' do | |
context 'with valid params' do | |
it 'returns a token' do | |
post '/oauth/token', params: valid_params, as: :json | |
expect(response).to have_http_status :ok | |
response_object = JSON.parse(response.body) | |
expect(response_object).to have_key 'access_token' | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment