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:
authorGeorge Koltsov <gkoltsov@gitlab.com>2019-07-30 13:53:23 +0300
committerGeorge Koltsov <gkoltsov@gitlab.com>2019-08-02 17:39:18 +0300
commit8abf920d1f55e9117dd3b05d81ee9ebf7721f2bd (patch)
treebcdc229c8b9819f0ff6f5dc99095fe40bbeff51c /app/validators
parentac7661924eebd6eb0fa72848e2b4bf4391ebf113 (diff)
Refactor SystemHookUrlValidator and specs
Simplify SystemHookUrlValidator to inherit from PublicUrlValidator Refactor specs to move out shared examples to be used in both system hooks and public url validators.
Diffstat (limited to 'app/validators')
-rw-r--r--app/validators/system_hook_url_validator.rb16
1 files changed, 2 insertions, 14 deletions
diff --git a/app/validators/system_hook_url_validator.rb b/app/validators/system_hook_url_validator.rb
index e482828685d..f4253006dad 100644
--- a/app/validators/system_hook_url_validator.rb
+++ b/app/validators/system_hook_url_validator.rb
@@ -7,23 +7,11 @@
# ApplicationSetting.allow_local_requests_from_system_hooks
#
# Example:
-#
# class SystemHook < WebHook
-# validates :url, system_hook_url: { allow_localhost: true, allow_local_network: true }
+# validates :url, system_hook_url: true
# end
#
-class SystemHookUrlValidator < AddressableUrlValidator
- DEFAULT_OPTIONS = {
- allow_localhost: false,
- allow_local_network: false
- }.freeze
-
- def initialize(options)
- options.reverse_merge!(DEFAULT_OPTIONS)
-
- super(options)
- end
-
+class SystemHookUrlValidator < PublicUrlValidator
def self.allow_setting_local_requests?
ApplicationSetting.current&.allow_local_requests_from_system_hooks?
end