Skip to content
Browse files

Added tests for using http auth (and fixed them).

  • Loading branch information...
1 parent b2980e3 commit 1aeab58d8f7fcb74398d6a564cb6b65d2b1fc346 @slaskis slaskis committed May 22, 2011
Showing with 23 additions and 1 deletion.
  1. +1 −1 lib/schemes/http.js
  2. +22 −0 test/test-open-uri.js
View
2 lib/schemes/http.js
@@ -35,7 +35,7 @@ module.exports = function http(uri,opts,output){
// HTTP Auth
if( uri.userinfo && !uri.headers.authorization )
- uri.headers.authorization = "Basic " + utils.toBase64(options.uri.userinfo);
+ uri.headers.authorization = "Basic " + utils.toBase64(uri.userinfo);
// Use gzip?
var gzip = typeof opts.gzip == "undefined" ? gzip : opts.gzip;
View
22 test/test-open-uri.js
@@ -74,6 +74,28 @@ exports["GET an encrypted website"] = function(beforeExit){
beforeExit(function(){assert.ok(loaded)})
}
+exports["GET a website with auth"] = function(beforeExit){
+ var loaded = false;
+ open("http://user:pass@google.com",function(err,google){
+ loaded = true;
+ assert.ifError(err)
+ assert.type(google,"string")
+ assert.ok(google.length>0)
+ })
+ beforeExit(function(){assert.ok(loaded)})
+}
+
+exports["GET an encrypted website with auth"] = function(beforeExit){
+ var loaded = false;
+ open("https://user:pass@google.com",function(err,google){
+ loaded = true;
+ assert.ifError(err)
+ assert.type(google,"string")
+ assert.ok(google.length>0)
+ })
+ beforeExit(function(){assert.ok(loaded)})
+}
+
exports["POST a string to a website"] = function(){
echo(++port,function(server){
open("http://localhost:"+port,{method:"POST",body:"abc"},function(err,dump,res){

0 comments on commit 1aeab58

Please sign in to comment.
Something went wrong with that request. Please try again.