Fixes #3573 - Accept 2xx as response for requests in UserAgent
This commit is contained in:
parent
c3247e98ff
commit
18f14d1720
2 changed files with 16 additions and 1 deletions
|
@ -472,7 +472,7 @@ returns
|
|||
|
||||
url = response['location']
|
||||
return get(url, params, options, count - 1)
|
||||
when Net::HTTPOK, Net::HTTPCreated
|
||||
when Net::HTTPSuccess
|
||||
data = nil
|
||||
if options[:json] && !options[:jsonParseDisable] && response.body
|
||||
data = JSON.parse(response.body)
|
||||
|
|
|
@ -32,6 +32,21 @@ class UserAgentTest < ActiveSupport::TestCase
|
|||
assert_match(%r{"remote_ip":"#{ENV['ZAMMAD_PROXY_REMOTE_IP_CHECK']}"}, result.body)
|
||||
end
|
||||
|
||||
# get / 202
|
||||
result = UserAgent.get(
|
||||
"#{host}/test/get_accepted/1?submitted=123",
|
||||
)
|
||||
assert(result)
|
||||
assert_equal(true, result.success?)
|
||||
assert_equal('202', result.code)
|
||||
assert_equal(String, result.body.class)
|
||||
assert(result.body.include?('"get"'))
|
||||
assert(result.body.include?('"123"'))
|
||||
assert(result.body.include?('"content_type_requested":null'))
|
||||
if ENV['ZAMMAD_PROXY_TEST'] == 'true' && ENV['ZAMMAD_PROXY_REMOTE_IP_CHECK']
|
||||
assert_match(%r{"remote_ip":"#{ENV['ZAMMAD_PROXY_REMOTE_IP_CHECK']}"}, result.body)
|
||||
end
|
||||
|
||||
# get / 404
|
||||
result = UserAgent.get(
|
||||
"#{host}/test/not_existing",
|
||||
|
|
Loading…
Reference in a new issue