You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by jh...@apache.org on 2012/02/29 12:09:58 UTC
[5/9] git commit: Tighten and simplify Ryan's rewrite/vhost tests
Tighten and simplify Ryan's rewrite/vhost tests
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/0ab41ad1
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/0ab41ad1
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/0ab41ad1
Branch: refs/heads/COUCHDB-1416
Commit: 0ab41ad1ec96858d96561c7a82077292c67f3d49
Parents: 2696850
Author: Jason Smith (air) <jh...@apache.org>
Authored: Wed Feb 29 16:57:13 2012 +0700
Committer: Jason Smith (air) <jh...@apache.org>
Committed: Wed Feb 29 16:57:13 2012 +0700
----------------------------------------------------------------------
share/www/script/test/rewrite.js | 85 ++++++++++++++-------------------
1 files changed, 36 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/0ab41ad1/share/www/script/test/rewrite.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/rewrite.js b/share/www/script/test/rewrite.js
index a30cd4f..36ab87e 100644
--- a/share/www/script/test/rewrite.js
+++ b/share/www/script/test/rewrite.js
@@ -437,57 +437,44 @@ couchTests.rewrite = function(debug) {
var res = CouchDB.request("GET", "/test_suite_db/_design/invalid/_rewrite/foo");
TEquals(400, res.status, "should return 400");
- // test req.requested_path with rewrites with some vhosts
- var rw_ddoc = {
- _id: "_design/rwtest",
- rewrites: [
- {"from":"testShow","to":"_show/show_requested_path"}
- ],
- shows : {
- show_requested_path : stringFun(function(doc, req){
- return '/' + req.requested_path.join('/');
- })
+ // Test req.requested_path with rewrites with some vhosts
+ run_on_modified_server([{section:'httpd', key:'secure_rewrites', value:'false'}],
+ function() {
+ var rw_ddoc = {
+ _id: "_design/rwtest",
+ rewrites: [
+ {"from":"testShow","to":"_show/show_requested_path"},
+ {"from":"_config/*","to":"../../../_config/*"}
+ ],
+ shows : {
+ show_requested_path : stringFun(function(doc, req){
+ return '/' + req.requested_path.join('/');
+ })
+ }
}
- }
- db.save(rw_ddoc);
- // try accessing directly
- var res = CouchDB.request("GET", "/test_suite_db/_design/rwtest/_rewrite/testShow");
- TEquals('/test_suite_db/_design/rwtest/_rewrite/testShow', res.responseText, "requested_path should equal requested");
+ T(db.save(rw_ddoc).ok);
- // test a vhost with a path as well
- run_on_modified_server(
- [{section: "vhosts",
- key: encodeURIComponent(CouchDB.host + '/path'),
- value: "/test_suite_db/_design/rwtest/_rewrite/"}
- ],
- function(){
- var res = CouchDB.request("GET", "/path/testShow");
- TEquals('/path/testShow', res.responseText, "requested_path should equal requested");
- }
- );
+ // try accessing directly
+ var res = CouchDB.request("GET", "/test_suite_db/_design/rwtest/_rewrite/testShow");
+ TEquals('/test_suite_db/_design/rwtest/_rewrite/testShow',
+ res.responseText, "requested_path should equal requested");
- // test a vhost on the root of the host
- rw_ddoc.rewrites.push({"from":"_config/*","to":"../../../_config/*"});
- T(db.save(rw_ddoc).ok);
- run_on_modified_server(
- [{section: "httpd",
- key: "secure_rewrites",
- value: "false"}
- ],
- function(){
- // we have to 'double wrap' with a run_on_modified_server
- // so that vhosts gets remove first, then the secure_rewrite
- run_on_modified_server(
- [{section: "vhosts",
- key: encodeURIComponent(CouchDB.host),
- value: "/test_suite_db/_design/rwtest/_rewrite/"}
- ],
- function() {
- var res = CouchDB.request("GET", "/testShow");
- TEquals('/testShow', res.responseText, "requested_path should equal requested");
- }
- );
- }
- );
+ // test a vhost with a path as well
+ var vhosts = {section:'vhosts',
+ key:encodeURIComponent(CouchDB.host + '/path'),
+ value:"/test_suite_db/_design/rwtest/_rewrite/"};
+
+ run_on_modified_server([vhosts], function() {
+ var res = CouchDB.request("GET", "/path/testShow");
+ TEquals('/path/testShow', res.responseText, "requested_path should equal requested");
+ });
+
+ // test a vhost on the root of the host
+ vhosts.key = encodeURIComponent(CouchDB.host);
+ run_on_modified_server([vhosts], function() {
+ var res = CouchDB.request("GET", "/testShow");
+ TEquals('/testShow', res.responseText, "requested_path should equal requested");
+ });
+ });
}