Huge News!Announcing our $40M Series B led by Abstract Ventures.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.3 to 0.1.4

3

index.js

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

'javascript/tests/jsonp.js',
'javascript/tests/list_views.js',
'javascript/tests/method_override.js',

@@ -58,5 +57,3 @@ 'javascript/tests/oauth.js',

'javascript/tests/security_validation.js',
'javascript/tests/show_documents.js',
'javascript/tests/stats.js',
'javascript/tests/update_documents.js',
'javascript/tests/users_db.js',

@@ -63,0 +60,0 @@ 'javascript/tests/users_db_security.js',

160

javascript/tests/list_views.js

@@ -218,19 +218,21 @@ // Licensed under the Apache License, Version 2.0 (the "License"); you may not

// test that etags are available
var etag = xhr.getResponseHeader("etag");
xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/basicBasic/basicView", {
headers: {"if-none-match": etag}
skip("PouchDB-server bug: why doesn't express do etags here?", function () {
// test that etags are available
var etag = xhr.getResponseHeader("etag");
xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/basicBasic/basicView", {
headers: {"if-none-match": etag}
});
T(xhr.status == 304);
// confirm ETag changes with different POST bodies
xhr = CouchDB.request("POST", "/test_suite_db/_design/lists/_list/basicBasic/basicView",
{body: JSON.stringify({keys:[1]})}
);
var etag1 = xhr.getResponseHeader("etag");
xhr = CouchDB.request("POST", "/test_suite_db/_design/lists/_list/basicBasic/basicView",
{body: JSON.stringify({keys:[2]})}
);
var etag2 = xhr.getResponseHeader("etag");
T(etag1 != etag2, "POST to map _list generates key-depdendent ETags");
});
T(xhr.status == 304);
// confirm ETag changes with different POST bodies
xhr = CouchDB.request("POST", "/test_suite_db/_design/lists/_list/basicBasic/basicView",
{body: JSON.stringify({keys:[1]})}
);
var etag1 = xhr.getResponseHeader("etag");
xhr = CouchDB.request("POST", "/test_suite_db/_design/lists/_list/basicBasic/basicView",
{body: JSON.stringify({keys:[2]})}
);
var etag2 = xhr.getResponseHeader("etag");
T(etag1 != etag2, "POST to map _list generates key-depdendent ETags");

@@ -246,3 +248,5 @@ // test the richness of the arguments

T(resp.rows.length == 10);
TEquals(resp.rows[0], {"id": "0","key": 0,"value": "0"});
skip("Compares property order of the object - which is broken", function () {
TEquals(resp.rows[0], {"id": "0","key": 0,"value": "0"});
});

@@ -300,29 +304,31 @@ TEquals(resp.req.info.db_name, "test_suite_db");

// there should be etags on reduce as well
var etag = xhr.getResponseHeader("etag");
T(etag, "Etags should be served with reduce lists");
xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/simpleForm/withReduce?group=true", {
headers: {"if-none-match": etag}
});
T(xhr.status == 304);
skip("PouchDB-server bug: why doesn't express do etags here?", function () {
// there should be etags on reduce as well
var etag = xhr.getResponseHeader("etag");
T(etag, "Etags should be served with reduce lists");
xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/simpleForm/withReduce?group=true", {
headers: {"if-none-match": etag}
});
T(xhr.status == 304);
// confirm ETag changes with different POST bodies
xhr = CouchDB.request("POST", "/test_suite_db/_design/lists/_list/simpleForm/withReduce?group=true",
{body: JSON.stringify({keys:[1]})}
);
var etag1 = xhr.getResponseHeader("etag");
xhr = CouchDB.request("POST", "/test_suite_db/_design/lists/_list/simpleForm/withReduce?group=true",
{body: JSON.stringify({keys:[2]})}
);
var etag2 = xhr.getResponseHeader("etag");
T(etag1 != etag2, "POST to reduce _list generates key-depdendent ETags");
// confirm ETag changes with different POST bodies
xhr = CouchDB.request("POST", "/test_suite_db/_design/lists/_list/simpleForm/withReduce?group=true",
{body: JSON.stringify({keys:[1]})}
);
var etag1 = xhr.getResponseHeader("etag");
xhr = CouchDB.request("POST", "/test_suite_db/_design/lists/_list/simpleForm/withReduce?group=true",
{body: JSON.stringify({keys:[2]})}
);
var etag2 = xhr.getResponseHeader("etag");
T(etag1 != etag2, "POST to reduce _list generates key-depdendent ETags");
// verify the etags expire correctly
var docs = makeDocs(11, 12);
db.bulkSave(docs);
// verify the etags expire correctly
var docs = makeDocs(11, 12);
db.bulkSave(docs);
xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/simpleForm/withReduce?group=true", {
headers: {"if-none-match": etag}
xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/simpleForm/withReduce?group=true", {
headers: {"if-none-match": etag}
});
T(xhr.status == 200, "reduce etag");
});
T(xhr.status == 200, "reduce etag");

