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

[33/44] git commit: test to make sure that the port is checked in the origin

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/a6b35210
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/a6b35210
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/a6b35210

Branch: refs/heads/1368-fix-multipart-header-parts
Commit: a6b35210ef05fa168432bc73b73e27f12d2b96c8
Parents: 87cac98
Author: benoitc <bc...@gmail.com>
Authored: Mon Nov 5 11:56:45 2012 +0100
Committer: benoitc <bc...@gmail.com>
Committed: Mon Nov 5 11:56:45 2012 +0100

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


http://git-wip-us.apache.org/repos/asf/couchdb/blob/a6b35210/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.