From 6bebee4e85ba211212a9ed3b270077f050214911 Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Wed, 3 Feb 2010 17:29:41 +0000 Subject: enhance reader and admin lists git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@906138 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/test/reader_acl.js | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'share') diff --git a/share/www/script/test/reader_acl.js b/share/www/script/test/reader_acl.js index 58f3d001..a5fc6a1a 100644 --- a/share/www/script/test/reader_acl.js +++ b/share/www/script/test/reader_acl.js @@ -49,8 +49,23 @@ couchTests.reader_acl = function(debug) { T(true) } + CouchDB.logout(); + + // make top-secret an admin + T(secretDb.setDbProperty("_admins", { + roles : ["top-secret"], + names : []}).ok); + + T(CouchDB.login("jchris@apache.org", "funnybone").ok); + + T(secretDb.open("baz").foo == "bar"); + CouchDB.logout(); + T(secretDb.setDbProperty("_admins", { + roles : [], + names : []}).ok); + // admin now adds the top-secret role to the db's readers T(CouchDB.session().userCtx.roles.indexOf("_admin") != -1); @@ -67,18 +82,26 @@ couchTests.reader_acl = function(debug) { // can't set non string reader names or roles try { - T(!secretDb.setDbProperty("_readers", { + secretDb.setDbProperty("_readers", { roles : ["super-secret-club", {"top-secret":"awesome"}], - names : ["joe","barb"]}).ok); + names : ["joe","barb"]}); T(false && "only string roles"); } catch (e) {} try { - T(!secretDb.setDbProperty("_readers", { - roles : ["super-secret-club", "top-secret"], - names : ["joe",22]}).ok); + secretDb.setDbProperty("_readers", { + roles : ["super-secret-club", "top-secret"], + names : ["joe",22]}); T(false && "only string names"); - } catch (e) {} + } catch (e) {} + + try { + secretDb.setDbProperty("_readers", { + roles : ["super-secret-club", "top-secret"], + names : "joe" + }); + T(false && "only lists of names"); + } catch (e) {} } finally { CouchDB.logout(); } -- cgit v1.2.3