Commit c06cc70a authored by Rémy Coutable's avatar Rémy Coutable

Revert Rails.application.env_config after using mock_auth_hash

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 24c9c458
......@@ -41,11 +41,15 @@ describe Groups::OmniauthCallbacksController do
context "valid credentials" do
before do
mock_auth_hash(provider, uid, user.email, response_object: saml_response)
@original_env_config_omniauth_auth = mock_auth_hash(provider, uid, user.email, response_object: saml_response)
stub_omniauth_provider(provider, context: request)
stub_last_request_id(last_request_id)
end
after do
Rails.application.env_config['omniauth.auth'] = @original_env_config_omniauth_auth
end
shared_examples "and identity already linked" do
let!(:user) { create_linked_user }
......
......@@ -9,10 +9,14 @@ describe OmniauthCallbacksController, type: :controller do
let(:user) { create(:omniauth_user, extern_uid: extern_uid, provider: provider) }
before do
mock_auth_hash(provider.to_s, +extern_uid, user.email)
@original_env_config_omniauth_auth = mock_auth_hash(provider.to_s, +extern_uid, user.email)
stub_omniauth_provider(provider, context: request)
end
after do
Rails.application.env_config['omniauth.auth'] = @original_env_config_omniauth_auth
end
context 'when the user is on the last sign in attempt' do
let(:extern_uid) { 'my-uid' }
......
......@@ -25,9 +25,13 @@ shared_context 'Ldap::OmniauthCallbacksController' do
described_class.define_providers!
Rails.application.reload_routes!
mock_auth_hash(provider.to_s, uid, user.email)
@original_env_config_omniauth_auth = 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
after do
Rails.application.env_config['omniauth.auth'] = @original_env_config_omniauth_auth
end
end
......@@ -118,7 +118,10 @@ module LoginHelpers
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]
original_env_config_omniauth_auth
end
def saml_xml(raw_saml_response)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment