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/11/11 20:24:31 UTC
[6/28] 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/1b718179
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/1b718179
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/1b718179
Branch: refs/heads/431-feature-cors
Commit: 1b718179bda4b4c3635a8831a9dfb1f5f24d5dfc
Parents: 79481b1
Author: benoitc <bc...@gmail.com>
Authored: Mon Nov 5 12:57:52 2012 +0100
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Sun Nov 11 16:11:15 2012 +0000
----------------------------------------------------------------------
test/etap/231-cors.t | 40 ++++++++++++++++++++++++++++++++++++----
1 files changed, 36 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/1b718179/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.