summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab
diff options
context:
space:
mode:
authorPatricio Cano <suprnova32@gmail.com>2016-02-18 17:02:43 -0500
committerPatricio Cano <suprnova32@gmail.com>2016-02-18 17:02:43 -0500
commitbb4fa3a185d6cf0e2fbd5d11917ba5bcdbf92926 (patch)
treeff71d4ba9a9e0ced72d77c81d44739d61d839903 /spec/lib/gitlab
parent06376be56a84b43976b63aad91638fb2c00fec1a (diff)
downloadgitlab-ce-bb4fa3a185d6cf0e2fbd5d11917ba5bcdbf92926.tar.gz
Make new `allow_single_sign_on` feature backwards compatible
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r--spec/lib/gitlab/o_auth/user_spec.rb24
-rw-r--r--spec/lib/gitlab/saml/user_spec.rb2
2 files changed, 23 insertions, 3 deletions
diff --git a/spec/lib/gitlab/o_auth/user_spec.rb b/spec/lib/gitlab/o_auth/user_spec.rb
index 76b1360f208..3a769acfdc0 100644
--- a/spec/lib/gitlab/o_auth/user_spec.rb
+++ b/spec/lib/gitlab/o_auth/user_spec.rb
@@ -41,7 +41,7 @@ describe Gitlab::OAuth::User, lib: true do
describe 'signup' do
shared_examples "to verify compliance with allow_single_sign_on" do
- context "with allow_single_sign_on enabled" do
+ context "with new allow_single_sign_on enabled syntax" do
before { stub_omniauth_config(allow_single_sign_on: ['twitter']) }
it "creates a user from Omniauth" do
@@ -54,12 +54,32 @@ describe Gitlab::OAuth::User, lib: true do
end
end
- context "with allow_single_sign_on disabled (Default)" do
+ context "with old allow_single_sign_on enabled syntax" do
+ before { stub_omniauth_config(allow_single_sign_on: true) }
+
+ it "creates a user from Omniauth" do
+ oauth_user.save
+
+ expect(gl_user).to be_valid
+ identity = gl_user.identities.first
+ expect(identity.extern_uid).to eql uid
+ expect(identity.provider).to eql 'twitter'
+ end
+ end
+
+ context "with new allow_single_sign_on disabled syntax" do
before { stub_omniauth_config(allow_single_sign_on: []) }
it "throws an error" do
expect{ oauth_user.save }.to raise_error StandardError
end
end
+
+ context "with old allow_single_sign_on disabled (Default)" do
+ before { stub_omniauth_config(allow_single_sign_on: false) }
+ it "throws an error" do
+ expect{ oauth_user.save }.to raise_error StandardError
+ end
+ end
end
context "with auto_link_ldap_user disabled (default)" do
diff --git a/spec/lib/gitlab/saml/user_spec.rb b/spec/lib/gitlab/saml/user_spec.rb
index 480ca1aee4b..de7cd99d49d 100644
--- a/spec/lib/gitlab/saml/user_spec.rb
+++ b/spec/lib/gitlab/saml/user_spec.rb
@@ -61,7 +61,7 @@ describe Gitlab::Saml::User, lib: true do
end
context 'with allow_single_sign_on disabled' do
- before { stub_omniauth_config(allow_single_sign_on: []) }
+ before { stub_omniauth_config(allow_single_sign_on: false) }
it 'should throw an error' do
expect{ saml_user.save }.to raise_error StandardError
end