COUCHDB-1511 - User docs require doc.roles
A _users doc must include roles otherwise the user receives an opaque
error. This patch throws an error if it is missing and adds a test to
verify that the user receives a readable error message.
diff --git a/script/test/users_db.js b/script/test/users_db.js
index 7648523..44e6c88 100644
--- a/script/test/users_db.js
+++ b/script/test/users_db.js
@@ -112,6 +112,16 @@
}
jchrisUserDoc.roles = [];
+ // "roles" must exist
+ delete jchrisUserDoc.roles;
+ try {
+ usersDb.save(jchrisUserDoc);
+ T(false && "should only allow us to save doc when roles exists");
+ } catch(e) {
+ T(e.reason == "doc.roles must exist");
+ }
+ jchrisUserDoc.roles = [];
+
// character : is not allowed in usernames
var joeUserDoc = CouchDB.prepareUserDoc({
name: "joe:erlang"