Skip to content

Commit

Permalink
Showing 2 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ Signet is an OAuth 1.0 / OAuth 2.0 implementation.
require 'signet/oauth_2/client'
client = Signet::OAuth2::Client.new(
:authorization_uri => 'https://accounts.google.com/o/oauth2/auth',
:token_credential_uri => 'https://www.googleapis.com/oauth2/v3/token',
:token_credential_uri => 'https://oauth2.googleapis.com/token',
:client_id => '44410190108-74nkm6jc5e3vvjqis803frkvmu88cu3a.apps.googleusercontent.com',
:client_secret => 'X1NUhvO-rQr9sm8uUSMY8i7v',
:scope => 'email profile',
46 changes: 23 additions & 23 deletions spec/signet/oauth_2/client_spec.rb
Original file line number Diff line number Diff line change
@@ -187,10 +187,10 @@ def build_form_encoded_response(payload)
@key = OpenSSL::PKey::RSA.new 2048
@client = Signet::OAuth2::Client.new(
:token_credential_uri =>
'https://accounts.google.com/o/oauth2/token',
'https://oauth2.googleapis.com/token',
:scope => 'https://www.googleapis.com/auth/userinfo.profile',
:issuer => 'app@example.com',
:audience => 'https://accounts.google.com/o/oauth2/token',
:audience => 'https://oauth2.googleapis.com/token',
:signing_key => @key
)
end
@@ -202,7 +202,7 @@ def build_form_encoded_response(payload)
claim, header = JWT.decode(jwt, @key.public_key, true, algorithm: 'RS256')
expect(claim["iss"]).to eq 'app@example.com'
expect(claim["scope"]).to eq 'https://www.googleapis.com/auth/userinfo.profile'
expect(claim["aud"]).to eq 'https://accounts.google.com/o/oauth2/token'
expect(claim["aud"]).to eq 'https://oauth2.googleapis.com/token'
end

it 'should generate valid JWTs for impersonation' do
@@ -214,7 +214,7 @@ def build_form_encoded_response(payload)
expect(claim["iss"]).to eq 'app@example.com'
expect(claim["prn"]).to eq 'user@example.com'
expect(claim["scope"]).to eq 'https://www.googleapis.com/auth/userinfo.profile'
expect(claim["aud"]).to eq 'https://accounts.google.com/o/oauth2/token'
expect(claim["aud"]).to eq 'https://oauth2.googleapis.com/token'
end

it 'should generate valid JWTs for impersonation using deprecated person attribute' do
@@ -226,7 +226,7 @@ def build_form_encoded_response(payload)
expect(claim["iss"]).to eq 'app@example.com'
expect(claim["prn"]).to eq 'user@example.com'
expect(claim["scope"]).to eq 'https://www.googleapis.com/auth/userinfo.profile'
expect(claim["aud"]).to eq 'https://accounts.google.com/o/oauth2/token'
expect(claim["aud"]).to eq 'https://oauth2.googleapis.com/token'
end

it 'should generate valid JWTs for impersonation using the sub attribute' do
@@ -238,7 +238,7 @@ def build_form_encoded_response(payload)
expect(claim["iss"]).to eq 'app@example.com'
expect(claim["sub"]).to eq 'user@example.com'
expect(claim["scope"]).to eq 'https://www.googleapis.com/auth/userinfo.profile'
expect(claim["aud"]).to eq 'https://accounts.google.com/o/oauth2/token'
expect(claim["aud"]).to eq 'https://oauth2.googleapis.com/token'
end

it 'should generate a JSON representation of the client' do
@@ -247,16 +247,16 @@ def build_form_encoded_response(payload)
expect(json).not_to be_nil

deserialized = MultiJson.load(json)
expect(deserialized["token_credential_uri"]).to eq 'https://accounts.google.com/o/oauth2/token'
expect(deserialized["token_credential_uri"]).to eq 'https://oauth2.googleapis.com/token'
expect(deserialized["scope"]).to eq ['https://www.googleapis.com/auth/userinfo.profile']
expect(deserialized["issuer"]).to eq 'app@example.com'
expect(deserialized["audience"]).to eq 'https://accounts.google.com/o/oauth2/token'
expect(deserialized["audience"]).to eq 'https://oauth2.googleapis.com/token'
expect(deserialized["signing_key"]).to eq @key.to_s
end

it 'should send valid access token request' do
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
stub.post('/o/oauth2/token') do |env|
stub.post('/token') do |env|
params = Addressable::URI.form_unencode(env[:body])
claim, header = JWT.decode(params.assoc("assertion").last, @key.public_key, true, algorithm: 'RS256')
expect(params.assoc("grant_type")).to eq ['grant_type','urn:ietf:params:oauth:grant-type:jwt-bearer']
@@ -282,10 +282,10 @@ def build_form_encoded_response(payload)
@key = 'my secret key'
@client = Signet::OAuth2::Client.new(
:token_credential_uri =>
'https://accounts.google.com/o/oauth2/token',
'https://oauth2.googleapis.com/token',
:scope => 'https://www.googleapis.com/auth/userinfo.profile',
:issuer => 'app@example.com',
:audience => 'https://accounts.google.com/o/oauth2/token',
:audience => 'https://oauth2.googleapis.com/token',
:signing_key => @key
)
end
@@ -297,7 +297,7 @@ def build_form_encoded_response(payload)
claim, header = JWT.decode(jwt, @key, true, algorithm: 'HS256')
expect(claim["iss"]).to eq 'app@example.com'
expect(claim["scope"]).to eq 'https://www.googleapis.com/auth/userinfo.profile'
expect(claim["aud"]).to eq 'https://accounts.google.com/o/oauth2/token'
expect(claim["aud"]).to eq 'https://oauth2.googleapis.com/token'
end
end
end
@@ -308,7 +308,7 @@ def build_form_encoded_response(payload)
:authorization_uri =>
'https://accounts.google.com/o/oauth2/auth',
:token_credential_uri =>
'https://accounts.google.com/o/oauth2/token',
'https://oauth2.googleapis.com/token',
:scope => 'https://www.googleapis.com/auth/userinfo.profile'
)
end
@@ -478,7 +478,7 @@ def build_form_encoded_response(payload)
@client.client_id = 'client-12345'
@client.client_secret = 'secret-12345'
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
stub.post('/o/oauth2/token') do
stub.post('/token') do
[401, {}, 'User authorization failed or something.']
end
end
@@ -497,7 +497,7 @@ def build_form_encoded_response(payload)
@client.client_id = 'client-12345'
@client.client_secret = 'secret-12345'
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
stub.post('/o/oauth2/token') do
stub.post('/token') do
[509, {}, 'Rate limit hit or something.']
end
end
@@ -516,7 +516,7 @@ def build_form_encoded_response(payload)
@client.client_id = 'client-12345'
@client.client_secret = 'secret-12345'
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
stub.post('/o/oauth2/token') do
stub.post('/token') do
[309, {}, 'Rate limit hit or something.']
end
end
@@ -537,7 +537,7 @@ def build_form_encoded_response(payload)
@client.code = '00000'
@client.redirect_uri = 'https://www.example.com/'
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
stub.post('/o/oauth2/token') do
stub.post('/token') do
build_json_response({
'access_token' => '12345',
'refresh_token' => '54321',
@@ -563,7 +563,7 @@ def build_form_encoded_response(payload)
@client.username = 'johndoe'
@client.password = 'incognito'
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
stub.post('/o/oauth2/token') do
stub.post('/token') do
build_json_response({
'access_token' => '12345',
'refresh_token' => '54321',
@@ -588,7 +588,7 @@ def build_form_encoded_response(payload)
@client.client_secret = 'secret-12345'
@client.refresh_token = '54321'
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
stub.post('/o/oauth2/token') do
stub.post('/token') do
build_json_response({
'access_token' => '12345',
'refresh_token' => '54321',
@@ -774,7 +774,7 @@ def build_form_encoded_response(payload)
@client.client_id = 'client-12345'
@client.client_secret = 'secret-12345'
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
stub.post('/o/oauth2/token') do
stub.post('/token') do
build_json_response({
'access_token' => '12345',
'refresh_token' => '54321',
@@ -815,7 +815,7 @@ def build_form_encoded_response(payload)
@client.client_id = 'client-54321'
@client.client_secret = 'secret-12345'
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
stub.post('/o/oauth2/token') do
stub.post('/token') do
build_json_response({
'access_token' => '12345',
'refresh_token' => '54321',
@@ -850,7 +850,7 @@ def build_form_encoded_response(payload)
@client.client_id = 'client-12345'
@client.client_secret = 'secret-12345'
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
stub.post('/o/oauth2/token') do
stub.post('/token') do
build_json_response({
'access_token' => '12345',
'refresh_token' => '54321',
@@ -884,7 +884,7 @@ def build_form_encoded_response(payload)
@client.client_id = 'client-12345'
@client.client_secret = 'secret-12345'
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
stub.post('/o/oauth2/token') do
stub.post('/token') do
build_json_response({
'access_token' => '12345',
'refresh_token' => '54321',

0 comments on commit 5bde136

Please sign in to comment.