New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

couchdb-harness

Package Overview
Dependencies
Maintainers
3
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

couchdb-harness - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

.travis.yml

6

index.js

@@ -26,3 +26,2 @@ "use strict";

'javascript/tests/conflicts.js',
'javascript/tests/cookie_auth.js',
'javascript/tests/delayed_commits.js',

@@ -38,7 +37,5 @@ 'javascript/tests/design_docs.js',

'javascript/tests/method_override.js',
'javascript/tests/oauth.js',
'javascript/tests/oauth_users_db.js',
'javascript/tests/proxyauth.js',
'javascript/tests/purge.js',
'javascript/tests/reader_acl.js',
'javascript/tests/recreate_doc.js',

@@ -49,3 +46,2 @@ 'javascript/tests/reduce_builtin.js',

'javascript/tests/replicator_db_by_doc_id.js',
'javascript/tests/replicator_db_compact_rep_db.js',
'javascript/tests/replicator_db_credential_delegation.js',

@@ -58,5 +54,3 @@ 'javascript/tests/replicator_db_filtered.js',

'javascript/tests/rev_stemming.js',
'javascript/tests/security_validation.js',
'javascript/tests/stats.js',
'javascript/tests/users_db.js',
'javascript/tests/users_db_security.js',

@@ -63,0 +57,0 @@ 'javascript/tests/view_collation.js',

52

javascript/tests/cookie_auth.js

@@ -91,13 +91,15 @@ // Licensed under the Apache License, Version 2.0 (the "License"); you may not

// make sure we cant create duplicate users
var duplicateJchrisDoc = CouchDB.prepareUserDoc({
name: "jchris@apache.org"
}, "eh, Boo-Boo?");
skip("For some reason this gives 'forbidden' instead of 'conflict'", function () {
var duplicateJchrisDoc = CouchDB.prepareUserDoc({
name: "jchris@apache.org"
}, "eh, Boo-Boo?");
try {
usersDb.save(duplicateJchrisDoc);
T(false && "Can't create duplicate user names. Should have thrown an error.");
} catch (e) {
TEquals("conflict", e.error);
TEquals(409, usersDb.last_req.status);
}
try {
usersDb.save(duplicateJchrisDoc);
T(false && "Can't create duplicate user names. Should have thrown an error.");
} catch (e) {
TEquals("conflict", e.error);
TEquals(409, usersDb.last_req.status);
}
});

@@ -165,4 +167,6 @@ // we can't create _names

// a failed login attempt should log you out
T(CouchDB.session().userCtx.name != 'Jason Davies');
skip("a pouchdb-auth bug/feature", function () {
// a failed login attempt should log you out
T(CouchDB.session().userCtx.name != 'Jason Davies');
});

@@ -198,9 +202,11 @@ // test redirect on success

try {
usersDb.save(jasonUserDoc);
T(false && "Can't update someone else's user doc. Should have thrown an error.");
} catch (e) {
T(e.error == "not_found");
T(usersDb.last_req.status == 404);
}
skip("Should be 'not_found' instead of 'forbidden'.", function () {
try {
usersDb.save(jasonUserDoc);
T(false && "Can't update someone else's user doc. Should have thrown an error.");
} catch (e) {
T(e.error == "not_found");
T(usersDb.last_req.status == 404);
}
});

@@ -249,3 +255,5 @@ // test that you can't edit roles unless you are admin

// test that jchris still has the foo role
T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);
skip("pouchdb-auth doesn't link admins to user docs", function () {
T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);
});

@@ -266,3 +274,5 @@ // should work even when user doc has no password

// test that jchris still has the foo role
T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);
skip("pouchdb-auth doesn't link admins to user docs", function () {
T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);
});
});

@@ -269,0 +279,0 @@

@@ -222,118 +222,122 @@ // Licensed under the Apache License, Version 2.0 (the "License"); you may not

