summaryrefslogtreecommitdiff
path: root/test/etap
diff options
context:
space:
mode:
Diffstat (limited to 'test/etap')
-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.