summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--share/www/script/test/list_views.js12
-rw-r--r--share/www/script/test/show_documents.js22
-rw-r--r--src/couchdb/couch_httpd_external.erl6
3 files changed, 38 insertions, 2 deletions
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);
+ }
+ );
};
diff --git a/src/couchdb/couch_httpd_external.erl b/src/couchdb/couch_httpd_external.erl
index 84ac44d3..f8d6f171 100644
--- a/src/couchdb/couch_httpd_external.erl
+++ b/src/couchdb/couch_httpd_external.erl
@@ -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, []).