Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Moved the Google Omniauth key id_info from root into extra #1181

Merged
merged 3 commits into from
May 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions lib/faker/omniauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def google(name: nil, email: nil, uid: Number.number(9))
raw_info: {
sub: uid,
email: auth.email,
email_verified: random_boolean,
email_verified: random_boolean.to_s,
name: auth.name,
given_name: auth.first_name,
family_name: auth.last_name,
Expand All @@ -45,19 +45,19 @@ def google(name: nil, email: nil, uid: Number.number(9))
birthday: Date.backward(36_400).strftime('%Y-%m-%d'),
local: 'en',
hd: "#{Company.name.downcase}.com"
},
id_info: {
'iss' => 'accounts.google.com',
'at_hash' => Crypto.md5,
'email_verified' => true,
'sub' => Number.number(28).to_s,
'azp' => 'APP_ID',
'email' => auth.email,
'aud' => 'APP_ID',
'iat' => Time.forward.to_i,
'exp' => Time.forward.to_i,
'openid_id' => "https://www.google.com/accounts/o8/id?id=#{uid}"
}
},
id_info: {
'iss' => 'accounts.google.com',
'at_hash' => Crypto.md5,
'email_verified' => 'true',
'sub' => Number.number(28).to_s,
'azp' => 'APP_ID',
'email' => auth.email,
'aud' => 'APP_ID',
'iat' => Number.number(10),
'exp' => Time.forward.to_i.to_s,
'openid_id' => "https://www.google.com/accounts/o8/id?id=#{uid}"
}
}
end
Expand Down
12 changes: 6 additions & 6 deletions test/test_faker_omniauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_omniauth_google
info = auth[:info]
credentials = auth[:credentials]
extra_raw_info = auth[:extra][:raw_info]
id_info = auth[:id_info]
id_info = auth[:extra][:id_info]
plus_url = "https://plus.google.com/#{auth[:uid]}"
openid_id = "https://www.google.com/accounts/o8/id?id=#{auth[:uid]}"

Expand All @@ -34,7 +34,7 @@ def test_omniauth_google
assert_equal true, credentials[:expires]
assert_equal 9, extra_raw_info[:sub].length
assert_equal info[:email], extra_raw_info[:email]
assert [true, false].include? extra_raw_info[:email_verified]
assert %w[true false].include? extra_raw_info[:email_verified]
assert_equal info[:name], extra_raw_info[:name]
assert_equal info[:first_name], extra_raw_info[:given_name]
assert_equal info[:last_name], extra_raw_info[:family_name]
Expand All @@ -46,13 +46,13 @@ def test_omniauth_google
assert_instance_of String, extra_raw_info[:hd]
assert_equal 'accounts.google.com', id_info['iss']
assert_instance_of String, id_info['at_hash']
assert_instance_of String, id_info['email_verified']
assert [true, false].include? id_info['email_verified']
assert_equal 28, id_info['sub'].length
assert_equal 'APP_ID', id_info['azp']
assert_equal info[:email], id_info['email']
assert_equal 'APP_ID', id_info['aud']
assert_instance_of String, id_info['iat']
assert_instance_of String, id_info['exp']
assert_instance_of Fixnum, id_info['iat']
assert_instance_of Fixnum, id_info['exp']
assert_equal openid_id, id_info['openid_id']
end

Expand All @@ -79,7 +79,7 @@ def test_omniauth_google_with_email
auth = @tester.google(email: custom_email)
info = auth[:info]
extra_raw_info = auth[:extra][:raw_info]
id_info = auth[:id_info]
id_info = auth[:extra][:id_info]

assert_instance_of String, info[:email]
assert_equal custom_email, info[:email]
Expand Down