summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-07-06 12:59:21 +0000
committerDouwe Maan <douwe@gitlab.com>2017-07-06 12:59:21 +0000
commita33fb2132cc9c1924fe986ce562cd7bea084a5c9 (patch)
tree93fc06817bd2b068b96e1b5813966d8e4b75b234 /spec/support
parentd6836a3bc66662618efdd4f86969bdfd0904aca8 (diff)
parent89b0c987fcba5692842f83cfaba90a9004ac91de (diff)
downloadgitlab-ce-a33fb2132cc9c1924fe986ce562cd7bea084a5c9.tar.gz
Merge branch '18000-remember-me-for-oauth-login' into 'master'
Fix `migration:path` build for "Honor the 'Remember me' parameter for OAuth-based login" Closes #34713 See merge request !12668
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/capybara_helpers.rb5
-rw-r--r--spec/support/login_helpers.rb13
2 files changed, 17 insertions, 1 deletions
diff --git a/spec/support/capybara_helpers.rb b/spec/support/capybara_helpers.rb
index b57a3493aff..3eb7bea3227 100644
--- a/spec/support/capybara_helpers.rb
+++ b/spec/support/capybara_helpers.rb
@@ -35,6 +35,11 @@ module CapybaraHelpers
visit 'about:blank'
visit url
end
+
+ # Simulate a browser restart by clearing the session cookie.
+ def clear_browser_session
+ page.driver.remove_cookie('_gitlab_session')
+ end
end
RSpec.configure do |config|
diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb
index 4c88958264b..99e7806353d 100644
--- a/spec/support/login_helpers.rb
+++ b/spec/support/login_helpers.rb
@@ -62,6 +62,16 @@ module LoginHelpers
Thread.current[:current_user] = user
end
+ def login_via(provider, user, uid, remember_me: false)
+ mock_auth_hash(provider, uid, user.email)
+ visit new_user_session_path
+ expect(page).to have_content('Sign in with')
+
+ check 'Remember Me' if remember_me
+
+ click_link "oauth-login-#{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.
@@ -108,6 +118,7 @@ module LoginHelpers
end
allow(Gitlab::OAuth::Provider).to receive_messages(providers: [:saml], config_for: mock_saml_config)
stub_omniauth_setting(messages)
- expect_any_instance_of(Object).to receive(:omniauth_authorize_path).with(:user, "saml").and_return('/users/auth/saml')
+ allow_any_instance_of(Object).to receive(:user_saml_omniauth_authorize_path).and_return('/users/auth/saml')
+ allow_any_instance_of(Object).to receive(:omniauth_authorize_path).with(:user, "saml").and_return('/users/auth/saml')
end
end