diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-23 22:31:27 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-23 22:31:27 +0300 |
commit | fed154841026699d3580df7b3bd48302f2441c63 (patch) | |
tree | 6592c2420748bac1c2364ab6bf312bef65ebadc5 | |
parent | 3f242b6bb267fea02de29c67cc5cf0384020662e (diff) |
Add latest changes from gitlab-org/gitlab@12-9-stable-ee
-rw-r--r-- | app/workers/authorized_keys_worker.rb | 10 | ||||
-rw-r--r-- | app/workers/gitlab_shell_worker.rb | 2 | ||||
-rw-r--r-- | changelogs/unreleased/212178-fix-authorized-keys-worker.yml | 5 | ||||
-rw-r--r-- | spec/workers/authorized_keys_worker_spec.rb | 12 | ||||
-rw-r--r-- | spec/workers/gitlab_shell_worker_spec.rb | 6 |
5 files changed, 22 insertions, 13 deletions
diff --git a/app/workers/authorized_keys_worker.rb b/app/workers/authorized_keys_worker.rb index b2333033e56..eabfd89ba60 100644 --- a/app/workers/authorized_keys_worker.rb +++ b/app/workers/authorized_keys_worker.rb @@ -3,7 +3,7 @@ class AuthorizedKeysWorker include ApplicationWorker - PERMITTED_ACTIONS = [:add_key, :remove_key].freeze + PERMITTED_ACTIONS = %w[add_key remove_key].freeze feature_category :source_code_management urgency :high @@ -13,11 +13,13 @@ class AuthorizedKeysWorker def perform(action, *args) return unless Gitlab::CurrentSettings.authorized_keys_enabled? - case action - when :add_key + case action.to_s + when 'add_key' authorized_keys.add_key(*args) - when :remove_key + when 'remove_key' authorized_keys.remove_key(*args) + else + raise "Unknown action: #{action.inspect}" end end diff --git a/app/workers/gitlab_shell_worker.rb b/app/workers/gitlab_shell_worker.rb index 0db794793d4..b104d3c681e 100644 --- a/app/workers/gitlab_shell_worker.rb +++ b/app/workers/gitlab_shell_worker.rb @@ -13,7 +13,7 @@ class GitlabShellWorker # rubocop:disable Scalability/IdempotentWorker # enqueued in the previous release, so handle them here. # # See https://gitlab.com/gitlab-org/gitlab/-/issues/25095 for more details - if AuthorizedKeysWorker::PERMITTED_ACTIONS.include?(action) + if AuthorizedKeysWorker::PERMITTED_ACTIONS.include?(action.to_s) AuthorizedKeysWorker.new.perform(action, *arg) return diff --git a/changelogs/unreleased/212178-fix-authorized-keys-worker.yml b/changelogs/unreleased/212178-fix-authorized-keys-worker.yml new file mode 100644 index 00000000000..a95f2e0e71a --- /dev/null +++ b/changelogs/unreleased/212178-fix-authorized-keys-worker.yml @@ -0,0 +1,5 @@ +--- +title: Fix updating the authorized_keys file +merge_request: 27798 +author: +type: fixed diff --git a/spec/workers/authorized_keys_worker_spec.rb b/spec/workers/authorized_keys_worker_spec.rb index 2aaa6fb2ddf..4f1dde0bfc0 100644 --- a/spec/workers/authorized_keys_worker_spec.rb +++ b/spec/workers/authorized_keys_worker_spec.rb @@ -17,7 +17,7 @@ describe AuthorizedKeysWorker do expect(instance).to receive(:add_key).with('foo', 'bar') end - worker.perform(:add_key, 'foo', 'bar') + worker.perform('add_key', 'foo', 'bar') end end @@ -27,15 +27,17 @@ describe AuthorizedKeysWorker do expect(instance).to receive(:remove_key).with('foo', 'bar') end - worker.perform(:remove_key, 'foo', 'bar') + worker.perform('remove_key', 'foo', 'bar') end end describe 'all other commands' do - it 'does nothing' do + it 'raises an error' do expect(Gitlab::AuthorizedKeys).not_to receive(:new) - worker.perform(:foo, 'bar', 'baz') + expect do + worker.perform('foo', 'bar', 'baz') + end.to raise_error('Unknown action: "foo"') end end end @@ -48,7 +50,7 @@ describe AuthorizedKeysWorker do it 'does nothing' do expect(Gitlab::AuthorizedKeys).not_to receive(:new) - worker.perform(:add_key, 'foo', 'bar') + worker.perform('add_key', 'foo', 'bar') end end end diff --git a/spec/workers/gitlab_shell_worker_spec.rb b/spec/workers/gitlab_shell_worker_spec.rb index f5884e5e8f8..0e63f48d3e8 100644 --- a/spec/workers/gitlab_shell_worker_spec.rb +++ b/spec/workers/gitlab_shell_worker_spec.rb @@ -12,7 +12,7 @@ describe GitlabShellWorker do expect(instance).to receive(:add_key).with('foo', 'bar') end - worker.perform(:add_key, 'foo', 'bar') + worker.perform('add_key', 'foo', 'bar') end end @@ -22,7 +22,7 @@ describe GitlabShellWorker do expect(instance).to receive(:remove_key).with('foo', 'bar') end - worker.perform(:remove_key, 'foo', 'bar') + worker.perform('remove_key', 'foo', 'bar') end end @@ -32,7 +32,7 @@ describe GitlabShellWorker do expect(instance).to receive(:foo).with('bar', 'baz') end - worker.perform(:foo, 'bar', 'baz') + worker.perform('foo', 'bar', 'baz') end end end |