Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Small changes to the CORS test

I looked through the patches on JIRA and found that the tests had moved
around a couple times. So I'm bring it all together.

- Use a new number, 250-cors.t. Found two patches on JIRA, one with
  221 and one with 230. New etap tests have been committed since, so
  I decided to bump the number.

- Added the CORS test to test/etap/Makefile.am

- Removed trailing whitespace
  • Loading branch information...
commit 2ccda64bbffdfa96e8b9817d42788715ca3adb5f 1 parent 8de5e72
Randall Leeds tilgovi authored
22 test/etap/221-cors.t → test/etap/250-cors.t
@@ -49,9 +49,9 @@ admin_user_ctx() -> {user_ctx, #user_ctx{roles=[<<"_admin">>]}}.
49 49 set_admin_password(UserName, Password) ->
50 50 Salt = binary_to_list(couch_uuids:random()),
51 51 Hashed = couch_util:to_hex(crypto:sha(Password ++ Salt)),
52   - couch_config:set("admins", UserName,
  52 + couch_config:set("admins", UserName,
53 53 "-hashed-" ++ Hashed ++ "," ++ Salt, false).
54   -
  54 +
55 55
56 56 secobj() ->
57 57 {[
@@ -66,7 +66,7 @@ secobj2() ->
66 66 {<<"admins">>, {[{<<"names">>, []}, {<<"roles">>, []}]}}
67 67 ]}.
68 68
69   -
  69 +
70 70 test() ->
71 71 %% launch couchdb
72 72 couch_server_sup:start_link(test_util:config_files()),
@@ -82,8 +82,8 @@ test() ->
82 82 {ok, Db1} = couch_db:create(list_to_binary(dbname1()), [admin_user_ctx()]),
83 83 {ok, Db2} = couch_db:create(list_to_binary(dbname2()), [admin_user_ctx()]),
84 84
85   - ok = couch_db:set_security(Db1, secobj()),
86   - ok = couch_db:set_security(Db2, secobj2()),
  85 + ok = couch_db:set_security(Db1, secobj()),
  86 + ok = couch_db:set_security(Db2, secobj2()),
87 87
88 88 %% do tests
89 89 test_simple_request(),
@@ -96,7 +96,7 @@ test() ->
96 96
97 97 %% do tests with auth
98 98 ok = set_admin_password("test", "test"),
99   -
  99 +
100 100 test_db_preflight_auth_request(),
101 101 test_db_origin_auth_request(),
102 102
@@ -126,10 +126,10 @@ test_simple_request() ->
126 126 end.
127 127
128 128 test_preflight_request() ->
129   - Headers = [{"Origin", "http://127.0.0.1"},
  129 + Headers = [{"Origin", "http://127.0.0.1"},
130 130 {"Access-Control-Request-Method", "GET"}],
131 131 case ibrowse:send_req(server(), Headers, options, []) of
132   - {ok, _, RespHeaders, _} ->
  132 + {ok, _, RespHeaders, _} ->
133 133 etap:is(proplists:get_value("Access-Control-Allow-Methods", RespHeaders),
134 134 ?SUPPORTED_METHODS,
135 135 "Access-Control-Allow-Methods ok");
@@ -151,7 +151,7 @@ test_db_request() ->
151 151
152 152 test_db_preflight_request() ->
153 153 Url = server() ++ "etap-test-db",
154   - Headers = [{"Origin", "http://127.0.0.1"},
  154 + Headers = [{"Origin", "http://127.0.0.1"},
155 155 {"Access-Control-Request-Method", "GET"}],
156 156 case ibrowse:send_req(Url, Headers, options, []) of
157 157 {ok, _, RespHeaders, _} ->
@@ -203,7 +203,7 @@ test_db1_wrong_origin_request() ->
203 203
204 204 test_db_preflight_auth_request() ->
205 205 Url = server() ++ "etap-test-db2",
206   - Headers = [{"Origin", "http://127.0.0.1"},
  206 + Headers = [{"Origin", "http://127.0.0.1"},
207 207 {"Access-Control-Request-Method", "GET"}],
208 208 case ibrowse:send_req(Url, Headers, options, []) of
209 209 {ok, _Status, RespHeaders, _} ->
@@ -222,7 +222,7 @@ test_db_origin_auth_request() ->
222 222 Headers = [{"Origin", "http://127.0.0.1"}],
223 223 Url = server() ++ "etap-test-db2",
224 224
225   - case ibrowse:send_req(Url, Headers, get, [],
  225 + case ibrowse:send_req(Url, Headers, get, [],
226 226 [{basic_auth, {"test", "test"}}]) of
227 227 {ok, _, RespHeaders, _Body} ->
228 228 etap:is(proplists:get_value("Access-Control-Allow-Origin", RespHeaders),
3  test/etap/Makefile.am
@@ -93,4 +93,5 @@ EXTRA_DIST = \
93 93 230-httpc-pool.t \
94 94 240-replication-compact.t \
95 95 241-replication-large-atts.t \
96   - 242-replication-many-leaves.t
  96 + 242-replication-many-leaves.t \
  97 + 250-cors.t

0 comments on commit 2ccda64

Please sign in to comment.
Something went wrong with that request. Please try again.