You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by be...@apache.org on 2012/11/05 06:02:38 UTC
[3/3] git commit: Add a test for wildcard based origin
Add a test for wildcard based origin
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/cae8e162
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/cae8e162
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/cae8e162
Branch: refs/heads/431-feature_cors
Commit: cae8e162c2ed51ce44dddc0b613d6a01109d0515
Parents: e70e4fa
Author: Dale Harvey <da...@arandomurl.com>
Authored: Sun Nov 4 18:34:58 2012 -0800
Committer: Dale Harvey <da...@arandomurl.com>
Committed: Sun Nov 4 18:34:58 2012 -0800
----------------------------------------------------------------------
test/etap/231_cors.t | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/cae8e162/test/etap/231_cors.t
----------------------------------------------------------------------
diff --git a/test/etap/231_cors.t b/test/etap/231_cors.t
index 72fc3df..85867be 100644
--- a/test/etap/231_cors.t
+++ b/test/etap/231_cors.t
@@ -32,7 +32,7 @@ server() ->
main(_) ->
test_util:init_code_path(),
- etap:plan(11),
+ etap:plan(12),
case (catch test()) of
ok ->
etap:end_tests();
@@ -89,6 +89,10 @@ test() ->
test_db_origin_request(),
test_db1_origin_request(),
+ ok = couch_config:set("cors", "origins", "*", false),
+ test_preflight_with_wildcard(),
+ ok = couch_config:set("cors", "origins", "http://example.com", false),
+
%% do tests with auth
ok = set_admin_password("test", "test"),
@@ -228,3 +232,16 @@ test_db_origin_auth_request() ->
_ ->
etap:is(false, true, "ibrowse failed")
end.
+
+test_preflight_with_wildcard() ->
+ Headers = [{"Origin", "http://example.com"},
+ {"Access-Control-Request-Method", "GET"}],
+ case ibrowse:send_req(server(), Headers, options, []) of
+ {ok, _, RespHeaders, _} ->
+ % I would either expect the current origin or a wildcard to be returned
+ etap:is(proplists:get_value("Access-Control-Allow-Origin", RespHeaders),
+ "http://example.com",
+ "db origin ok");
+ _ ->
+ etap:is(false, true, "ibrowse failed")
+ end.