Add tests for openid signup with every provider
The spec for omniauth doesn't test signup for every provider, and it doesn't test if it has tests for all available providers Also, we no longer use secrets * Add model test to check if the omniauth providers have changed * Test signup using every provider * Replace secretswith environment variables
This commit is contained in:
parent
9341edd9cb
commit
95b88be061
3 changed files with 107 additions and 4 deletions
|
|
@ -2,10 +2,14 @@ module OmniauthMacros
|
|||
# The mock_auth configuration allows you to set per-provider (or default)
|
||||
# authentication hashes to return during integration testing.
|
||||
|
||||
Rails.application.secrets.google_key = 'test key google'
|
||||
Rails.application.secrets.google_secret = 'test secret google'
|
||||
Rails.application.secrets.facebook_key = 'test key facebook'
|
||||
Rails.application.secrets.facebook_secret = 'test secret facebook'
|
||||
ENV['OSEM_GOOGLE_KEY'] = 'test key google'
|
||||
ENV['OSEM_GOOGLE_SECRET'] = 'test secret google'
|
||||
ENV['OSEM_FACEBOOK_KEY'] = 'test key facebook'
|
||||
ENV['OSEM_FACEBOOK_SECRET'] = 'test secret facebook'
|
||||
ENV['OSEM_SUSE_KEY'] = 'test key suse'
|
||||
ENV['OSEM_SUSE_SECRET'] = 'test secret suse'
|
||||
ENV['OSEM_GITHUB_KEY'] = 'test key github'
|
||||
ENV['OSEM_GITHUB_SECRET'] = 'test secret github'
|
||||
|
||||
def mock_auth_new_user
|
||||
OmniAuth.config.mock_auth[:google] =
|
||||
|
|
@ -74,4 +78,71 @@ module OmniauthMacros
|
|||
}
|
||||
)
|
||||
end
|
||||
|
||||
# We use these mock accounts to ensure that the ones which are available in
|
||||
# development are valid, to test omniauth actions and verify that a mock
|
||||
# account is available for every supported omniauth provider.
|
||||
# These must be identical to the ones in /config/environments/development.rb
|
||||
# Remember to keep them in sync with development.rb
|
||||
def mock_auth_accounts
|
||||
OmniAuth.config.mock_auth[:facebook] =
|
||||
OmniAuth::AuthHash.new(
|
||||
provider: 'facebook',
|
||||
uid: 'facebook-test-uid-1',
|
||||
info: {
|
||||
name: 'facebook user',
|
||||
email: 'user-facebook@example.com',
|
||||
username: 'user_facebook'
|
||||
},
|
||||
credentials: {
|
||||
token: 'fb_mock_token',
|
||||
secret: 'fb_mock_secret'
|
||||
}
|
||||
)
|
||||
|
||||
OmniAuth.config.mock_auth[:google] =
|
||||
OmniAuth::AuthHash.new(
|
||||
provider: 'google',
|
||||
uid: 'google-test-uid-1',
|
||||
info: {
|
||||
name: 'google user',
|
||||
email: 'user-google@example.com',
|
||||
username: 'user_google'
|
||||
},
|
||||
credentials: {
|
||||
token: 'google_mock_token',
|
||||
secret: 'google_mock_secret'
|
||||
}
|
||||
)
|
||||
|
||||
OmniAuth.config.mock_auth[:suse] =
|
||||
OmniAuth::AuthHash.new(
|
||||
provider: 'suse',
|
||||
uid: 'suse-test-uid-1',
|
||||
info: {
|
||||
name: 'suse user',
|
||||
email: 'user-suse@example.com',
|
||||
username: 'user_suse'
|
||||
},
|
||||
credentials: {
|
||||
token: 'suse_mock_token',
|
||||
secret: 'suse_mock_secret'
|
||||
}
|
||||
)
|
||||
|
||||
OmniAuth.config.mock_auth[:github] =
|
||||
OmniAuth::AuthHash.new(
|
||||
provider: 'github',
|
||||
uid: 'github-test-uid-1',
|
||||
info: {
|
||||
name: 'github user',
|
||||
email: 'user-github@example.com',
|
||||
username: 'user_github'
|
||||
},
|
||||
credentials: {
|
||||
token: 'github_mock_token',
|
||||
secret: 'github_mock_secret'
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue