diff options
author | Benoit Chesneau <benoitc@apache.org> | 2010-08-17 04:11:02 +0000 |
---|---|---|
committer | Benoit Chesneau <benoitc@apache.org> | 2010-08-17 04:11:02 +0000 |
commit | 84ad2322c28a4d40463dbe031ee0778d50d6b18a (patch) | |
tree | 60700763c0b4c34ab2d99e8a4989edac722a596e /test | |
parent | 64da83d7ae72bb23030c3b5c0e810225e09cb706 (diff) |
New vhost manager. allows dynamic add of vhosts without restart,
wildcard in vhost and dynamic routing via pattern matching. Close
#COUCHDB-855.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@986182 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rwxr-xr-x | test/etap/160-vhosts.t | 65 |
1 files changed, 59 insertions, 6 deletions
diff --git a/test/etap/160-vhosts.t b/test/etap/160-vhosts.t index 45b3f893..b1050d7f 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(6), + etap:plan(10), case (catch test()) of ok -> etap:end_tests(); @@ -69,6 +69,7 @@ test() -> ibrowse:start(), crypto:start(), + timer:sleep(1000), couch_server:delete(list_to_binary(dbname()), [admin_user_ctx()]), {ok, Db} = couch_db:create(list_to_binary(dbname()), [admin_user_ctx()]), @@ -101,9 +102,16 @@ test() -> %% end boilerplate, start test - couch_config:set("vhosts", "example.com", "/etap-test-db", false), - couch_config:set("vhosts", "example1.com", -"/etap-test-db/_design/doc1/_rewrite/", false), + 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", "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), + test_regular_request(), test_vhost_request(), @@ -111,10 +119,16 @@ test() -> test_vhost_request_with_global(), test_vhost_requested_path(), test_vhost_requested_path_path(), + test_vhost_request_wildcard(), + test_vhost_request_replace_var(), + test_vhost_request_replace_var1(), + test_vhost_request_replace_wildcard(), %% restart boilerplate couch_db:close(Db), - couch_server:delete(list_to_binary(dbname()), []), + timer:sleep(3000), + couch_server_sup:stop(), + ok. test_regular_request() -> @@ -166,7 +180,6 @@ test_vhost_requested_path() -> _Else -> false end. - test_vhost_requested_path_path() -> case ibrowse:send_req(server(), [], get, [], [{host_header, "example1.com"}]) of {ok, _, _, Body} -> @@ -178,3 +191,43 @@ test_vhost_requested_path_path() -> _Else -> false end. +test_vhost_request_wildcard()-> + case ibrowse:send_req(server(), [], get, [], [{host_header, "test.example.com"}]) 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, <<"wildcard ok">>); + _Else -> false + end. + + +test_vhost_request_replace_var() -> + case ibrowse:send_req(server(), [], get, [], [{host_header,"etap-test-db.example1.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_replace_var1() -> + case ibrowse:send_req(server(), [], get, [], [{host_header, "doc1.etap-test-db.example1.com"}]) 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, <<"wildcard ok">>); + _Else -> false + end. + +test_vhost_request_replace_wildcard() -> + case ibrowse:send_req(server(), [], 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. |