Fix code flow spec to use integrated session

pull/6824/head
Oliver Günther 6 years ago
parent 750544f141
commit a5b4f9414e
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 10
      spec/features/oauth/authorization_code_flow_spec.rb

@ -65,10 +65,6 @@ describe 'OAuth authorization code flow', type: :feature, js: true do
expect(user.oauth_grants.count).to eq 1 expect(user.oauth_grants.count).to eq 1
expect(user.oauth_grants.first.application).to eq app expect(user.oauth_grants.first.application).to eq app
# Use that code to get a request
host = Capybara.current_session.server.host
port = Capybara.current_session.server.port
parameters = { parameters = {
client_id: app.uid, client_id: app.uid,
client_secret: client_secret, client_secret: client_secret,
@ -77,8 +73,10 @@ describe 'OAuth authorization code flow', type: :feature, js: true do
redirect_uri: app.redirect_uri redirect_uri: app.redirect_uri
} }
response = RestClient.post "http://#{host}:#{port}/oauth/token", parameters.to_param session = ActionDispatch::Integration::Session.new(Rails.application)
body = JSON.parse(response.body) response = session.post("/oauth/token", params: parameters)
expect(response).to eq 200
body = JSON.parse(session.response.body)
expect(body['access_token']).to be_present expect(body['access_token']).to be_present
expect(body['refresh_token']).to be_present expect(body['refresh_token']).to be_present

Loading…
Cancel
Save