You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by jc...@apache.org on 2010/07/29 08:04:03 UTC

svn commit: r980319 - in /couchdb/trunk: share/www/script/test/security_validation.js src/couchdb/couch_db.erl

Author: jchris
Date: Thu Jul 29 06:04:03 2010
New Revision: 980319

URL: http://svn.apache.org/viewvc?rev=980319&view=rev
Log:
fix the underlying issue that was giving replication problems attempting to push design docs as a non-admin. this is what my reverted commit should have been

Modified:
    couchdb/trunk/share/www/script/test/security_validation.js
    couchdb/trunk/src/couchdb/couch_db.erl

Modified: couchdb/trunk/share/www/script/test/security_validation.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/security_validation.js?rev=980319&r1=980318&r2=980319&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/security_validation.js (original)
+++ couchdb/trunk/share/www/script/test/security_validation.js Thu Jul 29 06:04:03 2010
@@ -111,6 +111,18 @@ couchTests.security_validation = functio
 
       T(userDb.save(designDoc).ok);
 
+      var user2Db = new CouchDB("test_suite_db",
+        {"WWW-Authenticate": "X-Couch-Test-Auth Jan Lehnardt:apple"}
+      );
+      // Attempt to save the design as a non-admin (in replication scenario)
+      try {
+        user2Db.save(designDoc, {new_edits : false});
+        T(false && "Can't get here. Should have thrown an error on design doc");
+      } catch (e) {
+        T(e.error == "unauthorized");
+        T(user2Db.last_req.status == 401);
+      }
+
       // test the _session API
       var resp = userDb.request("GET", "/_session");
       var user = JSON.parse(resp.responseText).userCtx;
@@ -134,10 +146,6 @@ couchTests.security_validation = functio
       }
 
       // Now attempt to update the document as a different user, Jan
-      var user2Db = new CouchDB("test_suite_db",
-        {"WWW-Authenticate": "X-Couch-Test-Auth Jan Lehnardt:apple"}
-      );
-
       var doc = user2Db.open("testdoc");
       doc.foo=3;
       try {

Modified: couchdb/trunk/src/couchdb/couch_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db.erl?rev=980319&r1=980318&r2=980319&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db.erl Thu Jul 29 06:04:03 2010
@@ -368,6 +368,8 @@ update_doc(Db, Doc, Options, UpdateType)
     case update_docs(Db, [Doc], Options, UpdateType) of
     {ok, [{ok, NewRev}]} ->
         {ok, NewRev};
+    {ok, [{{_Id, _Rev}, Error}]} ->
+        throw(Error);
     {ok, [Error]} ->
         throw(Error);
     {ok, []} ->