From 1f729f7f261f9607b74b6c8723e190720db8dc32 Mon Sep 17 00:00:00 2001 From: Benoit Chesneau Date: Wed, 18 Aug 2010 18:54:40 +0000 Subject: expose security obj to shows, lists & updates functions. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@986854 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/test/list_views.js | 12 ++++++++++++ share/www/script/test/show_documents.js | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+) (limited to 'share/www') diff --git a/share/www/script/test/list_views.js b/share/www/script/test/list_views.js index f826b46f..048fc5e3 100644 --- a/share/www/script/test/list_views.js +++ b/share/www/script/test/list_views.js @@ -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", diff --git a/share/www/script/test/show_documents.js b/share/www/script/test/show_documents.js index e06bcadc..55ed9698 100644 --- a/share/www/script/test/show_documents.js +++ b/share/www/script/test/show_documents.js @@ -157,6 +157,9 @@ couchTests.show_documents = function(debug) { }), "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(debug) { 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); + } + ); }; -- cgit v1.2.3