diff options
author | Damien F. Katz <damien@apache.org> | 2009-02-11 16:08:38 +0000 |
---|---|---|
committer | Damien F. Katz <damien@apache.org> | 2009-02-11 16:08:38 +0000 |
commit | 59f41c2678f59a2effade9651c0de11bbe811c56 (patch) | |
tree | 7a4ecf30fae7478a98d1cd5be55f09241bca43c6 /share/www/script | |
parent | 3132843214251e3a68b7b3fe89618d323dffa546 (diff) |
Fix for COUCHDB-238, explicit check and error for doc ids starting with underscore.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@743371 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script')
-rw-r--r-- | share/www/script/couch_tests.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index 2df262d7..55a63bc9 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -1482,6 +1482,49 @@ db.createDb(); T(db.view("test/no_docs") == null); }, + invalid_docids: function(debug) { + var db = new CouchDB("test_suite_db"); + db.deleteDb(); + db.createDb(); + if (debug) debugger; + + // Test _local explicitly first. + T(db.save({"_id": "_local/foo"}).ok); + T(db.open("_local/foo")._id == "_local/foo"); + + //Test non-string + try { + db.save({"_id": 1}); + T(1 == 0); + } catch(e) { + T(db.last_req.status == 400); + T(e.error == "invalid_doc"); + } + + // Test invalid _prefix + try { + db.save({"_id": "_invalid"}); + T(1 == 0); + } catch(e) { + T(db.last_req.status == 400); + T(e.error == "invalid_doc"); + } + + // Test _bulk_docs explicitly. + var docs = [{"_id": "_design/foo"}, {"_id": "_local/bar"}]; + T(db.bulkSave(docs).ok); + docs.forEach(function(d) {T(db.open(d._id)._id == d._id);}); + + docs = [{"_id": "_invalid"}]; + try { + db.bulkSave(docs); + T(1 == 0); + } catch(e) { + T(db.last_req.status == 400); + T(e.error == "invalid_doc"); + } + }, + view_collation: function(debug) { var db = new CouchDB("test_suite_db"); db.deleteDb(); |