diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
commit | 5afcbe03ead9ada87621888a31a62652b10a7e4f (patch) | |
tree | 9918b67a0d0f0bafa6542e839a8be37adf73102d /spec/models/hooks/web_hook_log_spec.rb | |
parent | c97c0201564848c1f53226fe19d71fdcc472f7d0 (diff) |
Add latest changes from gitlab-org/gitlab@16-4-stable-eev16.4.0-rc42
Diffstat (limited to 'spec/models/hooks/web_hook_log_spec.rb')
-rw-r--r-- | spec/models/hooks/web_hook_log_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/models/hooks/web_hook_log_spec.rb b/spec/models/hooks/web_hook_log_spec.rb index 4b88b3b3e65..e9a2635bf28 100644 --- a/spec/models/hooks/web_hook_log_spec.rb +++ b/spec/models/hooks/web_hook_log_spec.rb @@ -46,6 +46,20 @@ RSpec.describe WebHookLog, feature_category: :webhooks do end end + context 'with basic auth credentials and masked components' do + let(:web_hook_log) { build(:web_hook_log, web_hook: hook, url: 'http://test:123@{domain}.com:{port}') } + + subject { web_hook_log.save! } + + it { is_expected.to eq(true) } + + it 'obfuscates the basic auth credentials' do + subject + + expect(web_hook_log.url).to eq('http://*****:*****@{domain}.com:{port}') + end + end + context "with users' emails" do let(:author) { build(:user) } let(:user) { build(:user) } @@ -235,4 +249,28 @@ RSpec.describe WebHookLog, feature_category: :webhooks do it { expect(web_hook_log.request_headers).to eq(expected_headers) } end end + + describe '#url_current?' do + let(:url) { 'example@gitlab.com' } + + let(:hook) { build(:project_hook, url: url) } + let(:web_hook_log) do + build( + :web_hook_log, + web_hook: hook, + interpolated_url: hook.url, + url_hash: Gitlab::CryptoHelper.sha256('example@gitlab.com') + ) + end + + context 'with matching url' do + it { expect(web_hook_log.url_current?).to be_truthy } + end + + context 'with different url' do + let(:url) { 'example@gitlab2.com' } + + it { expect(web_hook_log.url_current?).to be_falsey } + end + end end |