diff options
author | Stan Hu <stanhu@gmail.com> | 2018-02-13 19:08:47 +0000 |
---|---|---|
committer | Mark Fletcher <mark@gitlab.com> | 2018-02-14 11:50:01 +0000 |
commit | ed9f6c845911eacba1b74f61df319eef76e3b701 (patch) | |
tree | c71f07751b0c65c1deb481e71bff475ee93cbf63 | |
parent | 6f92957248ee6a54b4eabca06ded6685f8511dd2 (diff) | |
download | gitlab-ce-ed9f6c845911eacba1b74f61df319eef76e3b701.tar.gz |
Merge branch 'remove_ldap_person_validation' into 'master'
Remove problematic LDAP::Person validation for new strategy
Closes #42412 and #42359
See merge request gitlab-org/gitlab-ce!16727
-rw-r--r-- | changelogs/unreleased/remove_ldap_person_validation.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/ldap/person.rb | 15 | ||||
-rw-r--r-- | spec/lib/gitlab/ldap/person_spec.rb | 9 |
3 files changed, 5 insertions, 24 deletions
diff --git a/changelogs/unreleased/remove_ldap_person_validation.yml b/changelogs/unreleased/remove_ldap_person_validation.yml new file mode 100644 index 00000000000..da7f0a52886 --- /dev/null +++ b/changelogs/unreleased/remove_ldap_person_validation.yml @@ -0,0 +1,5 @@ +--- +title: LDAP Person no longer throws exception on invalid entry +merge_request: +author: +type: fixed diff --git a/lib/gitlab/ldap/person.rb b/lib/gitlab/ldap/person.rb index b91757c2a4b..c59df556247 100644 --- a/lib/gitlab/ldap/person.rb +++ b/lib/gitlab/ldap/person.rb @@ -63,8 +63,6 @@ module Gitlab Rails.logger.debug { "Instantiating #{self.class.name} with LDIF:\n#{entry.to_ldif}" } @entry = entry @provider = provider - - validate_entry end def name @@ -117,19 +115,6 @@ module Gitlab entry.public_send(selected_attr) # rubocop:disable GitlabSecurity/PublicSend end - - def validate_entry - allowed_attrs = self.class.ldap_attributes(config).map(&:downcase) - - # Net::LDAP::Entry transforms keys to symbols. Change to strings to compare. - entry_attrs = entry.attribute_names.map { |n| n.to_s.downcase } - invalid_attrs = entry_attrs - allowed_attrs - - if invalid_attrs.any? - raise InvalidEntryError, - "#{self.class.name} initialized with Net::LDAP::Entry containing invalid attributes(s): #{invalid_attrs}" - end - end end end end diff --git a/spec/lib/gitlab/ldap/person_spec.rb b/spec/lib/gitlab/ldap/person_spec.rb index b54d4000b53..05e1e394bb1 100644 --- a/spec/lib/gitlab/ldap/person_spec.rb +++ b/spec/lib/gitlab/ldap/person_spec.rb @@ -66,15 +66,6 @@ describe Gitlab::LDAP::Person do end end - describe '.validate_entry' do - it 'raises InvalidEntryError' do - entry['foo'] = 'bar' - - expect { described_class.new(entry, 'ldapmain') } - .to raise_error(Gitlab::LDAP::Person::InvalidEntryError) - end - end - describe '#name' do it 'uses the configured name attribute and handles values as an array' do name = 'John Doe' |