summaryrefslogtreecommitdiff
path: root/spec/support/login_helpers.rb
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-07-12 20:53:09 +0000
committerRobert Speicher <robert@gitlab.com>2016-07-12 20:53:09 +0000
commit488a7f5976264975c7e418674e52fb08db82bce7 (patch)
tree93f3052d2b7249c182a22d6d73dc245bf76e622a /spec/support/login_helpers.rb
parentbd7d6124524e0a2222f7837b27857b363b34729f (diff)
parent24cf6b9f62a312c010c9479fd6155f7c72099979 (diff)
downloadgitlab-ce-488a7f5976264975c7e418674e52fb08db82bce7.tar.gz
Merge branch 'add-2fa-check-to-oauth' into 'master'
Add 2FA check to the OAuth authentication mechanism Needed for https://gitlab.com/gitlab-org/gitlab-ce/issues/19312 2FA checks were not being performed when logging in via any of the OAuth providers. Just LDAP had the check. This MR fixes that. See merge request !1976
Diffstat (limited to 'spec/support/login_helpers.rb')
-rw-r--r--spec/support/login_helpers.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb
index ffdf2bb0a8a..e5f76afbfc0 100644
--- a/spec/support/login_helpers.rb
+++ b/spec/support/login_helpers.rb
@@ -37,6 +37,40 @@ module LoginHelpers
Thread.current[:current_user] = user
end
+ def login_via(provider, user, uid)
+ mock_auth_hash(provider, uid, user.email)
+ visit new_user_session_path
+ click_link provider
+ end
+
+ def mock_auth_hash(provider, uid, email)
+ # The mock_auth configuration allows you to set per-provider (or default)
+ # authentication hashes to return during integration testing.
+ OmniAuth.config.mock_auth[provider.to_sym] = OmniAuth::AuthHash.new({
+ provider: provider,
+ uid: uid,
+ info: {
+ name: 'mockuser',
+ email: email,
+ image: 'mock_user_thumbnail_url'
+ },
+ credentials: {
+ token: 'mock_token',
+ secret: 'mock_secret'
+ },
+ extra: {
+ raw_info: {
+ info: {
+ name: 'mockuser',
+ email: email,
+ image: 'mock_user_thumbnail_url'
+ }
+ }
+ }
+ })
+ Rails.application.env_config['omniauth.auth'] = OmniAuth.config.mock_auth[:saml]
+ end
+
# Requires Javascript driver.
def logout
find(".header-user-dropdown-toggle").click