summaryrefslogtreecommitdiff
path: root/bin/run_tests
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2014-06-25 14:39:48 -0700
committerelijah <elijah@riseup.net>2014-06-25 14:39:48 -0700
commit1bf4dff125fb7d164d12ba9645241a5fd8f76a3a (patch)
tree6f8023677b0a7a986193bc1726f17a1645118e00 /bin/run_tests
parentfba004bc8cbee0d9556538342ce78ac1c9d1229b (diff)
parent10c76ac1cfa4e94375b456266e4113a4313abe96 (diff)
Merge branch 'bugfix/tests' into develop
Diffstat (limited to 'bin/run_tests')
-rwxr-xr-xbin/run_tests23
1 files changed, 20 insertions, 3 deletions
diff --git a/bin/run_tests b/bin/run_tests
index 3ba89684..d7fc1e4c 100755
--- a/bin/run_tests
+++ b/bin/run_tests
@@ -122,7 +122,7 @@ class LeapTest < MiniTest::Unit::TestCase
#
# attempts a http GET on the url, yields |body, response, error|
#
- def get(url, params=nil)
+ def get(url, params=nil, options=nil)
uri = URI(url)
if params
uri.query = URI.encode_www_form(params)
@@ -133,7 +133,11 @@ class LeapTest < MiniTest::Unit::TestCase
http.use_ssl = true
end
http.start do |agent|
- response = agent.get(uri.request_uri)
+ request = Net::HTTP::Get.new uri.request_uri
+ if options && options[:username]
+ request.basic_auth options[:username], options[:password]
+ end
+ response = agent.request(request)
if response.is_a?(Net::HTTPSuccess)
yield response.body, response, nil
else
@@ -146,7 +150,7 @@ class LeapTest < MiniTest::Unit::TestCase
def assert_get(url, params=nil, options=nil)
options ||= {}
- get(url, params) do |body, response, error|
+ get(url, params, options) do |body, response, error|
if body
yield body if block_given?
elsif response
@@ -158,6 +162,19 @@ class LeapTest < MiniTest::Unit::TestCase
end
#
+ # only a warning for now, should be a failure in the future
+ #
+ def assert_auth_fail(url, params, auth_options)
+ get(url, params, auth_options) do |body, response, error|
+ unless response.code == 401
+ warn "Expected a '401 Unauthorized' response, but got #{response.code} instead (GET #{url} with username '#{auth_options[:username]}')."
+ return false
+ end
+ end
+ true
+ end
+
+ #
# test if a socket can be connected to
#