diff options
author | Francisco Javier López <fjlopez@gitlab.com> | 2017-12-21 14:31:15 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-12-21 14:31:15 +0000 |
commit | 8c6b5baba1d784b1615d023c63fb4531713ef8db (patch) | |
tree | 5a7ebfc046dc8a006db0520350e3378f00fa2bd2 /spec/models/identity_spec.rb | |
parent | 3ee5fd156e3465a1e1c04b2b321c62b577496ee8 (diff) | |
download | gitlab-ce-8c6b5baba1d784b1615d023c63fb4531713ef8db.tar.gz |
LDAP extern_uids are not normalized when updated via API
Diffstat (limited to 'spec/models/identity_spec.rb')
-rw-r--r-- | spec/models/identity_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/models/identity_spec.rb b/spec/models/identity_spec.rb index a45a6088831..7c66c98231b 100644 --- a/spec/models/identity_spec.rb +++ b/spec/models/identity_spec.rb @@ -44,4 +44,31 @@ describe Identity do end end end + + context 'callbacks' do + context 'before_save' do + describe 'normalizes extern uid' do + let!(:ldap_identity) { create(:identity, provider: 'ldapmain', extern_uid: 'uid=john smith,ou=people,dc=example,dc=com') } + + it 'if extern_uid changes' do + expect(ldap_identity).not_to receive(:ensure_normalized_extern_uid) + ldap_identity.save + end + + it 'if current_uid is nil' do + expect(ldap_identity).to receive(:ensure_normalized_extern_uid) + + ldap_identity.update(extern_uid: nil) + + expect(ldap_identity.extern_uid).to be_nil + end + + it 'if extern_uid changed and not nil' do + ldap_identity.update(extern_uid: 'uid=john1,ou=PEOPLE,dc=example,dc=com') + + expect(ldap_identity.extern_uid).to eq 'uid=john1,ou=people,dc=example,dc=com' + end + end + end + end end |