diff options
author | Robert Speicher <robert@gitlab.com> | 2018-01-09 19:47:31 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-01-15 13:23:07 +0300 |
commit | 3073b51762a73bd28057f0ad8498b7fb15eb27f3 (patch) | |
tree | c47acffe0082910101691a8450b735455d009c52 /spec/support | |
parent | 964fa8361ebb4b6f2d8994f89c3ba5c9c237b869 (diff) |
Merge branch 'jej/fix-disabled-oauth-access-10-3' into 'security-10-3'
[10.3] Prevent login with disabled OAuth providers
See merge request gitlab/gitlabhq!2296
(cherry picked from commit 4936650427ffc88e6ee927aedbb2c724d24b094c)
a0f9d222 Prevents login with disabled OAuth providers
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/devise_helpers.rb | 15 | ||||
-rw-r--r-- | spec/support/login_helpers.rb | 7 |
2 files changed, 16 insertions, 6 deletions
diff --git a/spec/support/devise_helpers.rb b/spec/support/devise_helpers.rb index 890a2d9d287..66874e10f38 100644 --- a/spec/support/devise_helpers.rb +++ b/spec/support/devise_helpers.rb @@ -2,13 +2,16 @@ module DeviseHelpers # explicitly tells Devise which mapping to use # this is needed when we are testing a Devise controller bypassing the router def set_devise_mapping(context:) - env = - if context.respond_to?(:env_config) - context.env_config - elsif context.respond_to?(:env) - context.env - end + env = env_from_context(context) env['devise.mapping'] = Devise.mappings[:user] if env end + + def env_from_context(context) + if context.respond_to?(:env_config) + context.env_config + elsif context.respond_to?(:env) + context.env + end + end end diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 50702a0ac88..b52b6a28c54 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -125,6 +125,13 @@ module LoginHelpers }) end + def stub_omniauth_provider(provider, context: Rails.application) + env = env_from_context(context) + + set_devise_mapping(context: context) + env['omniauth.auth'] = OmniAuth.config.mock_auth[provider] + end + def stub_omniauth_saml_config(messages) set_devise_mapping(context: Rails.application) Rails.application.routes.disable_clear_and_finalize = true |