Skip to content
Snippets Groups Projects

Add low level api cookie passing

Merged Zeff Morgan requested to merge qa/zm-api-cookie-update into master
1 file
+ 12
21
Compare changes
  • Side-by-side
  • Inline
+ 12
21
@@ -20,10 +20,8 @@ def post(url, payload, args = {})
verify_ssl: false
}
set_canary_api(default_args)
RestClient::Request.execute(
default_args.merge(args)
default_args.merge(args).merge(with_canary(args))
)
rescue RestClient::ExceptionWithResponse => e
return_response_or_raise(e)
@@ -38,10 +36,8 @@ def get(url, args = {})
verify_ssl: false
}
set_canary_api(default_args)
RestClient::Request.execute(
default_args.merge(args)
default_args.merge(args).merge(with_canary(args))
)
rescue RestClient::ExceptionWithResponse => e
return_response_or_raise(e)
@@ -57,10 +53,8 @@ def patch(url, payload = nil)
verify_ssl: false
}
set_canary_api(default_args)
RestClient::Request.execute(
default_args
default_args.merge(args).merge(with_canary(args))
)
rescue RestClient::ExceptionWithResponse => e
return_response_or_raise(e)
@@ -76,10 +70,8 @@ def put(url, payload = nil)
verify_ssl: false
}
set_canary_api(default_args)
RestClient::Request.execute(
default_args
default_args.merge(args).merge(with_canary(args))
)
rescue RestClient::ExceptionWithResponse => e
return_response_or_raise(e)
@@ -94,10 +86,8 @@ def delete(url)
verify_ssl: false
}
set_canary_api(default_args)
RestClient::Request.execute(
default_args
default_args.merge(args).merge(with_canary(args))
)
rescue RestClient::ExceptionWithResponse => e
return_response_or_raise(e)
@@ -115,13 +105,14 @@ def head(url)
end
end
def set_canary_api(default_args)
return unless ENV["QA_COOKIES"]["gitlab_canary"]
canary_value = ENV["QA_COOKIES"]["true"] = true ? "true" : "false"
canary = { cookies: { "gitlab_canary" => canary_value }}
def with_canary(args)
# returns empty hash when `gitlab_canary` not present so chained #merge succeeds
return {} unless ENV['QA_COOKIES']['gitlab_canary']
default_args.merge!(canary)
canary_value = { 'gitlab_canary' => ENV['QA_COOKIES']['gitlab_canary=true'] ? 'true' : 'false' }
# merges `gitlab_canary` cookie with existing cookies, not overwriting them
# or returns single cookie hash if no other cookies exist
args[:cookies] ? args[:cookies].merge!(canary_value) : { cookies: canary_value }
end
def with_retry_on_too_many_requests
Loading