Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-11-30 07:50:46 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-11-30 07:50:46 +0300
commite6572d41b847c839ce49bc022a8cd1b99216798b (patch)
tree419eeffb09aafcd9d5a82e43c823b8cfbf88963e /spec/models/hooks/web_hook_spec.rb
parent1f6654659564013b8aa4f3572158cb63d3a519c1 (diff)
Add latest changes from gitlab-org/security/gitlab@15-6-stable-ee
Diffstat (limited to 'spec/models/hooks/web_hook_spec.rb')
-rw-r--r--spec/models/hooks/web_hook_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/models/hooks/web_hook_spec.rb b/spec/models/hooks/web_hook_spec.rb
index db854670cc3..9b55db15f3b 100644
--- a/spec/models/hooks/web_hook_spec.rb
+++ b/spec/models/hooks/web_hook_spec.rb
@@ -195,6 +195,36 @@ RSpec.describe WebHook do
end
end
+ describe 'before_validation :reset_token' do
+ subject(:hook) { build_stubbed(:project_hook, :token, project: project) }
+
+ it 'resets token if url changed' do
+ hook.url = 'https://webhook.example.com/new-hook'
+
+ expect(hook).to be_valid
+ expect(hook.token).to be_nil
+ end
+
+ it 'does not reset token if new url is set together with the same token' do
+ hook.url = 'https://webhook.example.com/new-hook'
+ current_token = hook.token
+ hook.token = current_token
+
+ expect(hook).to be_valid
+ expect(hook.token).to eq(current_token)
+ expect(hook.url).to eq('https://webhook.example.com/new-hook')
+ end
+
+ it 'does not reset token if new url is set together with a new token' do
+ hook.url = 'https://webhook.example.com/new-hook'
+ hook.token = 'token'
+
+ expect(hook).to be_valid
+ expect(hook.token).to eq('token')
+ expect(hook.url).to eq('https://webhook.example.com/new-hook')
+ end
+ end
+
it "only consider these branch filter strategies are valid" do
expected_valid_types = %w[all_branches regex wildcard]
expect(described_class.branch_filter_strategies.keys).to contain_exactly(*expected_valid_types)