Skip to content

Instantly share code, notes, and snippets.

@dcorking
Created January 9, 2020 17:20
Show Gist options
  • Save dcorking/489f7008e874a30c0ec88638ee4fda4e to your computer and use it in GitHub Desktop.
Save dcorking/489f7008e874a30c0ec88638ee4fda4e to your computer and use it in GitHub Desktop.
testing a doorkeeper token request via a password grant
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