@@ -405,23 +411,25 @@ // empty list

// Test we can run lists and views from separate docs.
T(db.save(viewOnlyDesignDoc).ok);
var url = "/test_suite_db/_design/lists/_list/simpleForm/views/basicView" +
"?startkey=-3";
xhr = CouchDB.request("GET", url);
T(xhr.status == 200, "multiple design docs.");
T(!(/Key: -4/.test(xhr.responseText)));
T(/FirstKey: -3/.test(xhr.responseText));
T(/LastKey: 0/.test(xhr.responseText));
skip("PouchDB-Server can't run lists and views from separate docs", function () {
// Test we can run lists and views from separate docs.
T(db.save(viewOnlyDesignDoc).ok);
var url = "/test_suite_db/_design/lists/_list/simpleForm/views/basicView" +
"?startkey=-3";
xhr = CouchDB.request("GET", url);
T(xhr.status == 200, "multiple design docs.");
T(!(/Key: -4/.test(xhr.responseText)));
T(/FirstKey: -3/.test(xhr.responseText));
T(/LastKey: 0/.test(xhr.responseText));
// Test we do multi-key requests on lists and views in separate docs.
var url = "/test_suite_db/_design/lists/_list/simpleForm/views/basicView";
xhr = CouchDB.request("POST", url, {
body: '{"keys":[-2,-4,-5,-7]}'
// Test we do multi-key requests on lists and views in separate docs.
var url = "/test_suite_db/_design/lists/_list/simpleForm/views/basicView";
xhr = CouchDB.request("POST", url, {
body: '{"keys":[-2,-4,-5,-7]}'
});
T(xhr.status == 200, "multi key separate docs");
T(!(/Key: -3/.test(xhr.responseText)));
T(/Key: -7/.test(xhr.responseText));
T(/FirstKey: -2/.test(xhr.responseText));
T(/LastKey: -7/.test(xhr.responseText));
});
T(xhr.status == 200, "multi key separate docs");
T(!(/Key: -3/.test(xhr.responseText)));
T(/Key: -7/.test(xhr.responseText));
T(/FirstKey: -2/.test(xhr.responseText));
T(/LastKey: -7/.test(xhr.responseText));

@@ -448,7 +456,9 @@ // Test if secObj is available

run_on_modified_server([{
section: "native_query_servers",
key: "erlang",
value: "{couch_native_process, start_link, []}"
}], erlViewTest);
skip("PouchDB-Server doesn't support erlang views", function () {
run_on_modified_server([{
section: "native_query_servers",
key: "erlang",
value: "{couch_native_process, start_link, []}"
}], erlViewTest);
});

@@ -487,12 +497,14 @@ // COUCHDB-1113

// test handling _all_docs by _list functions. the result should be equal
var xhr_lAllDocs = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/allDocs/_all_docs");
T(xhr_lAllDocs.status == 200, "standard get should be 200");
var xhr_allDocs = CouchDB.request("GET", "/test_suite_db/_all_docs");
var allDocs = JSON.parse(xhr_allDocs.responseText);
var lAllDocs = JSON.parse(xhr_lAllDocs.responseText);
TEquals(allDocs.total_rows, lAllDocs.total_rows, "total_rows mismatch");
TEquals(allDocs.offset, lAllDocs.offset, "offset mismatch");
TEquals(allDocs.rows.length, lAllDocs.rows.length, "amount of rows mismatch");
TEquals(allDocs.rows, lAllDocs.rows, "rows mismatch");
skip("_all_docs list is unsupported in PouchDB-Server", function () {
// test handling _all_docs by _list functions. the result should be equal
var xhr_lAllDocs = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/allDocs/_all_docs");
T(xhr_lAllDocs.status == 200, "standard get should be 200");
var xhr_allDocs = CouchDB.request("GET", "/test_suite_db/_all_docs");
var allDocs = JSON.parse(xhr_allDocs.responseText);
var lAllDocs = JSON.parse(xhr_lAllDocs.responseText);
TEquals(allDocs.total_rows, lAllDocs.total_rows, "total_rows mismatch");
TEquals(allDocs.offset, lAllDocs.offset, "offset mismatch");
TEquals(allDocs.rows.length, lAllDocs.rows.length, "amount of rows mismatch");
TEquals(allDocs.rows, lAllDocs.rows, "rows mismatch");
});
};

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

T(xhr.status == 404, 'Should be missing');
T(JSON.parse(xhr.responseText).reason == "Invalid path.");
skip("different error message", function () {
T(JSON.parse(xhr.responseText).reason == "Invalid path.");
});

@@ -185,4 +187,6 @@ // hello template world

// Fix for COUCHDB-379
T(equals(xhr.getResponseHeader("Server").substr(0,7), "CouchDB"));
skip("PouchDB-Server doesn't set the Server header to 'CouchDB' (doesn't set it at all?)", function () {
// Fix for COUCHDB-379
T(equals(xhr.getResponseHeader("Server").substr(0,7), "CouchDB"));
});

@@ -247,3 +251,5 @@ // // error stacktraces

T(/text\/html/.test(ct))
T("Accept" == xhr.getResponseHeader("Vary"));
skip("PouchDB-Server adds Accept-Encoding because of probably different compresssion logic.", function () {
T("Accept" == xhr.getResponseHeader("Vary"));
});
var etag = xhr.getResponseHeader("etag");

@@ -297,4 +303,6 @@

});
// should not be 304 if we change the doc
T(xhr.status != 304, "changed ddoc");
skip("Incompatible CouchDB/PouchDB Server (express) etags", function () {
// should not be 304 if we change the doc
T(xhr.status != 304, "changed ddoc");
});

