You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by fd...@apache.org on 2012/01/23 00:43:14 UTC

[46/50] git commit: fix whitespace

fix whitespace


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/e2e7e15e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/e2e7e15e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/e2e7e15e

Branch: refs/heads/COUCHDB-1342
Commit: e2e7e15eec3e78fdb896601872181bcd1c4f6223
Parents: ee19fd9
Author: Jan Lehnardt <ja...@apache.org>
Authored: Fri Nov 25 20:13:12 2011 +0100
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Tue Jan 3 19:21:23 2012 +0100

----------------------------------------------------------------------
 share/www/script/test/cookie_auth.js |   45 +++++++++++++++--------------
 1 files changed, 23 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/e2e7e15e/share/www/script/test/cookie_auth.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/cookie_auth.js b/share/www/script/test/cookie_auth.js
index a3fbb7a..ffedba7 100644
--- a/share/www/script/test/cookie_auth.js
+++ b/share/www/script/test/cookie_auth.js
@@ -12,7 +12,7 @@
 
 couchTests.cookie_auth = function(debug) {
   // This tests cookie-based authentication.
-  
+
   var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"false"});
   db.deleteDb();
   db.createDb();
@@ -34,13 +34,14 @@ couchTests.cookie_auth = function(debug) {
       // try using an invalid cookie
       var usersDb = new CouchDB("test_suite_users", {"X-Couch-Full-Commit":"false"});
       usersDb.deleteDb();
-      
+      usersDb.createDb();
+
       // test that the users db is born with the auth ddoc
       var ddoc = usersDb.open("_design/_auth");
       T(ddoc.validate_doc_update);
-      
+
       // TODO test that changing the config so an existing db becomes the users db installs the ddoc also
-      
+
       var password = "3.141592653589";
 
       // Create a user
@@ -48,11 +49,11 @@ couchTests.cookie_auth = function(debug) {
         name: "Jason Davies",
         roles: ["dev"]
       }, password);
-      T(usersDb.save(jasonUserDoc).ok);      
-      
+      T(usersDb.save(jasonUserDoc).ok);
+
       var checkDoc = usersDb.open(jasonUserDoc._id);
       T(checkDoc.name == "Jason Davies");
-      
+
       var jchrisUserDoc = CouchDB.prepareUserDoc({
         name: "jchris@apache.org"
       }, "funnybone");
@@ -70,7 +71,7 @@ couchTests.cookie_auth = function(debug) {
         T(e.error == "conflict");
         T(usersDb.last_req.status == 409);
       }
-      
+
       // we can't create _names
       var underscoreUserDoc = CouchDB.prepareUserDoc({
         name: "_why"
@@ -83,12 +84,12 @@ couchTests.cookie_auth = function(debug) {
         T(e.error == "forbidden");
         T(usersDb.last_req.status == 403);
       }
-      
+
       // we can't create docs with malformed ids
       var badIdDoc = CouchDB.prepareUserDoc({
         name: "foo"
       }, "bar");
-      
+
       badIdDoc._id = "org.apache.couchdb:w00x";
 
       try {
@@ -98,11 +99,11 @@ couchTests.cookie_auth = function(debug) {
         T(e.error == "forbidden");
         T(usersDb.last_req.status == 403);
       }
-      
+
       // login works
       T(CouchDB.login('Jason Davies', password).ok);
       T(CouchDB.session().userCtx.name == 'Jason Davies');
-      
+
       // JSON login works
       var xhr = CouchDB.request("POST", "/_session", {
         headers: {"Content-Type": "application/json"},
@@ -156,12 +157,12 @@ couchTests.cookie_auth = function(debug) {
        }
 
       // test users db validations
-      // 
+      //
       // test that you can't update docs unless you are logged in as the user (or are admin)
       T(CouchDB.login("jchris@apache.org", "funnybone").ok);
       T(CouchDB.session().userCtx.name == "jchris@apache.org");
       T(CouchDB.session().userCtx.roles.length == 0);
-      
+
       jasonUserDoc.foo=3;
 
       try {
@@ -174,7 +175,7 @@ couchTests.cookie_auth = function(debug) {
 
       // test that you can't edit roles unless you are admin
       jchrisUserDoc.roles = ["foo"];
-      
+
       try {
         usersDb.save(jchrisUserDoc);
         T(false && "Can't set roles unless you are admin. Should have thrown an error.");
@@ -182,16 +183,16 @@ couchTests.cookie_auth = function(debug) {
         T(e.error == "forbidden");
         T(usersDb.last_req.status == 403);
       }
-      
+
       T(CouchDB.logout().ok);
-      T(CouchDB.session().userCtx.roles[0] == "_admin");      
+      T(CouchDB.session().userCtx.roles[0] == "_admin");
 
       jchrisUserDoc.foo = ["foo"];
       T(usersDb.save(jchrisUserDoc).ok);
 
       // test that you can't save system (underscore) roles even if you are admin
       jchrisUserDoc.roles = ["_bar"];
-      
+
       try {
         usersDb.save(jchrisUserDoc);
         T(false && "Can't add system roles to user's db. Should have thrown an error.");
@@ -199,18 +200,18 @@ couchTests.cookie_auth = function(debug) {
         T(e.error == "forbidden");
         T(usersDb.last_req.status == 403);
       }
-      
+
       // make sure the foo role has been applied
       T(CouchDB.login("jchris@apache.org", "funnybone").ok);
       T(CouchDB.session().userCtx.name == "jchris@apache.org");
       T(CouchDB.session().userCtx.roles.indexOf("_admin") == -1);
       T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);
-      
+
       // now let's make jchris a server admin
       T(CouchDB.logout().ok);
       T(CouchDB.session().userCtx.roles[0] == "_admin");
       T(CouchDB.session().userCtx.name == null);
-      
+
       // set the -hashed- password so the salt matches
       // todo ask on the ML about this
       run_on_modified_server([{section: "admins",
@@ -236,7 +237,7 @@ couchTests.cookie_auth = function(debug) {
           T(s.info.authentication_db == "test_suite_users");
           // test that jchris still has the foo role
           T(CouchDB.session().userCtx.roles.indexOf("foo") != -1);
-        });      
+        });
 
     } finally {
       // Make sure we erase any auth cookies so we don't affect other tests