Commit 0e91a796 authored by Subashis's avatar Subashis

Move reactive cache methods to base class

- Move methods to base class
- Change factory to better naming sequence

Changelog: other
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/82442
EE: true
parent 978a8612
......@@ -9,6 +9,8 @@ module Security
self.reactive_cache_refresh_interval = 1.minute
self.reactive_cache_lifetime = 10.minutes
self.reactive_cache_work_type = :external_dependency
self.reactive_cache_key = ->(finder) { finder.full_url }
self.reactive_cache_worker_finder = ->(id, *args) { from_cache(id) }
def initialize(provider, identifier)
@provider = provider
......
......@@ -3,9 +3,6 @@
module Security
module TrainingProviders
class KontraUrlFinder < BaseUrlFinder
self.reactive_cache_key = ->(finder) { finder.full_url }
self.reactive_cache_worker_finder = ->(id, *args) { from_cache(id) }
def calculate_reactive_cache(full_url)
bearer_token = "sbdMsxcgW2Xs75Q2uHc9FhUCZSEV3fSg" # To improve the authentication/integration https://gitlab.com/gitlab-org/gitlab/-/issues/354070
response = Gitlab::HTTP.try_get(
......
......@@ -3,9 +3,6 @@
module Security
module TrainingProviders
class SecureCodeWarriorUrlFinder < BaseUrlFinder
self.reactive_cache_key = ->(finder) { finder.full_url }
self.reactive_cache_worker_finder = ->(id, *args) { from_cache(id) }
def calculate_reactive_cache(full_url)
response = Gitlab::HTTP.try_get(full_url)
{ url: response.parsed_response["url"] } if response
......
......@@ -2,7 +2,7 @@
FactoryBot.define do
factory :security_training_provider, class: 'Security::TrainingProvider' do
sequence(:name) { |n| "acme #{n}" }
sequence(:name) { |n| "Training Provider ##{n}" }
url { 'example.com' }
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment