You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2012/12/04 21:43:49 UTC
[32/44] git commit: check the scheme as well
check the scheme as well
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d4f547f8
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d4f547f8
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d4f547f8
Branch: refs/heads/1368-fix-multipart-header-parts
Commit: d4f547f8c082adb0543fa538a018db9779e9b9dd
Parents: a6b3521
Author: benoitc <bc...@gmail.com>
Authored: Mon Nov 5 12:57:52 2012 +0100
Committer: benoitc <bc...@gmail.com>
Committed: Mon Nov 5 12:57:52 2012 +0100
----------------------------------------------------------------------
test/etap/231-cors.t | 40 ++++++++++++++++++++++++++++++++++++----
1 files changed, 36 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/d4f547f8/test/etap/231-cors.t
----------------------------------------------------------------------
diff --git a/test/etap/231-cors.t b/test/etap/231-cors.t
index 7a49126..75cae6b 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(14),
+ etap:plan(16),
case (catch test()) of
ok ->
etap:end_tests();
@@ -89,14 +89,20 @@ test() ->
test_db_origin_request(),
test_db1_origin_request(),
test_preflight_with_port1(),
+ test_preflight_with_scheme1(),
ok = couch_config:set("cors", "origins", "http://example.com:5984", false),
test_preflight_with_port2(),
+ ok = couch_config:set("cors", "origins", "https://example.com:5984", false),
+ test_preflight_with_scheme2(),
+
+
+
ok = couch_config:set("cors", "origins", "*", false),
- test_preflight_with_wildcard(),
-
+ test_preflight_with_wildcard(),
+
ok = couch_config:set("cors", "origins", "http://example.com", false),
%% do tests with auth
@@ -104,7 +110,7 @@ test() ->
test_db_preflight_auth_request(),
test_db_origin_auth_request(),
-
+
%% restart boilerplate
catch couch_db:close(Db),
@@ -278,3 +284,29 @@ test_preflight_with_port2() ->
_ ->
etap:is(false, true, "ibrowse failed")
end.
+
+test_preflight_with_scheme1() ->
+ Headers = [{"Origin", "https://example.com:5984"},
+ {"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),
+ undefined,
+ "check non defined scheme in origin ok");
+ _ ->
+ etap:is(false, true, "ibrowse failed")
+ end.
+
+test_preflight_with_scheme2() ->
+ Headers = [{"Origin", "https://example.com:5984"},
+ {"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),
+ "https://example.com:5984",
+ "check scheme in origin ok");
+ _ ->
+ etap:is(false, true, "ibrowse failed")
+ end.