summaryrefslogtreecommitdiff
path: root/bin/run_tests
diff options
context:
space:
mode:
Diffstat (limited to 'bin/run_tests')
-rwxr-xr-xbin/run_tests35
1 files changed, 30 insertions, 5 deletions
diff --git a/bin/run_tests b/bin/run_tests
index 526aa83a..2ee027f4 100755
--- a/bin/run_tests
+++ b/bin/run_tests
@@ -127,11 +127,22 @@ class LeapTest < MiniTest::Unit::TestCase
if params
uri.query = URI.encode_www_form(params)
end
- response = Net::HTTP.get_response(uri)
- if response.is_a?(Net::HTTPSuccess)
- yield response.body, response, nil
- else
- yield nil, response, nil
+ http = Net::HTTP.new uri.host, uri.port
+ if uri.scheme == 'https'
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+ http.use_ssl = true
+ end
+ http.start do |agent|
+ request = Net::HTTP::Get.new uri.request_uri
+ if uri.user
+ request.basic_auth uri.user, uri.password
+ end
+ response = agent.request(request)
+ if response.is_a?(Net::HTTPSuccess)
+ yield response.body, response, nil
+ else
+ yield nil, response, nil
+ end
end
rescue => exc
yield nil, nil, exc
@@ -151,6 +162,20 @@ class LeapTest < MiniTest::Unit::TestCase
end
#
+ # only a warning for now, should be a failure in the future
+ #
+ def assert_auth_fail(url, params)
+ uri = URI(url)
+ get(url, params) do |body, response, error|
+ unless response.code.to_s == "401"
+ warn "Expected a '401 Unauthorized' response, but got #{response.code} instead (GET #{uri.request_uri} with username '#{uri.user}')."
+ return false
+ end
+ end
+ true
+ end
+
+ #
# test if a socket can be connected to
#