diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-04-24 13:18:10 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-04-24 13:18:10 +0300 |
commit | 1e624f3401fd426f8fff7064184061d71d36f5bf (patch) | |
tree | 72f7fb98cdf52541a7c434fd042deb5880495608 /spec/support/controllers | |
parent | d210c6b6d9251d4e002ed05285975d498c5faee4 (diff) | |
parent | dd09a19ad6f9daf36cd26c749be2b90d4f968b92 (diff) |
Merge branch 'jej/refactor-omniauth-controller' into 'master'
Refactor OmniauthCallbacksController to remove duplication
Closes #26559
See merge request gitlab-org/gitlab-ce!16694
Diffstat (limited to 'spec/support/controllers')
-rw-r--r-- | spec/support/controllers/ldap_omniauth_callbacks_controller_shared_context.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/support/controllers/ldap_omniauth_callbacks_controller_shared_context.rb b/spec/support/controllers/ldap_omniauth_callbacks_controller_shared_context.rb new file mode 100644 index 00000000000..72912ffb89d --- /dev/null +++ b/spec/support/controllers/ldap_omniauth_callbacks_controller_shared_context.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +shared_context 'Ldap::OmniauthCallbacksController' do + include LoginHelpers + include LdapHelpers + + let(:uid) { 'my-uid' } + let(:provider) { 'ldapmain' } + let(:valid_login?) { true } + let(:user) { create(:omniauth_user, extern_uid: uid, provider: provider) } + let(:ldap_server_config) do + { main: ldap_config_defaults(:main) } + end + + def ldap_config_defaults(key, hash = {}) + { + provider_name: "ldap#{key}", + attributes: {}, + encryption: 'plain' + }.merge(hash) + end + + before do + stub_ldap_setting(enabled: true, servers: ldap_server_config) + described_class.define_providers! + Rails.application.reload_routes! + + mock_auth_hash(provider.to_s, uid, user.email) + stub_omniauth_provider(provider, context: request) + + allow(Gitlab::Auth::LDAP::Access).to receive(:allowed?).and_return(valid_login?) + end +end |