@@ -362,3 +370,5 @@ // update design doc function

xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/json/foo");
TEquals(1, JSON.parse(xhr.responseText)._conflicts.length);
skip("all_or_nothing in bulkDocs not supported by PouchDB", function () {
TEquals(1, JSON.parse(xhr.responseText)._conflicts.length);
});

@@ -374,23 +384,25 @@ var doc3 = {_id:"a/b/c", a:1};

// test list() compatible API
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/list-api/foo");
T(xhr.responseText == "Hey");
TEquals("Yeah", xhr.getResponseHeader("X-Couch-Test-Header"), "header should be cool");
skip("list() compatible API isn't supported by PouchDB-Server", function () {
// test list() compatible API
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/list-api/foo");
T(xhr.responseText == "Hey");
TEquals("Yeah", xhr.getResponseHeader("X-Couch-Test-Header"), "header should be cool");
// test list() compatible API with provides function
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/list-api-provides/foo?format=text");
TEquals(xhr.responseText, "foo, bar, baz!", "should join chunks to response body");
// test list() compatible API with provides function
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/list-api-provides/foo?format=text");
TEquals(xhr.responseText, "foo, bar, baz!", "should join chunks to response body");
// should keep next result order: chunks + return value + provided chunks + provided return value
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/list-api-provides-and-return/foo?format=text");
TEquals(xhr.responseText, "1, 2, 3, 4, 5, 6, 7!", "should not break 1..7 range");
// should keep next result order: chunks + return value + provided chunks + provided return value
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/list-api-provides-and-return/foo?format=text");
TEquals(xhr.responseText, "1, 2, 3, 4, 5, 6, 7!", "should not break 1..7 range");
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/list-api-mix/foo");
T(xhr.responseText == "Hey Dude");
TEquals("Yeah", xhr.getResponseHeader("X-Couch-Test-Header"), "header should be cool");
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/list-api-mix/foo");
T(xhr.responseText == "Hey Dude");
TEquals("Yeah", xhr.getResponseHeader("X-Couch-Test-Header"), "header should be cool");
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/list-api-mix-with-header/foo");
T(xhr.responseText == "Hey Dude");
TEquals("Yeah", xhr.getResponseHeader("X-Couch-Test-Header"), "header should be cool");
TEquals("Oh Yeah!", xhr.getResponseHeader("X-Couch-Test-Header-Awesome"), "header should be cool");
xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/list-api-mix-with-header/foo");
T(xhr.responseText == "Hey Dude");
TEquals("Yeah", xhr.getResponseHeader("X-Couch-Test-Header"), "header should be cool");
TEquals("Oh Yeah!", xhr.getResponseHeader("X-Couch-Test-Header-Awesome"), "header should be cool");
});

