diff options
author | Patricio Cano <suprnova32@gmail.com> | 2016-07-05 16:34:34 -0500 |
---|---|---|
committer | Patricio Cano <suprnova32@gmail.com> | 2016-07-07 16:54:03 -0500 |
commit | 2a0be666e3078e28a02de298b386ec4c09232978 (patch) | |
tree | fdb020ec2b4547a46e935160f2f62a404134d6b5 /spec/features | |
parent | eda205342140e1bc71b5f0b6935b5ffc502a85cd (diff) | |
download | gitlab-ce-2a0be666e3078e28a02de298b386ec4c09232978.tar.gz |
Added a lot of stubbing to make sure OAUth requests are handled properly with 2FA
Diffstat (limited to 'spec/features')
-rw-r--r-- | spec/features/login_spec.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/spec/features/login_spec.rb b/spec/features/login_spec.rb index 39968db5b58..58753ff21f6 100644 --- a/spec/features/login_spec.rb +++ b/spec/features/login_spec.rb @@ -110,12 +110,29 @@ feature 'Login', feature: true do end context 'logging in via OAuth' do + def saml_config + OpenStruct.new(name: 'saml', label: 'saml', args: { + assertion_consumer_service_url: 'https://localhost:3443/users/auth/saml/callback', + idp_cert_fingerprint: '26:43:2C:47:AF:F0:6B:D0:07:9C:AD:A3:74:FE:5D:94:5F:4E:9E:52', + idp_sso_target_url: 'https://idp.example.com/sso/saml', + issuer: 'https://localhost:3443/', + name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient' + }) + end + def stub_omniauth_config(messages) + Rails.application.env_config['devise.mapping'] = Devise.mappings[:user] + Rails.application.routes.disable_clear_and_finalize = true + Rails.application.routes.draw do + post '/users/auth/saml' => 'omniauth_callbacks#saml' + end + allow(Gitlab::OAuth::Provider).to receive_messages(providers: [:saml], config_for: saml_config) allow(Gitlab.config.omniauth).to receive_messages(messages) + allow_any_instance_of(Object).to receive(:user_omniauth_authorize_path).with('saml').and_return('/users/auth/saml') end it 'should show 2FA prompt after OAuth login' do - stub_omniauth_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ['saml'], providers: [OpenStruct.new(name: 'saml', label: 'saml', args: {})]) + stub_omniauth_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ['saml'], providers: [saml_config]) user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: 'saml') login_via('saml', user, 'my-uid') |