Skip to content

Commit

Permalink
Omniauth types changes, some booleans should have been strings, some …
Browse files Browse the repository at this point in the history
…strings should have been booleans and fixnums, these types were taken from the omniauth-google docs. https://github.com/zquestz/omniauth-google-oauth2#auth-hash - I found my code which was passing tests was failing in production because the real life auth hash didn't match that faked.
  • Loading branch information
SirRawlins committed May 16, 2018
1 parent 71d2a8a commit 6ca9297
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 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 @@ -49,13 +49,13 @@ def google(name: nil, email: nil, uid: Number.number(9))
id_info: {
"iss" => "accounts.google.com",
"at_hash" => Crypto.md5,
"email_verified" => "true",
"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,
"iat" => Time.forward.to_i,
"exp" => Time.forward.to_i,
"openid_id" => "https://www.google.com/accounts/o8/id?id=#{uid}"
}
}
Expand Down
22 changes: 11 additions & 11 deletions test/test_faker_omniauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 ['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 @@ -44,16 +44,16 @@ def test_omniauth_google
assert_instance_of String, extra_raw_info[:birthday]
assert_equal 'en', extra_raw_info[:local]
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_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_equal openid_id, id_info['openid_id']
assert_equal "accounts.google.com", id_info["iss"]
assert_instance_of String, id_info["at_hash"]
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 Fixnum, id_info["iat"]
assert_instance_of Fixnum, id_info["exp"]
assert_equal openid_id, id_info["openid_id"]
end

def test_omniauth_google_with_name
Expand Down

0 comments on commit 6ca9297

Please sign in to comment.