@@ -397,0 +409,0 @@ // test deleted docs

@@ -76,11 +76,11 @@ // Licensed under the Apache License, Version 2.0 (the "License"); you may not

var message = "<h1>bumped it!</h1>";
resp = {"code": 302, "body": message}
var resp = {"code": 302, "body": message}
return [doc, resp];
}),
"resp-code" : stringFun(function(doc,req) {
resp = {"code": 302}
var resp = {"code": 302}
return [null, resp];
}),
"resp-code-and-json" : stringFun(function(doc,req) {
resp = {"code": 302, "json": {"ok": true}}
var resp = {"code": 302, "json": {"ok": true}}
return [{"_id": req["uuid"]}, resp];

@@ -112,3 +112,5 @@ }),

T(xhr.status == 404, 'Should be missing');
T(JSON.parse(xhr.responseText).reason == "Invalid path.");
skip("Different error message in pouchdb server", function () {
T(JSON.parse(xhr.responseText).reason == "Invalid path.");
});

@@ -125,4 +127,6 @@ // hello update world

// Fix for COUCHDB-379
T(equals(xhr.getResponseHeader("Server").substr(0,7), "CouchDB"));
skip("PouchDB-Server doesn't set the Server header (and even if it did, not to 'CouchDB ...')", function () {
// Fix for COUCHDB-379
T(equals(xhr.getResponseHeader("Server").substr(0,7), "CouchDB"));
});

@@ -190,3 +194,5 @@ // hello update world (no docid)

T(xhr.status == 200);
T(xhr.responseText.length == 32);
skip("CouchDB uuid length !== PouchDB server uuid length", function () {
T(xhr.responseText.length == 32);
});

@@ -210,2 +216,3 @@ // COUCHDB-1229 - allow slashes in doc ids for update handlers

warn("Difference from original CouchDB code in code-n-bump, resp-code & resp-code-and-json: 'var resp =' instead of 'resp ='");
xhr = CouchDB.request("PUT", "/test_suite_db/_design/update/_update/code-n-bump/"+docid, {

@@ -237,5 +244,7 @@ headers : {"X-Couch-Full-Commit":"true"}

xhr = CouchDB.request("PUT", "/test_suite_db/_design/update/_update/empty/foo");
TEquals(400, xhr.status);
TEquals("Document id must not be empty", JSON.parse(xhr.responseText).reason);
skip("PouchDB-Server gives a 412 & a similar (but not the same) error message. Not sure if worth replacing.", function () {
TEquals(400, xhr.status);
TEquals("Document id must not be empty", JSON.parse(xhr.responseText).reason);
});
};
{
"name": "couchdb-harness",
"version": "0.1.3",
"version": "0.1.4",
"description": "A generalized port of the CouchDB JavaScript test harness.",

@@ -5,0 +5,0 @@ "repository": {

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