couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject svn commit: r1033640 - in /couchdb/trunk: share/www/script/test/security_validation.js src/couchdb/couch_db_updater.erl
Date Wed, 10 Nov 2010 18:44:45 GMT
Author: rnewson
Date: Wed Nov 10 18:44:45 2010
New Revision: 1033640

URL: http://svn.apache.org/viewvc?rev=1033640&view=rev
Log:
COUCHDB-945 - ensure validation funs are still applied after compaction.

Modified:
    couchdb/trunk/share/www/script/test/security_validation.js
    couchdb/trunk/src/couchdb/couch_db_updater.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=1033640&r1=1033639&r2=1033640&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/security_validation.js (original)
+++ couchdb/trunk/share/www/script/test/security_validation.js Wed Nov 10 18:44:45 2010
@@ -136,13 +136,20 @@ couchTests.security_validation = functio
       doc.foo=2;
       T(userDb.save(doc).ok);
 
-      // Save a document that's missing an author field.
-      try {
-        userDb.save({foo:1});
-        T(false && "Can't get here. Should have thrown an error 2");
-      } catch (e) {
-        T(e.error == "forbidden");
-        T(userDb.last_req.status == 403);
+      // Save a document that's missing an author field (before and after compaction)
+      for (var i=0; i<2; i++) {
+          try {
+              userDb.save({foo:1});
+              T(false && "Can't get here. Should have thrown an error 2");
+          } catch (e) {
+              T(e.error == "forbidden");
+              T(userDb.last_req.status == 403);
+          }
+          // compact.
+          T(db.compact().ok);
+          T(db.last_req.status == 202);
+          // compaction isn't instantaneous, loop until done
+          while (db.info().compact_running) {};
       }
 
       // Now attempt to update the document as a different user, Jan

Modified: couchdb/trunk/src/couchdb/couch_db_updater.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db_updater.erl?rev=1033640&r1=1033639&r2=1033640&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db_updater.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db_updater.erl Wed Nov 10 18:44:45 2010
@@ -186,9 +186,10 @@ handle_cast({compact_done, CompactFilepa
         couch_file:delete(RootDir, Filepath),
         ok = file:rename(CompactFilepath, Filepath),
         close_db(Db),
-        ok = gen_server:call(Db#db.main_pid, {db_updated, NewDb2}, infinity),
+        NewDb3 = refresh_validate_doc_funs(NewDb2),
+        ok = gen_server:call(Db#db.main_pid, {db_updated, NewDb3}, infinity),
         ?LOG_INFO("Compaction for db \"~s\" completed.", [Db#db.name]),
-        {noreply, NewDb2#db{compactor_pid=nil}};
+        {noreply, NewDb3#db{compactor_pid=nil}};
     false ->
         ?LOG_INFO("Compaction file still behind main file "
             "(update seq=~p. compact update seq=~p). Retrying.",



Mime
View raw message