Skip to content

Commit

Permalink
Adding test coverage for basic-auth
Browse files Browse the repository at this point in the history
  • Loading branch information
steelThread committed Feb 25, 2011
1 parent 560567b commit 7b1484c
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions basicTests.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var CouchClient = require('./lib/couch-client');
var assert = require('assert');

({
run:function() {
Expand Down Expand Up @@ -71,10 +72,9 @@ var CouchClient = require('./lib/couch-client');
});
},


testCouchOne:function()
{
var db = CouchClient('http://couch-client:testingonly@couch-client.couchone.com:80/test');
var db = CouchClient('http://couch-client.couchone.com:80/test');

db.request("PUT", "/test", function (err, result) {
if (err) throw err;
Expand Down Expand Up @@ -106,7 +106,7 @@ var CouchClient = require('./lib/couch-client');

testCouchOneSSL:function()
{
var db = CouchClient('https://couch-client:testingonly@couch-client.couchone.com:443/test');
var db = CouchClient('https://couch-client.couchone.com:443/test');

db.request("PUT", "/test", function (err, result) {
if (err) throw err;
Expand All @@ -133,5 +133,27 @@ var CouchClient = require('./lib/couch-client');
});
});
});
}
},

testBasicAuthFailsWhenUsingHttp: function() {
var db = CouchClient('http://couch-client:testingonly@couch-client.couchone.com:80/');
db.view('/secure/does/not/exist', function (err, result) {
if (err) throw err;
assert.deepEqual(
{error: 'unauthorized', reason: 'You are not authorized to access this db.'},
result
);
});
},

testBasicAuthWorksWhenUsingHttps: function() {
var db = CouchClient('https://couch-client:testingonly@couch-client.couchone.com:443/');
db.view('/secure/does/not/exist', function (err, result) {
if (err) throw err;
assert.deepEqual(
{error: 'not_found', reason: 'missing'},
result
);
});
}
}).run();

0 comments on commit 7b1484c

Please sign in to comment.