summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2017-03-28 13:14:54 +0300
committerSteve Kemp <steve@steve.org.uk>2017-03-28 13:14:54 +0300
commit334c67fa0e39f657dfe59b4a6c6445de20d5706b (patch)
tree522553aca305601716b2dd3faa68d8f3237e32c8 /t
parente4040942ab55689f88625c8a048d83d84627d6e0 (diff)
Added testcases for HTTP basic-auth.
Diffstat (limited to 't')
-rwxr-xr-xt/test-custodian-parser.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/t/test-custodian-parser.rb b/t/test-custodian-parser.rb
index 1bcf5bc..843dc80 100755
--- a/t/test-custodian-parser.rb
+++ b/t/test-custodian-parser.rb
@@ -430,6 +430,46 @@ EOF
end
#
+ # Test that the parser works for basic-auth.
+ #
+ def test_http_user_password
+
+ #
+ # test data
+ #
+ data = {
+ 'http://example must run http with auth "bob:steve".' =>
+ { username: 'bob', password: 'steve'},
+ 'http://example must run http with auth "stee\':steve".' =>
+ { username: 'stee\'', password: 'steve'},
+ 'http://example must run http with auth \'e"e:pa$$w0rd\'.' =>
+ { username: 'e"e', password: 'pa$$w0rd'},
+ }
+
+ data.each do |str, hash |
+ assert_nothing_raised do
+
+ #
+ # Create the new parser
+ #
+ obj = Custodian::TestFactory.create(str)
+
+ assert(!obj.nil?)
+ assert(obj.kind_of?(Array))
+ assert(obj.size == 1)
+ assert_equal(obj[0].to_s, str)
+
+ # There should be auth-enabled
+ assert(obj[0].basic_auth?)
+ assert(obj[0].basic_auth_username == hash[:username] )
+ assert(obj[0].basic_auth_password == hash[:password] )
+
+ end
+ end
+ end
+
+
+ #
# HTTP/HTTPS tests might specify custom expiry
#
def test_https_custom_expiry