summaryrefslogtreecommitdiff
path: root/qa/qa/runtime/application_settings.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 19:00:14 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 19:00:14 +0000
commit05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch)
tree11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /qa/qa/runtime/application_settings.rb
parentec73467c23693d0db63a797d10194da9e72a74af (diff)
downloadgitlab-ce-05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2.tar.gz
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'qa/qa/runtime/application_settings.rb')
-rw-r--r--qa/qa/runtime/application_settings.rb18
1 files changed, 12 insertions, 6 deletions
diff --git a/qa/qa/runtime/application_settings.rb b/qa/qa/runtime/application_settings.rb
index 55a5ae9d06c..5aeab922a12 100644
--- a/qa/qa/runtime/application_settings.rb
+++ b/qa/qa/runtime/application_settings.rb
@@ -2,6 +2,8 @@
module QA
module Runtime
+ # TODO: Ideally this should be changed to a normal class due to now being able to override what api client is used
+ #
class ApplicationSettings
class << self
include Support::API
@@ -13,26 +15,30 @@ module QA
# #set({ allow_local_requests_from_web_hooks_and_services: true })
# #set(allow_local_requests_from_web_hooks_and_services: true)
# https://docs.gitlab.com/ee/api/settings.html
- def set_application_settings(**application_settings)
- @original_application_settings = get_application_settings
+ def set_application_settings(api_client: admin_api_client, **application_settings)
+ @original_application_settings = get_application_settings(api_client: api_client)
QA::Runtime::Logger.info("Setting application settings: #{application_settings}")
r = put(Runtime::API::Request.new(api_client, APPLICATION_SETTINGS_PATH).url, **application_settings)
- raise "Couldn't set application settings #{application_settings.inspect}" unless r.code == QA::Support::API::HTTP_STATUS_OK
+ return if r.code == QA::Support::API::HTTP_STATUS_OK
+
+ raise "Couldn't set application settings #{application_settings.inspect}"
end
- def get_application_settings
+ def get_application_settings(api_client: admin_api_client)
parse_body(get(Runtime::API::Request.new(api_client, APPLICATION_SETTINGS_PATH).url))
end
+ # TODO: This class probably needs to be refactored because this method relies on original settings to have been
+ # populated sometime in the past and there is no guarantee original settings instance variable is still valid
def restore_application_settings(*application_settings_keys)
set_application_settings(**@original_application_settings.slice(*application_settings_keys))
end
private
- def api_client
- @api_client ||= Runtime::API::Client.as_admin
+ def admin_api_client
+ @admin_api_client ||= Runtime::API::Client.as_admin
rescue API::Client::AuthorizationError => e
raise "Administrator access is required to set application settings. #{e.message}"
end