diff options
Diffstat (limited to 'spec/services/web_hook_service_spec.rb')
-rw-r--r-- | spec/services/web_hook_service_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/services/web_hook_service_spec.rb b/spec/services/web_hook_service_spec.rb index fb7d487b29b..259f5156d42 100644 --- a/spec/services/web_hook_service_spec.rb +++ b/spec/services/web_hook_service_spec.rb @@ -295,6 +295,20 @@ RSpec.describe WebHookService, :request_store, :clean_gitlab_redis_shared_state, expect(WebMock).not_to have_requested(:post, stubbed_hostname(project_hook.url)) end + context 'when silent mode is enabled' do + before do + stub_application_setting(silent_mode_enabled: true) + end + + it 'blocks and logs an error' do + stub_full_request(project_hook.url, method: :post) + + expect(Gitlab::AuthLogger).to receive(:error).with(include(message: 'GitLab is in silent mode')) + expect(service_instance.execute).to be_error + expect(WebMock).not_to have_requested(:post, stubbed_hostname(project_hook.url)) + end + end + it 'handles exceptions' do exceptions = Gitlab::HTTP::HTTP_ERRORS + [ Gitlab::Json::LimitedEncoder::LimitExceeded, URI::InvalidURIError @@ -733,6 +747,19 @@ RSpec.describe WebHookService, :request_store, :clean_gitlab_redis_shared_state, end end + context 'when silent mode is enabled' do + before do + stub_application_setting(silent_mode_enabled: true) + end + + it 'does not queue a worker and logs an error' do + expect(WebHookWorker).not_to receive(:perform_async) + expect(Gitlab::AuthLogger).to receive(:error).with(include(message: 'GitLab is in silent mode')) + + service_instance.async_execute + end + end + context 'when hook has custom context attributes' do it 'includes the attributes in the worker context' do expect(WebHookWorker).to receive(:perform_async) do |