From cbab06519900e116d99255f604dc161ac2a69c5b Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Sun, 20 Sep 2015 18:16:51 +0700 Subject: [PATCH 1/2] Remove pre-commit requirements --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 6ee064b0..29d6b5e3 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,7 @@ "jscs": "^1.7.0", "nock": "^0.48.1", "endswith": "^0.0.0", - "tape-it": "^0.3.1", - "pre-commit": "0.0.9" + "tape-it": "^0.3.1" }, "scripts": { "test": "DEBUG=* NOCK_OFF=true istanbul cover tape tests/*/*/*.js", From 8460d561d5b2a670787c688569c44213364f4e53 Mon Sep 17 00:00:00 2001 From: "Johannes J. Schmidt" Date: Tue, 3 Nov 2015 17:49:38 +0100 Subject: [PATCH 2/2] chore(test): requestDefaults tests Closes #296 --- tests/fixtures/shared/config.json | 8 +++++ tests/integration/shared/config.js | 47 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/tests/fixtures/shared/config.json b/tests/fixtures/shared/config.json index 148e0c13..d8d1f32e 100644 --- a/tests/fixtures/shared/config.json +++ b/tests/fixtures/shared/config.json @@ -13,6 +13,14 @@ , { "path" : "/_all_dbs" , "response" : "{}" } +, { "path" : "/_all_dbs" + , "status" : 401 + , "response" : "{}" + } +, { "path" : "/foo/_all_docs" + , "status" : 401 + , "response" : "{}" + } , { "method" : "delete" , "path" : "/shared_config" , "response" : "{ \"ok\": true }" diff --git a/tests/integration/shared/config.js b/tests/integration/shared/config.js index 0b00e2ec..0636e8d2 100644 --- a/tests/integration/shared/config.js +++ b/tests/integration/shared/config.js @@ -146,3 +146,50 @@ it('should prevent shallow object copies', function(assert) { assert.end(); }); + +it('should accept requestDefaults', function(assert) { + var nanoWithDefaultHeaders = Nano({ + url: helpers.couch, + requestDefaults: { + auth: { + user: 'wiki', + pass: 'pedia' + } + } + }); + + var req = nanoWithDefaultHeaders.db.list(function(err) { + assert.equal(err.statusCode, 401, 'should be access denied'); + assert.end(); + }); + + assert.equal( + req.headers['authorization'], + 'Basic d2lraTpwZWRpYQ==', + 'header `Authorization` honored'); +}); + +it('should preserve requestDefaults on database api', function(assert) { + var nanoWithDefaultHeaders = Nano({ + url: helpers.couch, + requestDefaults: { + auth: { + user: 'wiki', + pass: 'pedia' + } + } + }); + + var nanoDatabaseWithDefaultHeaders = nanoWithDefaultHeaders.use('foo'); + + var req = nanoDatabaseWithDefaultHeaders.list(function(err) { + assert.equal(err.statusCode, 401, 'should be access denied'); + assert.end(); + }); + + assert.equal( + req.headers['authorization'], + 'Basic d2lraTpwZWRpYQ==', + 'header `Authorization` honored'); +}); +