couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [13/28] git commit: test to make sure that the port is checked in the origin
Date Sun, 11 Nov 2012 19:24:31 GMT
test to make sure that the port is checked in the origin


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/79481b14
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/79481b14
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/79481b14

Branch: refs/heads/431-feature-cors
Commit: 79481b142d4cf9cb664e3d9fe24feb9744c7a25f
Parents: 63591d7
Author: benoitc <bchesneau@gmail.com>
Authored: Mon Nov 5 11:56:45 2012 +0100
Committer: Jan Lehnardt <jan@apache.org>
Committed: Sun Nov 11 16:11:15 2012 +0000

----------------------------------------------------------------------
 test/etap/231-cors.t |   37 +++++++++++++++++++++++++++++++++++--
 1 files changed, 35 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/79481b14/test/etap/231-cors.t
----------------------------------------------------------------------
diff --git a/test/etap/231-cors.t b/test/etap/231-cors.t
index 85867be..7a49126 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(12),
+    etap:plan(14),
     case (catch test()) of
         ok ->
             etap:end_tests();
@@ -88,9 +88,15 @@ test() ->
     test_db_preflight_request(),
     test_db_origin_request(),
     test_db1_origin_request(),
+    test_preflight_with_port1(),
+
+    ok = couch_config:set("cors", "origins", "http://example.com:5984", false),
+    test_preflight_with_port2(),
+
 
     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
@@ -98,6 +104,7 @@ test() ->
 
     test_db_preflight_auth_request(),
     test_db_origin_auth_request(),
+    
 
     %% restart boilerplate
     catch couch_db:close(Db),
@@ -245,3 +252,29 @@ test_preflight_with_wildcard() ->
     _ ->
         etap:is(false, true, "ibrowse failed")
     end.
+
+test_preflight_with_port1() ->
+    Headers = [{"Origin", "http://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 host:port in origin ok");
+    _ ->
+        etap:is(false, true, "ibrowse failed")
+    end.
+
+test_preflight_with_port2() ->
+    Headers = [{"Origin", "http://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),
+            "http://example.com:5984",
+            "check host:port in origin ok");
+    _ ->
+        etap:is(false, true, "ibrowse failed")
+    end.


Mime
View raw message