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>2023-05-23 21:08:27 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-23 21:08:27 +0300
commit3ca896b640def57a58485def308748b2fccbd0bb (patch)
tree7aead6484759d2a473bf9776aa7d87632f1e105f /spec/support/helpers/content_security_policy_helpers.rb
parentabdb550f6937ce69ec38954f24ef221d07637438 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/helpers/content_security_policy_helpers.rb')
-rw-r--r--spec/support/helpers/content_security_policy_helpers.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/support/helpers/content_security_policy_helpers.rb b/spec/support/helpers/content_security_policy_helpers.rb
index 7e3de9fd219..50a1bb62bc5 100644
--- a/spec/support/helpers/content_security_policy_helpers.rb
+++ b/spec/support/helpers/content_security_policy_helpers.rb
@@ -17,4 +17,22 @@ any_time: false)
end
end
end
+
+ # Finds the given csp directive values as an array
+ #
+ # Example:
+ # ```
+ # find_csp_directive('connect-src')
+ # ```
+ def find_csp_directive(key)
+ csp = response.headers['Content-Security-Policy']
+
+ # Transform "default-src foo bar; connect-src foo bar; script-src ..."
+ # into array of values for a single directive based on the given key
+ csp.split(';')
+ .map(&:strip)
+ .find { |entry| entry.starts_with?(key) }
+ .split(' ')
+ .drop(1)
+ end
end