Rename ssh_sync_key to old convention to prevent confusion

parent f488fd59
......@@ -79,7 +79,7 @@ module Gitlab
(ldap_user.ssh_keys - user.keys.ldap.pluck(:key)).each do |key|
Rails.logger.info "#{self.class.name}: adding LDAP SSH key #{key.inspect} to #{user.name} (#{user.id})"
new_key = LDAPKey.new(title: "LDAP - #{ldap_config.ssh_sync_key}", key: key)
new_key = LDAPKey.new(title: "LDAP - #{ldap_config.sync_ssh_keys}", key: key)
new_key.user = user
unless new_key.save
Rails.logger.error "#{self.class.name}: failed to add LDAP SSH key #{key.inspect} to #{user.name} (#{user.id})\n"\
......
......@@ -24,10 +24,11 @@ module Gitlab
end
def sync_ssh_keys?
ssh_sync_key.present?
sync_ssh_keys.present?
end
def ssh_sync_key
# The LDAP attribute in which the ssh keys are stored
def sync_ssh_keys
options['sync_ssh_keys']
end
......
......@@ -47,8 +47,8 @@ module Gitlab
end
def ssh_keys
if config.sync_ssh_keys? && entry.respond_to?(config.ssh_sync_key)
entry[config.ssh_sync_key.to_sym]
if config.sync_ssh_keys? && entry.respond_to?(config.sync_ssh_keys)
entry[config.sync_ssh_keys.to_sym]
else
[]
end
......
......@@ -70,7 +70,7 @@ describe Gitlab::LDAP::Access do
Net::LDAP::Entry.from_single_ldif_string("dn: cn=foo, dc=bar, dc=com\n#{ssh_key_attribute_name}: #{ssh_key}") }
before do
Gitlab::LDAP::Config.any_instance.stub(ssh_sync_key: ssh_key_attribute_name)
Gitlab::LDAP::Config.any_instance.stub(sync_ssh_keys: ssh_key_attribute_name)
access.stub sync_ssh_keys?: true
end
......@@ -87,7 +87,7 @@ describe Gitlab::LDAP::Access do
access.update_ssh_keys
expect(user.keys.last.title).to match(/LDAP/)
expect(user.keys.last.title).to match(/#{access.ldap_config.ssh_sync_key}/)
expect(user.keys.last.title).to match(/#{access.ldap_config.sync_ssh_keys}/)
end
it "should not add a SSH key if it is invalid" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment