Commit df8c9ac3 authored by Nick Thomas's avatar Nick Thomas

Fix one EE spec for the new Gitlab::Shell interface to batch_add_keys

parent 22ef5a09
......@@ -32,10 +32,8 @@ module Gitlab
def batch_add_keys_in_db_starting_from(start_id)
Rails.logger.info("Adding all keys starting from ID: #{start_id}")
gitlab_shell.batch_add_keys do |adder|
Key.find_each(start: start_id, batch_size: 1000) do |key|
adder.add_key(key.shell_id, key.key)
end
::Key.find_in_batches(start: start_id, batch_size: 1000) do |keys|
gitlab_shell.batch_add_keys(keys)
end
end
end
......
......@@ -80,15 +80,19 @@ describe Gitlab::BackgroundMigration::UpdateAuthorizedKeysFileSince do
background_migration.batch_add_keys_in_db_starting_from(@keys[3].id)
file = File.read(Rails.root.join('tmp/tests/.ssh/authorized_keys'))
file = File.read(Rails.root.join(Gitlab.config.gitlab_shell.authorized_keys_file))
expect(file.scan(/ssh-rsa/).count).to eq(7)
expect(file).not_to include(Gitlab::Shell.strip_key(@keys[0].key))
expect(file).not_to include(Gitlab::Shell.strip_key(@keys[2].key))
expect(file).to include(Gitlab::Shell.strip_key(@keys[3].key))
expect(file).to include(Gitlab::Shell.strip_key(@keys[9].key))
expect(file).not_to include(strip_key(@keys[0].key))
expect(file).not_to include(strip_key(@keys[2].key))
expect(file).to include(strip_key(@keys[3].key))
expect(file).to include(strip_key(@keys[9].key))
end
end
def strip_key(key)
key.split(/[ ]+/)[0, 2].join(' ')
end
end
end
# rubocop:enable RSpec/FactoriesInMigrationSpecs
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