diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /spec/workers/gitlab_shell_worker_spec.rb | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/workers/gitlab_shell_worker_spec.rb')
-rw-r--r-- | spec/workers/gitlab_shell_worker_spec.rb | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/spec/workers/gitlab_shell_worker_spec.rb b/spec/workers/gitlab_shell_worker_spec.rb index c46ef87333a..a5419291d35 100644 --- a/spec/workers/gitlab_shell_worker_spec.rb +++ b/spec/workers/gitlab_shell_worker_spec.rb @@ -2,37 +2,45 @@ require 'spec_helper' -RSpec.describe GitlabShellWorker do - let(:worker) { described_class.new } - +RSpec.describe GitlabShellWorker, :sidekiq_inline do describe '#perform' do - describe '#add_key' do - it 'delegates to Gitlab::AuthorizedKeys' do - expect_next_instance_of(Gitlab::AuthorizedKeys) do |instance| - expect(instance).to receive(:add_key).with('foo', 'bar') + Gitlab::Shell::PERMITTED_ACTIONS.each do |action| + describe "with the #{action} action" do + it 'forwards the message to Gitlab::Shell' do + expect_next_instance_of(Gitlab::Shell) do |instance| + expect(instance).to respond_to(action) + expect(instance).to receive(action).with('foo', 'bar') + end + + described_class.perform_async(action, 'foo', 'bar') end - - worker.perform('add_key', 'foo', 'bar') end end - describe '#remove_key' do - it 'delegates to Gitlab::AuthorizedKeys' do - expect_next_instance_of(Gitlab::AuthorizedKeys) do |instance| - expect(instance).to receive(:remove_key).with('foo', 'bar') + describe 'all other commands' do + context 'when verify_gitlab_shell_worker_method_names is enabled' do + it 'raises ArgumentError' do + allow_next_instance_of(described_class) do |job_instance| + expect(job_instance).not_to receive(:gitlab_shell) + end + + expect { described_class.perform_async('foo', 'bar', 'baz') } + .to raise_error(ArgumentError, 'foo not allowed for GitlabShellWorker') end - - worker.perform('remove_key', 'foo', 'bar') end - end - describe 'all other commands' do - it 'delegates them to Gitlab::Shell' do - expect_next_instance_of(Gitlab::Shell) do |instance| - expect(instance).to receive(:foo).with('bar', 'baz') + context 'when verify_gitlab_shell_worker_method_names is disabled' do + before do + stub_feature_flags(verify_gitlab_shell_worker_method_names: false) end - worker.perform('foo', 'bar', 'baz') + it 'forwards the message to Gitlab::Shell' do + expect_next_instance_of(Gitlab::Shell) do |instance| + expect(instance).to receive('foo').with('bar', 'baz') + end + + described_class.perform_async('foo', 'bar', 'baz') + end end end end |