Sha256: 026f4a476d765da52cdcbb98128ce18c3e802cf40b7bd7bd00dd984cdc9bdafd
Contents?: true
Size: 1.48 KB
Versions: 5
Compression:
Stored size: 1.48 KB
Contents
## NOT CAPYBARA # ActionDispatch::IntegrationTest # http://guides.rubyonrails.org/testing.html#integration-testing # used so we can test POST actions ^_^ require 'test_helper' class OauthTokenTest < ActionDispatch::IntegrationTest setup do @user = create_user end test "exchange a code for a token" do auth_grant = create_auth_grant_for_user(@user) client = auth_grant.application params = {:code => auth_grant.code, :client_id => client.client_id, :client_secret => client.client_secret} as_user(@user).post oauth_token_path(params) json_hash = JSON.parse(response.body) assert json_hash["access_token"] assert_equal json_hash["access_token"], auth_grant.access_token assert json_hash["refresh_token"] assert_equal json_hash["refresh_token"], auth_grant.refresh_token end test 'header authorization token' do auth_grant = create_auth_grant_for_user(@user) auth_grant.update_attributes(:permissions => {:write => true}) # curl -H "Authorization: token OAUTH-TOKEN" http://localhost:3000 # sets request.env["HTTP_AUTHORIZATION"] to "token OAUTH-TOKEN" access_token = auth_grant.access_token headers = {"HTTP_AUTHORIZATION" => "token #{access_token}"} post oauth_tests_path, {}, headers assert_equal 200, status headers = {"HTTP_AUTHORIZATION" => "Bearer #{access_token}"} post oauth_tests_path, {}, headers assert_equal 200, status end end
Version data entries
5 entries across 5 versions & 1 rubygems