// now test bulk docs
var docs = [{_id:"bahbah",author:"Damien Katz",foo:"bar"},{_id:"fahfah",foo:"baz"}];
skip("bulk docs ordering isn't preserved by pouchdb-bulkdocs-wrapper", function () {
var docs = [{_id:"bahbah",author:"Damien Katz",foo:"bar"},{_id:"fahfah",foo:"baz"}];
// Create the docs
var results = db.bulkSave(docs);
// Create the docs
var results = db.bulkSave(docs);
T(results[0].rev)
T(results[0].error == undefined)
T(results[1].rev === undefined)
T(results[1].error == "forbidden")
T(results[0].rev)
T(results[0].error == undefined)
T(results[1].rev === undefined)
T(results[1].error == "forbidden")
T(db.open("bahbah"));
T(db.open("fahfah") == null);
T(db.open("bahbah"));
T(db.open("fahfah") == null);
// now all or nothing with a failure
var docs = [{_id:"booboo",author:"Damien Katz",foo:"bar"},{_id:"foofoo",foo:"baz"}];
// now all or nothing with a failure
var docs = [{_id:"booboo",author:"Damien Katz",foo:"bar"},{_id:"foofoo",foo:"baz"}];
// Create the docs
var results = db.bulkSave(docs, {all_or_nothing:true});
// Create the docs
var results = db.bulkSave(docs, {all_or_nothing:true});
T(results.errors.length == 1);
T(results.errors[0].error == "forbidden");
T(db.open("booboo") == null);
T(db.open("foofoo") == null);
T(results.errors.length == 1);
T(results.errors[0].error == "forbidden");
T(db.open("booboo") == null);
T(db.open("foofoo") == null);
});
// Now test replication
var AuthHeaders = {"WWW-Authenticate": "X-Couch-Test-Auth Christopher Lenz:dog food"};
var host = CouchDB.host;
var dbPairs = [
{source:"test_suite_db_a",
target:"test_suite_db_b"},
skip("pouchdb-security's handling of replicate() is a mess combined with validation functions", function () {
var AuthHeaders = {"WWW-Authenticate": "X-Couch-Test-Auth Christopher Lenz:dog food"};
var host = CouchDB.host;
var dbPairs = [
{source:"test_suite_db_a",
target:"test_suite_db_b"},
{source:"test_suite_db_a",
target:{url: CouchDB.protocol + host + "/test_suite_db_b",
headers: AuthHeaders}},
{source:"test_suite_db_a",
target:{url: CouchDB.protocol + host + "/test_suite_db_b",
headers: AuthHeaders}},
{source:{url:CouchDB.protocol + host + "/test_suite_db_a",
headers: AuthHeaders},
target:"test_suite_db_b"},
{source:{url:CouchDB.protocol + host + "/test_suite_db_a",
headers: AuthHeaders},
target:"test_suite_db_b"},
{source:{url:CouchDB.protocol + host + "/test_suite_db_a",
headers: AuthHeaders},
target:{url:CouchDB.protocol + host + "/test_suite_db_b",
headers: AuthHeaders}},
]
var adminDbA = new CouchDB("test_suite_db_a", {"X-Couch-Full-Commit":"false"});
var adminDbB = new CouchDB("test_suite_db_b", {"X-Couch-Full-Commit":"false"});
var dbA = new CouchDB("test_suite_db_a",
{"WWW-Authenticate": "X-Couch-Test-Auth Christopher Lenz:dog food"});
var dbB = new CouchDB("test_suite_db_b",
{"WWW-Authenticate": "X-Couch-Test-Auth Christopher Lenz:dog food"});
var xhr;
for (var testPair = 0; testPair < dbPairs.length; testPair++) {
var A = dbPairs[testPair].source
var B = dbPairs[testPair].target
{source:{url:CouchDB.protocol + host + "/test_suite_db_a",
headers: AuthHeaders},
target:{url:CouchDB.protocol + host + "/test_suite_db_b",
headers: AuthHeaders}},
]
var adminDbA = new CouchDB("test_suite_db_a", {"X-Couch-Full-Commit":"false"});
var adminDbB = new CouchDB("test_suite_db_b", {"X-Couch-Full-Commit":"false"});
var dbA = new CouchDB("test_suite_db_a",
{"WWW-Authenticate": "X-Couch-Test-Auth Christopher Lenz:dog food"});
var dbB = new CouchDB("test_suite_db_b",
{"WWW-Authenticate": "X-Couch-Test-Auth Christopher Lenz:dog food"});
var xhr;
for (var testPair = 0; testPair < dbPairs.length; testPair++) {
var A = dbPairs[testPair].source
var B = dbPairs[testPair].target
adminDbA.deleteDb();
adminDbA.createDb();
adminDbB.deleteDb();
adminDbB.createDb();
adminDbA.deleteDb();
adminDbA.createDb();
adminDbB.deleteDb();
adminDbB.createDb();
// save and replicate a documents that will and will not pass our design
// doc validation function.
dbA.save({_id:"foo1",value:"a",author:"Noah Slater"});
dbA.save({_id:"foo2",value:"a",author:"Christopher Lenz"});
dbA.save({_id:"bad1",value:"a"});
// save and replicate a documents that will and will not pass our design
// doc validation function.
dbA.save({_id:"foo1",value:"a",author:"Noah Slater"});
dbA.save({_id:"foo2",value:"a",author:"Christopher Lenz"});
dbA.save({_id:"bad1",value:"a"});
T(CouchDB.replicate(A, B, {headers:AuthHeaders}).ok);
T(CouchDB.replicate(B, A, {headers:AuthHeaders}).ok);
T(CouchDB.replicate(A, B, {headers:AuthHeaders}).ok);
T(CouchDB.replicate(B, A, {headers:AuthHeaders}).ok);
T(dbA.open("foo1"));
T(dbB.open("foo1"));
T(dbA.open("foo2"));
T(dbB.open("foo2"));
T(dbA.open("foo1"));
T(dbB.open("foo1"));
T(dbA.open("foo2"));
T(dbB.open("foo2"));
// save the design doc to dbA
delete designDoc._rev; // clear rev from previous saves
adminDbA.save(designDoc);
// save the design doc to dbA
delete designDoc._rev; // clear rev from previous saves
adminDbA.save(designDoc);
// no affect on already saved docs
T(dbA.open("bad1"));
// no affect on already saved docs
T(dbA.open("bad1"));
// Update some docs on dbB. Since the design hasn't replicated, anything
// is allowed.
// Update some docs on dbB. Since the design hasn't replicated, anything
// is allowed.
// this edit will fail validation on replication to dbA (no author)
T(dbB.save({_id:"bad2",value:"a"}).ok);
// this edit will fail validation on replication to dbA (no author)
T(dbB.save({_id:"bad2",value:"a"}).ok);
// this edit will fail security on replication to dbA (wrong author
// replicating the change)
var foo1 = dbB.open("foo1");
foo1.value = "b";
dbB.save(foo1);
// this edit will fail security on replication to dbA (wrong author
// replicating the change)
var foo1 = dbB.open("foo1");
foo1.value = "b";
dbB.save(foo1);
// this is a legal edit
var foo2 = dbB.open("foo2");
foo2.value = "b";
dbB.save(foo2);
// this is a legal edit
var foo2 = dbB.open("foo2");
foo2.value = "b";
dbB.save(foo2);
var results = CouchDB.replicate(B, A, {headers:AuthHeaders});
var results = CouchDB.replicate(B, A, {headers:AuthHeaders});
T(results.ok);
T(results.ok);
T(results.history[0].docs_written == 1);
T(results.history[0].doc_write_failures == 2);
T(results.history[0].docs_written == 1);
T(results.history[0].doc_write_failures == 2);
// bad2 should not be on dbA
T(dbA.open("bad2") == null);
// bad2 should not be on dbA
T(dbA.open("bad2") == null);
// The edit to foo1 should not have replicated.
T(dbA.open("foo1").value == "a");
// The edit to foo1 should not have replicated.
T(dbA.open("foo1").value == "a");
// The edit to foo2 should have replicated.
T(dbA.open("foo2").value == "b");
}
// The edit to foo2 should have replicated.
T(dbA.open("foo2").value == "b");
};
});
});
};

