summaryrefslogtreecommitdiff
path: root/spec/models/hooks/web_hook_log_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-28 18:09:03 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-28 18:09:03 +0000
commitb420660ef1369fec4d09b7bf5e961d81980974e5 (patch)
treef096fdd1bd3b4898e1b2ca80957ce68c200c09f0 /spec/models/hooks/web_hook_log_spec.rb
parentb8026fd558e7ec154c626208a33c1485aec8f4ea (diff)
downloadgitlab-ce-b420660ef1369fec4d09b7bf5e961d81980974e5.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/hooks/web_hook_log_spec.rb')
-rw-r--r--spec/models/hooks/web_hook_log_spec.rb35
1 files changed, 28 insertions, 7 deletions
diff --git a/spec/models/hooks/web_hook_log_spec.rb b/spec/models/hooks/web_hook_log_spec.rb
index e1fea3318f6..8ff8a1c3865 100644
--- a/spec/models/hooks/web_hook_log_spec.rb
+++ b/spec/models/hooks/web_hook_log_spec.rb
@@ -30,15 +30,12 @@ RSpec.describe WebHookLog do
end
describe '#save' do
- let(:web_hook_log) { build(:web_hook_log, url: url) }
- let(:url) { 'http://example.com' }
-
- subject { web_hook_log.save! }
+ context 'with basic auth credentials' do
+ let(:web_hook_log) { build(:web_hook_log, url: 'http://test:123@example.com') }
- it { is_expected.to eq(true) }
+ subject { web_hook_log.save! }
- context 'with basic auth credentials' do
- let(:url) { 'http://test:123@example.com'}
+ it { is_expected.to eq(true) }
it 'obfuscates the basic auth credentials' do
subject
@@ -46,6 +43,30 @@ RSpec.describe WebHookLog do
expect(web_hook_log.url).to eq('http://*****:*****@example.com')
end
end
+
+ context 'with author email' do
+ let(:author) { create(:user) }
+ let(:web_hook_log) { create(:web_hook_log, request_data: data) }
+ let(:data) do
+ {
+ commit: {
+ author: {
+ name: author.name,
+ email: author.email
+ }
+ }
+ }.deep_stringify_keys
+ end
+
+ it "redacts author's email" do
+ expect(web_hook_log.request_data['commit']).to match a_hash_including(
+ 'author' => {
+ 'name' => author.name,
+ 'email' => _('[REDACTED]')
+ }
+ )
+ end
+ end
end
describe '.delete_batch_for' do