diff options
author | James Edwards-Jones <jedwardsjones@gitlab.com> | 2019-06-18 19:30:21 +0100 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2019-07-03 21:06:41 +0100 |
commit | 502b7226cd4e3b61d45218864f8579676e1b2b6d (patch) | |
tree | 0a9859ef8d4ec1ccc66eb0fcbb21050fce98932d | |
parent | f8825f953824a2efb95e5c256c1fd5d89b4f5eba (diff) | |
download | gitlab-ce-ce-jej/fix-group-saml-u2f.tar.gz |
Backport helpers for fake U2F and SAMLce-jej/fix-group-saml-u2f
These come from an EE MR where we needed to test the interaction
between Group SAML and U2F.
Introduces helper methods for fake interaction with U2F authentication.
-rw-r--r-- | spec/support/helpers/fake_u2f_device.rb | 4 | ||||
-rw-r--r-- | spec/support/helpers/login_helpers.rb | 12 |
2 files changed, 15 insertions, 1 deletions
diff --git a/spec/support/helpers/fake_u2f_device.rb b/spec/support/helpers/fake_u2f_device.rb index a7605cd483a..22cd8152d77 100644 --- a/spec/support/helpers/fake_u2f_device.rb +++ b/spec/support/helpers/fake_u2f_device.rb @@ -32,6 +32,10 @@ class FakeU2fDevice ") end + def fake_u2f_authentication + @page.execute_script("window.gl.u2fAuthenticate.renderAuthenticated('abc');") + end + private def u2f_device(app_id) diff --git a/spec/support/helpers/login_helpers.rb b/spec/support/helpers/login_helpers.rb index 0bb2d2510c2..0cb99b4e087 100644 --- a/spec/support/helpers/login_helpers.rb +++ b/spec/support/helpers/login_helpers.rb @@ -87,12 +87,17 @@ module LoginHelpers click_link "oauth-login-#{provider}" end + def fake_successful_u2f_authentication + allow(U2fRegistration).to receive(:authenticate).and_return(true) + FakeU2fDevice.new(page, nil).fake_u2f_authentication + end + def mock_auth_hash_with_saml_xml(provider, uid, email, saml_response) response_object = { document: saml_xml(saml_response) } mock_auth_hash(provider, uid, email, response_object: response_object) end - def mock_auth_hash(provider, uid, email, response_object: nil) + def configure_mock_auth(provider, uid, email, response_object: nil) # 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({ @@ -118,6 +123,11 @@ module LoginHelpers response_object: response_object } }) + end + + def mock_auth_hash(provider, uid, email, response_object: nil) + configure_mock_auth(provider, uid, email, response_object: response_object) + original_env_config_omniauth_auth = Rails.application.env_config['omniauth.auth'] Rails.application.env_config['omniauth.auth'] = OmniAuth.config.mock_auth[provider.to_sym] |