diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-07 03:07:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-07 03:07:51 +0300 |
commit | 4e375367b78bb44bd00957522cd9fc3e6d403fef (patch) | |
tree | 059b1ce541e4128bf03683407d7b5bbbc2094ed5 /spec/lib/gitlab/auth | |
parent | 99ddca0d88f1e4e49d61b1aa9d41b5785528d1dc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/auth')
-rw-r--r-- | spec/lib/gitlab/auth/ldap/access_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/auth/ldap/auth_hash_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/auth/ldap/authentication_spec.rb | 15 | ||||
-rw-r--r-- | spec/lib/gitlab/auth/o_auth/user_spec.rb | 24 |
4 files changed, 33 insertions, 14 deletions
diff --git a/spec/lib/gitlab/auth/ldap/access_spec.rb b/spec/lib/gitlab/auth/ldap/access_spec.rb index ecdd5b29986..f9eb4a30190 100644 --- a/spec/lib/gitlab/auth/ldap/access_spec.rb +++ b/spec/lib/gitlab/auth/ldap/access_spec.rb @@ -136,7 +136,9 @@ describe Gitlab::Auth::LDAP::Access do context 'without ActiveDirectory enabled' do before do allow(Gitlab::Auth::LDAP::Config).to receive(:enabled?).and_return(true) - allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive(:active_directory).and_return(false) + allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance| + allow(instance).to receive(:active_directory).and_return(false) + end end it 'returns true' do diff --git a/spec/lib/gitlab/auth/ldap/auth_hash_spec.rb b/spec/lib/gitlab/auth/ldap/auth_hash_spec.rb index adb8e138ca7..f1050b9f830 100644 --- a/spec/lib/gitlab/auth/ldap/auth_hash_spec.rb +++ b/spec/lib/gitlab/auth/ldap/auth_hash_spec.rb @@ -58,7 +58,9 @@ describe Gitlab::Auth::LDAP::AuthHash do end before do - allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive(:attributes).and_return(attributes) + allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance| + allow(instance).to receive(:attributes).and_return(attributes) + end end it "has the correct username" do diff --git a/spec/lib/gitlab/auth/ldap/authentication_spec.rb b/spec/lib/gitlab/auth/ldap/authentication_spec.rb index e68e83e4617..ebaf8383ce5 100644 --- a/spec/lib/gitlab/auth/ldap/authentication_spec.rb +++ b/spec/lib/gitlab/auth/ldap/authentication_spec.rb @@ -18,8 +18,9 @@ describe Gitlab::Auth::LDAP::Authentication do # try only to fake the LDAP call adapter = double('adapter', dn: dn).as_null_object - allow_any_instance_of(described_class) - .to receive(:adapter).and_return(adapter) + allow_next_instance_of(described_class) do |instance| + allow(instance).to receive(:adapter).and_return(adapter) + end expect(described_class.login(login, password)).to be_truthy end @@ -27,8 +28,9 @@ describe Gitlab::Auth::LDAP::Authentication do it "is false if the user does not exist" do # try only to fake the LDAP call adapter = double('adapter', dn: dn).as_null_object - allow_any_instance_of(described_class) - .to receive(:adapter).and_return(adapter) + allow_next_instance_of(described_class) do |instance| + allow(instance).to receive(:adapter).and_return(adapter) + end expect(described_class.login(login, password)).to be_falsey end @@ -38,8 +40,9 @@ describe Gitlab::Auth::LDAP::Authentication do # try only to fake the LDAP call adapter = double('adapter', bind_as: nil).as_null_object - allow_any_instance_of(described_class) - .to receive(:adapter).and_return(adapter) + allow_next_instance_of(described_class) do |instance| + allow(instance).to receive(:adapter).and_return(adapter) + end expect(described_class.login(login, password)).to be_falsey end diff --git a/spec/lib/gitlab/auth/o_auth/user_spec.rb b/spec/lib/gitlab/auth/o_auth/user_spec.rb index 1e3da4f7c2d..3b490646b6e 100644 --- a/spec/lib/gitlab/auth/o_auth/user_spec.rb +++ b/spec/lib/gitlab/auth/o_auth/user_spec.rb @@ -396,7 +396,9 @@ describe Gitlab::Auth::OAuth::User do context "and no account for the LDAP user" do context 'dont block on create (LDAP)' do before do - allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: false) + allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance| + allow(instance).to receive_messages(block_auto_created_users: false) + end end it do @@ -408,7 +410,9 @@ describe Gitlab::Auth::OAuth::User do context 'block on create (LDAP)' do before do - allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: true) + allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance| + allow(instance).to receive_messages(block_auto_created_users: true) + end end it do @@ -424,7 +428,9 @@ describe Gitlab::Auth::OAuth::User do context 'dont block on create (LDAP)' do before do - allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: false) + allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance| + allow(instance).to receive_messages(block_auto_created_users: false) + end end it do @@ -436,7 +442,9 @@ describe Gitlab::Auth::OAuth::User do context 'block on create (LDAP)' do before do - allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: true) + allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance| + allow(instance).to receive_messages(block_auto_created_users: true) + end end it do @@ -480,7 +488,9 @@ describe Gitlab::Auth::OAuth::User do context 'dont block on create (LDAP)' do before do - allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: false) + allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance| + allow(instance).to receive_messages(block_auto_created_users: false) + end end it do @@ -492,7 +502,9 @@ describe Gitlab::Auth::OAuth::User do context 'block on create (LDAP)' do before do - allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: true) + allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance| + allow(instance).to receive_messages(block_auto_created_users: true) + end end it do |