diff options
author | Robert Speicher <robert@gitlab.com> | 2017-04-25 15:56:48 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-04-25 15:56:48 +0000 |
commit | b93cc690b03d921669cc8c4dc389e3e2afcbdc48 (patch) | |
tree | ed96e682bff913380ef3c7da5f4ff30e2e659f29 /spec | |
parent | 95bf03063d3a1e2081e5b6189c1c7be6f4cf5482 (diff) | |
parent | d7e2ac729317ace2ccf0203663637ba32f328d1a (diff) | |
download | gitlab-ce-b93cc690b03d921669cc8c4dc389e3e2afcbdc48.tar.gz |
Merge branch 'dm-fix-oauth-user-creation' into 'master'
Fix OAuth, LDAP and SAML SSO when regular sign-ups are disabled
Closes #31294
See merge request !10896
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/ldap/user_spec.rb | 12 | ||||
-rw-r--r-- | spec/lib/gitlab/o_auth/user_spec.rb | 14 | ||||
-rw-r--r-- | spec/lib/gitlab/saml/user_spec.rb | 12 |
3 files changed, 38 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ldap/user_spec.rb b/spec/lib/gitlab/ldap/user_spec.rb index 346cf0d117c..65a304d1468 100644 --- a/spec/lib/gitlab/ldap/user_spec.rb +++ b/spec/lib/gitlab/ldap/user_spec.rb @@ -108,6 +108,18 @@ describe Gitlab::LDAP::User, lib: true do it "creates a new user if not found" do expect{ ldap_user.save }.to change{ User.count }.by(1) end + + context 'when signup is disabled' do + before do + stub_application_setting signup_enabled: false + end + + it 'creates the user' do + ldap_user.save + + expect(gl_user).to be_persisted + end + end end describe 'updating email' do diff --git a/spec/lib/gitlab/o_auth/user_spec.rb b/spec/lib/gitlab/o_auth/user_spec.rb index 8f09266c3b3..6d3ac62d9e9 100644 --- a/spec/lib/gitlab/o_auth/user_spec.rb +++ b/spec/lib/gitlab/o_auth/user_spec.rb @@ -40,6 +40,20 @@ describe Gitlab::OAuth::User, lib: true do let(:provider) { 'twitter' } describe 'signup' do + context 'when signup is disabled' do + before do + stub_application_setting signup_enabled: false + end + + it 'creates the user' do + stub_omniauth_config(allow_single_sign_on: ['twitter']) + + oauth_user.save + + expect(gl_user).to be_persisted + end + end + it 'marks user as having password_automatically_set' do stub_omniauth_config(allow_single_sign_on: ['twitter'], external_providers: ['twitter']) diff --git a/spec/lib/gitlab/saml/user_spec.rb b/spec/lib/gitlab/saml/user_spec.rb index 4f6ef3c10fc..b3b76a6d629 100644 --- a/spec/lib/gitlab/saml/user_spec.rb +++ b/spec/lib/gitlab/saml/user_spec.rb @@ -211,6 +211,18 @@ describe Gitlab::Saml::User, lib: true do end end end + + context 'when signup is disabled' do + before do + stub_application_setting signup_enabled: false + end + + it 'creates the user' do + saml_user.save + + expect(gl_user).to be_persisted + end + end end describe 'blocking' do |