@@ -102,3 +102,5 @@ // Licensed under the Apache License, Version 2.0 (the "License"); you may not

TEquals(40, userDoc.derived_key.length, "derived_key should exist");
TEquals(32, userDoc.salt.length, "salt should exist");
skip("pouchdb-auth uses a larger salt", function () {
TEquals(32, userDoc.salt.length, "salt should exist");
});

@@ -105,0 +107,0 @@ // create server admin

@@ -49,10 +49,14 @@ // Licensed under the Apache License, Version 2.0 (the "License"); you may not

T(s.info.authentication_db == "test_suite_users");
TEquals(["oauth", "cookie", "default"], s.info.authentication_handlers);
var s = CouchDB.session({
headers : {
"Authorization" : "Basic Xzpf" // name and pass of _:_
}
skip("oauth not supported in PouchDB server", function () {
TEquals(["oauth", "cookie", "default"], s.info.authentication_handlers);
});
T(s.name == null);
T(s.info.authenticated == "default");
skip("PouchDB-Server doesn't have a special case for _:_. Should it?", function () {
var s = CouchDB.session({
headers : {
"Authorization" : "Basic Xzpf" // name and pass of _:_
}
});
T(s.name == null);
T(s.info.authenticated == "default");
});

@@ -71,25 +75,27 @@

// save as bulk with new_edits=false to force conflict save
var resp = usersDb.bulkSave([jchrisUserDoc],{all_or_nothing : true});
skip("all_or_nothing not supported by PouchDB-Server", function () {
var resp = usersDb.bulkSave([jchrisUserDoc],{all_or_nothing : true});
var jchrisWithConflict = usersDb.open(jchrisUserDoc._id, {conflicts : true});
T(jchrisWithConflict._conflicts.length == 1);
var jchrisWithConflict = usersDb.open(jchrisUserDoc._id, {conflicts : true});
T(jchrisWithConflict._conflicts.length == 1);
// no login with conflicted user doc
try {
var s = CouchDB.session({
headers : {
"Authorization" : "Basic amNocmlzQGFwYWNoZS5vcmc6ZnVubnlib25l"
}
});
T(false && "this will throw");
} catch(e) {
T(e.error == "unauthorized");
T(/conflict/.test(e.reason));
}
// no login with conflicted user doc
try {
var s = CouchDB.session({
headers : {
"Authorization" : "Basic amNocmlzQGFwYWNoZS5vcmc6ZnVubnlib25l"
}
});
T(false && "this will throw");
} catch(e) {
T(e.error == "unauthorized");
T(/conflict/.test(e.reason));
}
// you can delete a user doc
s = CouchDB.session().userCtx;
T(s.name == null);
T(s.roles.indexOf("_admin") !== -1);
T(usersDb.deleteDoc(jchrisWithConflict).ok);
// you can delete a user doc
s = CouchDB.session().userCtx;
T(s.name == null);
T(s.roles.indexOf("_admin") !== -1);
T(usersDb.deleteDoc(jchrisWithConflict).ok);
});

@@ -96,0 +102,0 @@ // you can't change doc from type "user"

{
"name": "couchdb-harness",
"version": "0.1.4",
"version": "0.1.5",
"description": "A generalized port of the CouchDB JavaScript test harness.",

@@ -13,3 +13,4 @@ "repository": {

"jshint": "./node_modules/.bin/jshint bin/couchdb-harness index.js",
"test": "npm run jshint"
"test-pouchdb-server": "cd node_modules/pouchdb-server && npm run test-couchdb",
"test": "npm run jshint && npm run test-pouchdb-server"
},

@@ -37,4 +38,5 @@ "bin": "./bin/couchdb-harness",

"devDependencies": {
"jshint": "^2.5.11"
"jshint": "^2.5.11",
"pouchdb-server": "^0.6.4"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc