Author: jchris Date: Thu Jul 29 06:05:01 2010 New Revision: 980320 URL: http://svn.apache.org/viewvc?rev=980320&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/branches/1.0.x/share/www/script/test/security_validation.js couchdb/branches/1.0.x/src/couchdb/couch_db.erl Modified: couchdb/branches/1.0.x/share/www/script/test/security_validation.js URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/share/www/script/test/security_validation.js?rev=980320&r1=980319&r2=980320&view=diff ============================================================================== --- couchdb/branches/1.0.x/share/www/script/test/security_validation.js (original) +++ couchdb/branches/1.0.x/share/www/script/test/security_validation.js Thu Jul 29 06:05:01 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/branches/1.0.x/src/couchdb/couch_db.erl URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_db.erl?rev=980320&r1=980319&r2=980320&view=diff ============================================================================== --- couchdb/branches/1.0.x/src/couchdb/couch_db.erl (original) +++ couchdb/branches/1.0.x/src/couchdb/couch_db.erl Thu Jul 29 06:05:01 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, []} ->