diff options
Diffstat (limited to 'spec/lib/gitlab/auth/ldap')
-rw-r--r-- | spec/lib/gitlab/auth/ldap/access_spec.rb | 10 | ||||
-rw-r--r-- | spec/lib/gitlab/auth/ldap/adapter_spec.rb | 10 | ||||
-rw-r--r-- | spec/lib/gitlab/auth/ldap/auth_hash_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/auth/ldap/authentication_spec.rb | 8 | ||||
-rw-r--r-- | spec/lib/gitlab/auth/ldap/config_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/auth/ldap/dn_spec.rb | 50 | ||||
-rw-r--r-- | spec/lib/gitlab/auth/ldap/person_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/auth/ldap/user_spec.rb | 2 |
8 files changed, 45 insertions, 45 deletions
diff --git a/spec/lib/gitlab/auth/ldap/access_spec.rb b/spec/lib/gitlab/auth/ldap/access_spec.rb index f9eb4a30190..2f691429541 100644 --- a/spec/lib/gitlab/auth/ldap/access_spec.rb +++ b/spec/lib/gitlab/auth/ldap/access_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Auth::LDAP::Access do +describe Gitlab::Auth::Ldap::Access do include LdapHelpers let(:user) { create(:omniauth_user) } @@ -64,7 +64,7 @@ describe Gitlab::Auth::LDAP::Access do context 'and the user is disabled via active directory' do before do - allow(Gitlab::Auth::LDAP::Person).to receive(:disabled_via_active_directory?).and_return(true) + allow(Gitlab::Auth::Ldap::Person).to receive(:disabled_via_active_directory?).and_return(true) end it 'returns false' do @@ -90,7 +90,7 @@ describe Gitlab::Auth::LDAP::Access do context 'and has no disabled flag in active directory' do before do - allow(Gitlab::Auth::LDAP::Person).to receive(:disabled_via_active_directory?).and_return(false) + allow(Gitlab::Auth::Ldap::Person).to receive(:disabled_via_active_directory?).and_return(false) end it { is_expected.to be_truthy } @@ -135,8 +135,8 @@ 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_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance| + allow(Gitlab::Auth::Ldap::Config).to receive(:enabled?).and_return(true) + allow_next_instance_of(Gitlab::Auth::Ldap::Config) do |instance| allow(instance).to receive(:active_directory).and_return(false) end end diff --git a/spec/lib/gitlab/auth/ldap/adapter_spec.rb b/spec/lib/gitlab/auth/ldap/adapter_spec.rb index 54486913b72..34853acdd0f 100644 --- a/spec/lib/gitlab/auth/ldap/adapter_spec.rb +++ b/spec/lib/gitlab/auth/ldap/adapter_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Auth::LDAP::Adapter do +describe Gitlab::Auth::Ldap::Adapter do include LdapHelpers let(:ldap) { double(:ldap) } @@ -138,7 +138,7 @@ describe Gitlab::Auth::LDAP::Adapter do it 'as many times as MAX_SEARCH_RETRIES' do expect(ldap).to receive(:search).exactly(3).times - expect { subject }.to raise_error(Gitlab::Auth::LDAP::LDAPConnectionError) + expect { subject }.to raise_error(Gitlab::Auth::Ldap::LdapConnectionError) end context 'when no more retries' do @@ -147,11 +147,11 @@ describe Gitlab::Auth::LDAP::Adapter do end it 'raises the exception' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::LDAPConnectionError) + expect { subject }.to raise_error(Gitlab::Auth::Ldap::LdapConnectionError) end it 'logs the error' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::LDAPConnectionError) + expect { subject }.to raise_error(Gitlab::Auth::Ldap::LdapConnectionError) expect(Rails.logger).to have_received(:warn).with( "LDAP search raised exception Net::LDAP::Error: some error") end @@ -161,6 +161,6 @@ describe Gitlab::Auth::LDAP::Adapter do end def ldap_attributes - Gitlab::Auth::LDAP::Person.ldap_attributes(Gitlab::Auth::LDAP::Config.new('ldapmain')) + Gitlab::Auth::Ldap::Person.ldap_attributes(Gitlab::Auth::Ldap::Config.new('ldapmain')) end end diff --git a/spec/lib/gitlab/auth/ldap/auth_hash_spec.rb b/spec/lib/gitlab/auth/ldap/auth_hash_spec.rb index f1050b9f830..7bc92d0abea 100644 --- a/spec/lib/gitlab/auth/ldap/auth_hash_spec.rb +++ b/spec/lib/gitlab/auth/ldap/auth_hash_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Auth::LDAP::AuthHash do +describe Gitlab::Auth::Ldap::AuthHash do include LdapHelpers let(:auth_hash) do @@ -58,7 +58,7 @@ describe Gitlab::Auth::LDAP::AuthHash do end before do - allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance| + allow_next_instance_of(Gitlab::Auth::Ldap::Config) do |instance| allow(instance).to receive(:attributes).and_return(attributes) end end diff --git a/spec/lib/gitlab/auth/ldap/authentication_spec.rb b/spec/lib/gitlab/auth/ldap/authentication_spec.rb index ebaf8383ce5..1f8b1474539 100644 --- a/spec/lib/gitlab/auth/ldap/authentication_spec.rb +++ b/spec/lib/gitlab/auth/ldap/authentication_spec.rb @@ -2,15 +2,15 @@ require 'spec_helper' -describe Gitlab::Auth::LDAP::Authentication do +describe Gitlab::Auth::Ldap::Authentication do let(:dn) { 'uid=John Smith, ou=People, dc=example, dc=com' } - let(:user) { create(:omniauth_user, extern_uid: Gitlab::Auth::LDAP::Person.normalize_dn(dn)) } + let(:user) { create(:omniauth_user, extern_uid: Gitlab::Auth::Ldap::Person.normalize_dn(dn)) } let(:login) { 'john' } let(:password) { 'password' } describe 'login' do before do - allow(Gitlab::Auth::LDAP::Config).to receive(:enabled?).and_return(true) + allow(Gitlab::Auth::Ldap::Config).to receive(:enabled?).and_return(true) end it "finds the user if authentication is successful" do @@ -48,7 +48,7 @@ describe Gitlab::Auth::LDAP::Authentication do end it "fails if ldap is disabled" do - allow(Gitlab::Auth::LDAP::Config).to receive(:enabled?).and_return(false) + allow(Gitlab::Auth::Ldap::Config).to receive(:enabled?).and_return(false) expect(described_class.login(login, password)).to be_falsey end diff --git a/spec/lib/gitlab/auth/ldap/config_spec.rb b/spec/lib/gitlab/auth/ldap/config_spec.rb index e4a90d4018d..0967c45d36b 100644 --- a/spec/lib/gitlab/auth/ldap/config_spec.rb +++ b/spec/lib/gitlab/auth/ldap/config_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Auth::LDAP::Config do +describe Gitlab::Auth::Ldap::Config do include LdapHelpers let(:config) { described_class.new('ldapmain') } diff --git a/spec/lib/gitlab/auth/ldap/dn_spec.rb b/spec/lib/gitlab/auth/ldap/dn_spec.rb index 63656efba29..7aaffa52ae4 100644 --- a/spec/lib/gitlab/auth/ldap/dn_spec.rb +++ b/spec/lib/gitlab/auth/ldap/dn_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Auth::LDAP::DN do +describe Gitlab::Auth::Ldap::DN do using RSpec::Parameterized::TableSyntax describe '#normalize_value' do @@ -15,7 +15,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { 'John Smith,' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'DN string ended unexpectedly') + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, 'DN string ended unexpectedly') end end @@ -23,7 +23,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { '#aa aa' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "Expected the end of an attribute value, but got \"a\"") + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, "Expected the end of an attribute value, but got \"a\"") end end @@ -31,7 +31,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { '#aaXaaa' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "Expected the first character of a hex pair, but got \"X\"") + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, "Expected the first character of a hex pair, but got \"X\"") end end @@ -39,7 +39,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { '#aaaYaa' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "Expected the second character of a hex pair, but got \"Y\"") + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, "Expected the second character of a hex pair, but got \"Y\"") end end @@ -47,7 +47,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { '"Sebasti\\cX\\a1n"' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "Expected the second character of a hex pair inside a double quoted value, but got \"X\"") + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, "Expected the second character of a hex pair inside a double quoted value, but got \"X\"") end end @@ -55,7 +55,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { '"James' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'DN string ended unexpectedly') + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, 'DN string ended unexpectedly') end end @@ -63,7 +63,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { 'J\ames' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'Invalid escaped hex code "\am"') + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, 'Invalid escaped hex code "\am"') end end @@ -71,7 +71,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { 'foo\\' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'DN string ended unexpectedly') + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, 'DN string ended unexpectedly') end end end @@ -88,7 +88,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { 'uid=john smith+telephonenumber=+1 555-555-5555,ou=people,dc=example,dc=com' } it 'raises UnsupportedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::UnsupportedError) + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::UnsupportedError) end end @@ -97,7 +97,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { 'uid = John Smith + telephoneNumber = + 1 555-555-5555 , ou = People,dc=example,dc=com' } it 'raises UnsupportedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::UnsupportedError) + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::UnsupportedError) end end @@ -105,7 +105,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { 'uid = John Smith + telephoneNumber = +1 555-555-5555 , ou = People,dc=example,dc=com' } it 'raises UnsupportedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::UnsupportedError) + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::UnsupportedError) end end end @@ -117,7 +117,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { 'uid=John Smith,' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'DN string ended unexpectedly') + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, 'DN string ended unexpectedly') end end @@ -125,7 +125,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { '0.9.2342.19200300.100.1.25=#aa aa' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "Expected the end of an attribute value, but got \"a\"") + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, "Expected the end of an attribute value, but got \"a\"") end end @@ -133,7 +133,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { '0.9.2342.19200300.100.1.25=#aaXaaa' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "Expected the first character of a hex pair, but got \"X\"") + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, "Expected the first character of a hex pair, but got \"X\"") end end @@ -141,7 +141,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { '0.9.2342.19200300.100.1.25=#aaaYaa' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "Expected the second character of a hex pair, but got \"Y\"") + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, "Expected the second character of a hex pair, but got \"Y\"") end end @@ -149,7 +149,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { 'uid="Sebasti\\cX\\a1n"' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "Expected the second character of a hex pair inside a double quoted value, but got \"X\"") + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, "Expected the second character of a hex pair inside a double quoted value, but got \"X\"") end end @@ -157,7 +157,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { 'John' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'DN string ended unexpectedly') + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, 'DN string ended unexpectedly') end end @@ -165,7 +165,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { 'cn="James' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'DN string ended unexpectedly') + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, 'DN string ended unexpectedly') end end @@ -173,7 +173,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { 'cn=J\ames' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'Invalid escaped hex code "\am"') + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, 'Invalid escaped hex code "\am"') end end @@ -181,7 +181,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { 'cn=\\' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'DN string ended unexpectedly') + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, 'DN string ended unexpectedly') end end @@ -189,7 +189,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { '1.2.d=Value' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'Unrecognized RDN OID attribute type name character "d"') + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, 'Unrecognized RDN OID attribute type name character "d"') end end @@ -197,7 +197,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { 'd1.2=Value' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'Unrecognized RDN attribute type name character "."') + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, 'Unrecognized RDN attribute type name character "."') end end @@ -205,7 +205,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { ' -uid=John Smith' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'Unrecognized first character of an RDN attribute type name "-"') + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, 'Unrecognized first character of an RDN attribute type name "-"') end end @@ -213,7 +213,7 @@ describe Gitlab::Auth::LDAP::DN do let(:given) { 'uid\\=john' } it 'raises MalformedError' do - expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'Unrecognized RDN attribute type name character "\\"') + expect { subject }.to raise_error(Gitlab::Auth::Ldap::DN::MalformedError, 'Unrecognized RDN attribute type name character "\\"') end end end diff --git a/spec/lib/gitlab/auth/ldap/person_spec.rb b/spec/lib/gitlab/auth/ldap/person_spec.rb index 985732e69f9..e90917cfce1 100644 --- a/spec/lib/gitlab/auth/ldap/person_spec.rb +++ b/spec/lib/gitlab/auth/ldap/person_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Auth::LDAP::Person do +describe Gitlab::Auth::Ldap::Person do include LdapHelpers let(:entry) { ldap_user_entry('john.doe') } @@ -61,7 +61,7 @@ describe Gitlab::Auth::LDAP::Person do } } ) - config = Gitlab::Auth::LDAP::Config.new('ldapmain') + config = Gitlab::Auth::Ldap::Config.new('ldapmain') ldap_attributes = described_class.ldap_attributes(config) expect(ldap_attributes).to match_array(%w(dn uid cn mail memberof)) diff --git a/spec/lib/gitlab/auth/ldap/user_spec.rb b/spec/lib/gitlab/auth/ldap/user_spec.rb index 071d687b2bf..867633e54df 100644 --- a/spec/lib/gitlab/auth/ldap/user_spec.rb +++ b/spec/lib/gitlab/auth/ldap/user_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Auth::LDAP::User do +describe Gitlab::Auth::Ldap::User do include LdapHelpers let(:ldap_user) { described_class.new(auth_hash) } |