couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From beno...@apache.org
Subject svn commit: r986854 - in /couchdb/trunk: share/www/script/test/list_views.js share/www/script/test/show_documents.js src/couchdb/couch_httpd_external.erl
Date Wed, 18 Aug 2010 18:54:40 GMT
Author: benoitc
Date: Wed Aug 18 18:54:40 2010
New Revision: 986854

URL: http://svn.apache.org/viewvc?rev=986854&view=rev
Log:
expose security obj to shows, lists & updates functions.

Modified:
    couchdb/trunk/share/www/script/test/list_views.js
    couchdb/trunk/share/www/script/test/show_documents.js
    couchdb/trunk/src/couchdb/couch_httpd_external.erl

Modified: couchdb/trunk/share/www/script/test/list_views.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/list_views.js?rev=986854&r1=986853&r2=986854&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/list_views.js (original)
+++ couchdb/trunk/share/www/script/test/list_views.js Wed Aug 18 18:54:40 2010
@@ -156,6 +156,9 @@ couchTests.list_views = function(debug) 
         var row = getRow();
         send(row.doc.integer);
         return "tail";
+      }),
+      secObj: stringFun(function(head, req) {
+        return toJSON(req.secObj);
       })
     }
   };
@@ -201,6 +204,7 @@ couchTests.list_views = function(debug) 
   T(xhr.status == 200, "standard get should be 200");
   T(/head0123456789tail/.test(xhr.responseText));
 
+
   // test that etags are available
   var etag = xhr.getResponseHeader("etag");
   xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/basicBasic/basicView",
{
@@ -405,6 +409,12 @@ couchTests.list_views = function(debug) 
   T(/FirstKey: -2/.test(xhr.responseText));
   T(/LastKey: -7/.test(xhr.responseText));
 
+    // Test if secObj is available
+  var xhr = CouchDB.request("GET", "/test_suite_db/_design/lists/_list/secObj/basicView");
+  T(xhr.status == 200, "standard get should be 200");
+  var resp = JSON.parse(xhr.responseText);
+  T(typeof(resp) == "object");
+
   var erlViewTest = function() {
     T(db.save(erlListDoc).ok);
     var url = "/test_suite_db/_design/erlang/_list/simple/views/basicView" +
@@ -419,6 +429,8 @@ couchTests.list_views = function(debug) 
     }
   };
 
+  
+
   run_on_modified_server([{
     section: "native_query_servers",
     key: "erlang",

Modified: couchdb/trunk/share/www/script/test/show_documents.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/show_documents.js?rev=986854&r1=986853&r2=986854&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/show_documents.js (original)
+++ couchdb/trunk/share/www/script/test/show_documents.js Wed Aug 18 18:54:40 2010
@@ -157,6 +157,9 @@ couchTests.show_documents = function(deb
       }),
       "withSlash": stringFun(function(doc, req) {
         return { json: doc }
+      }),
+      "secObj": stringFun(function(doc, req) {
+        return { json: req.secObj };
       })
     }
   };
@@ -410,5 +413,24 @@ couchTests.show_documents = function(deb
   db.deleteDoc(doc);
   var xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/show-deleted/testdoc");
   TEquals("No doc testdoc", xhr.responseText, "should return 'no doc testdoc'");
+
+
+  run_on_modified_server(
+    [{section: "httpd",
+      key: "authentication_handlers",
+      value: "{couch_httpd_auth, special_test_authentication_handler}"},
+     {section:"httpd",
+      key: "WWW-Authenticate",
+      value:  "X-Couch-Test-Auth"}],
+
+      function() {
+        T(db.setDbProperty("_security", {foo: true}).ok);
+        T(db.save(doc).ok);
+
+        xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/secObj");
+        var resp = JSON.parse(xhr.responseText);
+        T(resp.foo == true);
+      }
+  );
   
 };

Modified: couchdb/trunk/src/couchdb/couch_httpd_external.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_external.erl?rev=986854&r1=986853&r2=986854&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_external.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_external.erl Wed Aug 18 18:54:40 2010
@@ -73,7 +73,8 @@ json_req_obj(#httpd{mochi_req=Req,
     Headers = Req:get(headers),
     Hlist = mochiweb_headers:to_list(Headers),
     {ok, Info} = couch_db:get_db_info(Db),
-    % add headers...
+    
+% add headers...
     {[{<<"info">>, {Info}},
         {<<"id">>, DocId},
         {<<"uuid">>, couch_uuids:new()},
@@ -86,7 +87,8 @@ json_req_obj(#httpd{mochi_req=Req,
         {<<"peer">>, ?l2b(Req:get(peer))},
         {<<"form">>, to_json_terms(ParsedForm)},
         {<<"cookie">>, to_json_terms(Req:parse_cookie())},
-        {<<"userCtx">>, couch_util:json_user_ctx(Db)}]}.
+        {<<"userCtx">>, couch_util:json_user_ctx(Db)},
+        {<<"secObj">>, couch_db:get_security(Db)}]}.
 
 to_json_terms(Data) ->
     to_json_terms(Data, []).



Mime
View raw message