Extract EE specific files/lines for spec/support/helpers
We have the following files containing EE specific code. We should move them to ee/
spec/support/helpers/javascript_fixtures_helpers.rb
diff --git a/spec/support/helpers/javascript_fixtures_helpers.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/support/helpers/javascript_fixtures_helpers.rb
index 89c5ec7a718..953cfb11907 100644
--- a/spec/support/helpers/javascript_fixtures_helpers.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/support/helpers/javascript_fixtures_helpers.rb
@@ -4,7 +4,7 @@ require 'fileutils'
module JavaScriptFixturesHelpers
include Gitlab::Popen
- FIXTURE_PATH = 'spec/javascripts/fixtures'.freeze
+ FIXTURE_PATHS = %w[spec/javascripts/fixtures ee/spec/javascripts/fixtures].freeze
def self.included(base)
base.around do |example|
@@ -15,26 +15,30 @@ module JavaScriptFixturesHelpers
# Public: Removes all fixture files from given directory
#
- # directory_name - directory of the fixtures (relative to FIXTURE_PATH)
+ # directory_name - directory of the fixtures (relative to FIXTURE_PATHS)
#
def clean_frontend_fixtures(directory_name)
- directory_name = File.expand_path(directory_name, FIXTURE_PATH)
- Dir[File.expand_path('*.html.raw', directory_name)].each do |file_name|
- FileUtils.rm(file_name)
+ FIXTURE_PATHS.each do |fixture_path|
+ directory_name = File.expand_path(directory_name, fixture_path)
+ Dir[File.expand_path('*.html.raw', directory_name)].each do |file_name|
+ FileUtils.rm(file_name)
+ end
end
end
# Public: Store a response object as fixture file
#
# response - string or response object to store
- # fixture_file_name - file name to store the fixture in (relative to FIXTURE_PATH)
+ # fixture_file_name - file name to store the fixture in (relative to FIXTURE_PATHS)
#
def store_frontend_fixture(response, fixture_file_name)
- fixture_file_name = File.expand_path(fixture_file_name, FIXTURE_PATH)
- fixture = response.respond_to?(:body) ? parse_response(response) : response
+ FIXTURE_PATHS.each do |fixture_path|
+ fixture_file_name = File.expand_path(fixture_file_name, fixture_path)
+ fixture = response.respond_to?(:body) ? parse_response(response) : response
- FileUtils.mkdir_p(File.dirname(fixture_file_name))
- File.write(fixture_file_name, fixture)
+ FileUtils.mkdir_p(File.dirname(fixture_file_name))
+ File.write(fixture_file_name, fixture)
+ end
end
def remove_repository(project)
spec/support/helpers/kubernetes_helpers.rb
diff --git a/spec/support/helpers/kubernetes_helpers.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/support/helpers/kubernetes_helpers.rb
index 9dc89b483b2..cca11e112c9 100644
--- a/spec/support/helpers/kubernetes_helpers.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/support/helpers/kubernetes_helpers.rb
@@ -9,6 +9,10 @@ module KubernetesHelpers
kube_response(kube_pods_body)
end
+ def kube_logs_response
+ kube_response(kube_logs_body)
+ end
+
def kube_deployments_response
kube_response(kube_deployments_body)
end
@@ -34,6 +38,13 @@ module KubernetesHelpers
WebMock.stub_request(:get, pods_url).to_return(response || kube_pods_response)
end
+ def stub_kubeclient_logs(pod_name, response = nil)
+ stub_kubeclient_discover(service.api_url)
+ logs_url = service.api_url + "/api/v1/namespaces/#{service.actual_namespace}/pods/#{pod_name}/log?tailLines=#{Clusters::Platforms::Kubernetes::LOGS_LIMIT}"
+
+ WebMock.stub_request(:get, logs_url).to_return(response || kube_logs_response)
+ end
+
def stub_kubeclient_deployments(response = nil)
stub_kubeclient_discover(service.api_url)
deployments_url = service.api_url + "/apis/extensions/v1beta1/namespaces/#{service.actual_namespace}/deployments"
@@ -212,6 +223,10 @@ module KubernetesHelpers
}
end
+ def kube_logs_body
+ "Log 1\nLog 2\nLog 3"
+ end
+
def kube_deployments_body
{
"kind" => "DeploymentList",
spec/support/helpers/ldap_helpers.rb
diff --git a/spec/support/helpers/ldap_helpers.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/support/helpers/ldap_helpers.rb
index 66ca5d7f0a3..2f9295d42a2 100644
--- a/spec/support/helpers/ldap_helpers.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/support/helpers/ldap_helpers.rb
@@ -1,8 +1,16 @@
module LdapHelpers
+ include EE::LdapHelpers
+
def ldap_adapter(provider = 'ldapmain', ldap = double(:ldap))
::Gitlab::Auth::LDAP::Adapter.new(provider, ldap)
end
+ def fake_ldap_sync_proxy(provider)
+ fake_proxy = double(:proxy, adapter: ldap_adapter)
+ allow(::EE::Gitlab::Auth::LDAP::Sync::Proxy).to receive(:open).with(provider).and_yield(fake_proxy)
+ fake_proxy
+ end
+
def user_dn(uid)
"uid=#{uid},ou=users,dc=example,dc=com"
end
spec/support/helpers/stub_configuration.rb
diff --git a/spec/support/helpers/stub_configuration.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/support/helpers/stub_configuration.rb
index ff21bbe28ca..fe67d9d0de7 100644
--- a/spec/support/helpers/stub_configuration.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/support/helpers/stub_configuration.rb
@@ -4,7 +4,11 @@ require 'active_support/dependencies'
require_dependency 'gitlab'
+require_dependency Gitlab.root.join('ee/spec/support/helpers/ee/stub_configuration')
+
module StubConfiguration
+ prepend EE::StubConfiguration
+
def stub_application_setting(messages)
add_predicates(messages)
@@ -18,6 +22,16 @@ module StubConfiguration
allow_any_instance_of(ApplicationSetting).to receive(:cached_html_up_to_date?).and_return(false)
end
+ def stub_application_setting_on_object(object, messages)
+ add_predicates(messages)
+
+ allow(Gitlab::CurrentSettings.current_application_settings)
+ .to receive_messages(messages)
+ messages.each do |setting, value|
+ allow(object).to receive_message_chain(:current_application_settings, setting) { value }
+ end
+ end
+
def stub_not_protect_default_branch
stub_application_setting(
default_branch_protection: Gitlab::Access::PROTECTION_NONE)
spec/support/helpers/stub_object_storage.rb
diff --git a/spec/support/helpers/stub_object_storage.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/support/helpers/stub_object_storage.rb
index e0c50e533a6..69e99c4d83e 100644
--- a/spec/support/helpers/stub_object_storage.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/support/helpers/stub_object_storage.rb
@@ -1,4 +1,8 @@
+require_relative '../../../ee/spec/support/helpers/ee/stub_object_storage'
+
module StubObjectStorage
+ prepend EE::StubObjectStorage
+
def stub_object_storage_uploader(
config:,
uploader:,
@@ -74,4 +78,9 @@ module StubObjectStorage
</InitiateMultipartUploadResult>
EOS
end
+
+ def stub_object_storage_pseudonymizer
+ stub_object_storage(connection_params: Pseudonymizer::Uploader.object_store_credentials,
+ remote_directory: Pseudonymizer::Uploader.remote_directory)
+ end
end
This is a bit random, but should be simple to do.
Edited by Yorick Peterse