diff options
author | Randall Leeds <randall@apache.org> | 2011-11-26 17:12:40 -0800 |
---|---|---|
committer | Randall Leeds <randall@apache.org> | 2011-11-26 17:17:29 -0800 |
commit | 2ccda64bbffdfa96e8b9817d42788715ca3adb5f (patch) | |
tree | 9a5ac11fb49a25c8170b8d2f789fd272b03af2a4 | |
parent | 8de5e722ea3172b26024107515de6a50dcd1a966 (diff) | |
download | couchdb-COUCHDB-431.tar.gz |
Small changes to the CORS testCOUCHDB-431
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
-rw-r--r-- | test/etap/250-cors.t (renamed from test/etap/221-cors.t) | 22 | ||||
-rw-r--r-- | test/etap/Makefile.am | 3 |
2 files changed, 13 insertions, 12 deletions
diff --git a/test/etap/221-cors.t b/test/etap/250-cors.t index d03486f2d..e4be63168 100644 --- a/test/etap/221-cors.t +++ b/test/etap/250-cors.t @@ -49,9 +49,9 @@ admin_user_ctx() -> {user_ctx, #user_ctx{roles=[<<"_admin">>]}}. set_admin_password(UserName, Password) -> Salt = binary_to_list(couch_uuids:random()), Hashed = couch_util:to_hex(crypto:sha(Password ++ Salt)), - couch_config:set("admins", UserName, + couch_config:set("admins", UserName, "-hashed-" ++ Hashed ++ "," ++ Salt, false). - + secobj() -> {[ @@ -66,7 +66,7 @@ secobj2() -> {<<"admins">>, {[{<<"names">>, []}, {<<"roles">>, []}]}} ]}. - + test() -> %% launch couchdb couch_server_sup:start_link(test_util:config_files()), @@ -82,8 +82,8 @@ test() -> {ok, Db1} = couch_db:create(list_to_binary(dbname1()), [admin_user_ctx()]), {ok, Db2} = couch_db:create(list_to_binary(dbname2()), [admin_user_ctx()]), - ok = couch_db:set_security(Db1, secobj()), - ok = couch_db:set_security(Db2, secobj2()), + ok = couch_db:set_security(Db1, secobj()), + ok = couch_db:set_security(Db2, secobj2()), %% do tests test_simple_request(), @@ -96,7 +96,7 @@ test() -> %% do tests with auth ok = set_admin_password("test", "test"), - + test_db_preflight_auth_request(), test_db_origin_auth_request(), @@ -126,10 +126,10 @@ test_simple_request() -> end. test_preflight_request() -> - Headers = [{"Origin", "http://127.0.0.1"}, + Headers = [{"Origin", "http://127.0.0.1"}, {"Access-Control-Request-Method", "GET"}], case ibrowse:send_req(server(), Headers, options, []) of - {ok, _, RespHeaders, _} -> + {ok, _, RespHeaders, _} -> etap:is(proplists:get_value("Access-Control-Allow-Methods", RespHeaders), ?SUPPORTED_METHODS, "Access-Control-Allow-Methods ok"); @@ -151,7 +151,7 @@ test_db_request() -> test_db_preflight_request() -> Url = server() ++ "etap-test-db", - Headers = [{"Origin", "http://127.0.0.1"}, + Headers = [{"Origin", "http://127.0.0.1"}, {"Access-Control-Request-Method", "GET"}], case ibrowse:send_req(Url, Headers, options, []) of {ok, _, RespHeaders, _} -> @@ -203,7 +203,7 @@ test_db1_wrong_origin_request() -> test_db_preflight_auth_request() -> Url = server() ++ "etap-test-db2", - Headers = [{"Origin", "http://127.0.0.1"}, + Headers = [{"Origin", "http://127.0.0.1"}, {"Access-Control-Request-Method", "GET"}], case ibrowse:send_req(Url, Headers, options, []) of {ok, _Status, RespHeaders, _} -> @@ -222,7 +222,7 @@ test_db_origin_auth_request() -> Headers = [{"Origin", "http://127.0.0.1"}], Url = server() ++ "etap-test-db2", - case ibrowse:send_req(Url, Headers, get, [], + case ibrowse:send_req(Url, Headers, get, [], [{basic_auth, {"test", "test"}}]) of {ok, _, RespHeaders, _Body} -> etap:is(proplists:get_value("Access-Control-Allow-Origin", RespHeaders), diff --git a/test/etap/Makefile.am b/test/etap/Makefile.am index b27404f30..a0f605489 100644 --- a/test/etap/Makefile.am +++ b/test/etap/Makefile.am @@ -93,4 +93,5 @@ EXTRA_DIST = \ 230-httpc-pool.t \ 240-replication-compact.t \ 241-replication-large-atts.t \ - 242-replication-many-leaves.t + 242-replication-many-leaves.t \ + 250-cors.t |