summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBenoit Chesneau <benoitc@apache.org>2010-09-07 23:35:28 +0000
committerBenoit Chesneau <benoitc@apache.org>2010-09-07 23:35:28 +0000
commitec75b49cc9385495d6fa40cac50f825def9433d8 (patch)
tree20d16a32c2a8756b99b49d4255e2e199bef46421 /test
parentc1b74df08076cd850617e500163fdb5fc8d55f3a (diff)
fix issue #COUCHDB-230 . now it's possible to do */test =
/db/_design/test or even example.com/test = /db/_design/test and other stuff already possible with vhost manager. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@993558 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rwxr-xr-xtest/etap/160-vhosts.t57
1 files changed, 54 insertions, 3 deletions
diff --git a/test/etap/160-vhosts.t b/test/etap/160-vhosts.t
index 7eaf2874..aea2e829 100755
--- a/test/etap/160-vhosts.t
+++ b/test/etap/160-vhosts.t
@@ -54,7 +54,7 @@ config_files() ->
main(_) ->
test_util:init_code_path(),
- etap:plan(10),
+ etap:plan(14),
case (catch test()) of
ok ->
etap:end_tests();
@@ -105,13 +105,18 @@ test() ->
ok = couch_config:set("vhosts", "example.com", "/etap-test-db", false),
ok = couch_config:set("vhosts", "*.example.com",
"/etap-test-db/_design/doc1/_rewrite", false),
+ ok = couch_config:set("vhosts", "example.com/test", "/etap-test-db", false),
ok = couch_config:set("vhosts", "example1.com",
"/etap-test-db/_design/doc1/_rewrite/", false),
ok = couch_config:set("vhosts",":appname.:dbname.example1.com",
"/:dbname/_design/:appname/_rewrite/", false),
ok = couch_config:set("vhosts", ":dbname.example1.com", "/:dbname", false),
+
ok = couch_config:set("vhosts", "*.example2.com", "/*", false),
-
+ ok = couch_config:set("vhosts", "*/test", "/etap-test-db", false),
+ ok = couch_config:set("vhosts", "*.example2.com/test", "/*", false),
+ ok = couch_config:set("vhosts", "*/test1",
+ "/etap-test-db/_design/doc1/_show/test", false),
test_regular_request(),
test_vhost_request(),
@@ -123,7 +128,11 @@ test() ->
test_vhost_request_replace_var(),
test_vhost_request_replace_var1(),
test_vhost_request_replace_wildcard(),
-
+ test_vhost_request_path(),
+ test_vhost_request_path1(),
+ test_vhost_request_path2(),
+ test_vhost_request_path3(),
+
%% restart boilerplate
couch_db:close(Db),
timer:sleep(3000),
@@ -231,3 +240,45 @@ test_vhost_request_replace_wildcard() ->
etap:is(true, true, "should return database info");
_Else -> false
end.
+
+test_vhost_request_path() ->
+ Uri = server() ++ "test",
+ case ibrowse:send_req(Uri, [], get, [], [{host_header, "example.com"}]) of
+ {ok, _, _, Body} ->
+ {[{<<"db_name">>, <<"etap-test-db">>},_,_,_,_,_,_,_,_,_]}
+ = couch_util:json_decode(Body),
+ etap:is(true, true, "should return database info");
+ _Else -> false
+ end.
+
+test_vhost_request_path1() ->
+ Url = server() ++ "test/doc1?revs_info=true",
+ case ibrowse:send_req(Url, [], get, [], []) of
+ {ok, _, _, Body} ->
+ {JsonProps} = couch_util:json_decode(Body),
+ HasRevsInfo = proplists:is_defined(<<"_revs_info">>, JsonProps),
+ etap:is(HasRevsInfo, true, "should return _revs_info");
+ _Else -> false
+ end.
+
+test_vhost_request_path2() ->
+ Uri = server() ++ "test",
+ case ibrowse:send_req(Uri, [], get, [], [{host_header,"etap-test-db.example2.com"}]) of
+ {ok, _, _, Body} ->
+ {[{<<"db_name">>, <<"etap-test-db">>},_,_,_,_,_,_,_,_,_]}
+ = couch_util:json_decode(Body),
+ etap:is(true, true, "should return database info");
+ _Else -> false
+ end.
+
+test_vhost_request_path3() ->
+ Uri = server() ++ "test1",
+ case ibrowse:send_req(Uri, [], get, [], []) of
+ {ok, _, _, Body} ->
+ {Json} = couch_util:json_decode(Body),
+ etap:is(case proplists:get_value(<<"path">>, Json) of
+ <<"/etap-test-db/_design/doc1/_show/test">> -> true;
+ _ -> false
+ end, true, <<"path in req ok">>);
+ _Else -> false
+ end.