diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/dispatcher_prop.erl | 68 | ||||
-rw-r--r-- | test/http_SUITE.erl | 40 | ||||
-rw-r--r-- | test/http_handler_init_shutdown.erl | 2 | ||||
-rw-r--r-- | test/http_handler_set_resp.erl | 4 | ||||
-rw-r--r-- | test/proper_SUITE.erl | 37 | ||||
-rw-r--r-- | test/rest_forbidden_resource.erl | 2 | ||||
-rw-r--r-- | test/rest_nodelete_resource.erl | 2 |
7 files changed, 25 insertions, 130 deletions
diff --git a/test/dispatcher_prop.erl b/test/dispatcher_prop.erl deleted file mode 100644 index 163fcd8..0000000 --- a/test/dispatcher_prop.erl +++ /dev/null @@ -1,68 +0,0 @@ -%% Copyright (c) 2011, Magnus Klaar <[email protected]> -%% Copyright (c) 2011, Loïc Hoguin <[email protected]> -%% -%% Permission to use, copy, modify, and/or distribute this software for any -%% purpose with or without fee is hereby granted, provided that the above -%% copyright notice and this permission notice appear in all copies. -%% -%% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -%% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -%% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -%% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -%% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -%% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -%% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - --module(dispatcher_prop). --include_lib("proper/include/proper.hrl"). - -%% Generators. - -hostname_head_char() -> - oneof([choose($a, $z), choose($A, $Z), choose($0, $9)]). - -hostname_char() -> - oneof([choose($a, $z), choose($A, $Z), choose($0, $9), $-]). - -hostname_label() -> - ?SUCHTHAT(Label, [hostname_head_char()|list(hostname_char())], - length(Label) < 64). - -hostname() -> - ?SUCHTHAT(Hostname, - ?LET(Labels, list(hostname_label()), string:join(Labels, ".")), - length(Hostname) > 0 andalso length(Hostname) =< 255). - -port_number() -> - choose(1, 16#ffff). - -port_str() -> - oneof(["", ?LET(Port, port_number(), ":" ++ integer_to_list(Port))]). - -server() -> - ?LET({Hostname, PortStr}, {hostname(), port_str()}, - list_to_binary(Hostname ++ PortStr)). - -%% Properties. - -prop_split_host_symmetric() -> - ?FORALL(Server, server(), - begin case cowboy_dispatcher:split_host(Server) of - {Tokens, RawHost, undefined} -> - (Server == RawHost) and (Server == binary_join(Tokens, ".")); - {Tokens, RawHost, Port} -> - PortBin = (list_to_binary(":" ++ integer_to_list(Port))), - (Server == << RawHost/binary, PortBin/binary >>) - and (Server == << (binary_join(Tokens, "."))/binary, - PortBin/binary >>) - end end). - -%% Internal. - -%% Contributed by MononcQc on #erlounge. -binary_join(Flowers, Leaf) -> - case Flowers of - [] -> <<>>; - [Petal|Pot] -> iolist_to_binary( - [Petal | [[Leaf | Pollen] || Pollen <- Pot]]) - end. diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl index 1140cf9..cb59c07 100644 --- a/test/http_SUITE.erl +++ b/test/http_SUITE.erl @@ -218,11 +218,11 @@ init_dispatch(Config) -> {[<<"init_shutdown">>], http_handler_init_shutdown, []}, {[<<"long_polling">>], http_handler_long_polling, []}, {[<<"headers">>, <<"dupe">>], http_handler, - [{headers, [{<<"Connection">>, <<"close">>}]}]}, + [{headers, [{<<"connection">>, <<"close">>}]}]}, {[<<"set_resp">>, <<"header">>], http_handler_set_resp, - [{headers, [{<<"Vary">>, <<"Accept">>}]}]}, + [{headers, [{<<"vary">>, <<"Accept">>}]}]}, {[<<"set_resp">>, <<"overwrite">>], http_handler_set_resp, - [{headers, [{<<"Server">>, <<"DesireDrive/1.0">>}]}]}, + [{headers, [{<<"server">>, <<"DesireDrive/1.0">>}]}]}, {[<<"set_resp">>, <<"body">>], http_handler_set_resp, [{body, <<"A flameless dance does not equal a cycle">>}]}, {[<<"stream_body">>, <<"set_resp">>], http_handler_stream_body, @@ -327,17 +327,17 @@ check_raw_status(Config) -> HugeCookie = lists:flatten(["whatever_man_biiiiiiiiiiiig_cookie_me_want_77=" "Wed Apr 06 2011 10:38:52 GMT-0500 (CDT)" || _ <- lists:seq(1, 40)]), ResponsePacket = -"HTTP/1.0 302 Found -Location: http://www.google.co.il/ -Cache-Control: private -Content-Type: text/html; charset=UTF-8 -Set-Cookie: PREF=ID=568f67013d4a7afa:FF=0:TM=1323014101:LM=1323014101:S=XqctDWC65MzKT0zC; expires=Tue, 03-Dec-2013 15:55:01 GMT; path=/; domain=.google.com -Date: Sun, 04 Dec 2011 15:55:01 GMT -Server: gws -Content-Length: 221 -X-XSS-Protection: 1; mode=block -X-Frame-Options: SAMEORIGIN - +"HTTP/1.0 302 Found\r +Location: http://www.google.co.il/\r +Cache-Control: private\r +Content-Type: text/html; charset=UTF-8\r +Set-Cookie: PREF=ID=568f67013d4a7afa:FF=0:TM=1323014101:LM=1323014101:S=XqctDWC65MzKT0zC; expires=Tue, 03-Dec-2013 15:55:01 GMT; path=/; domain=.google.com\r +Date: Sun, 04 Dec 2011 15:55:01 GMT\r +Server: gws\r +Content-Length: 221\r +X-XSS-Protection: 1; mode=block\r +X-Frame-Options: SAMEORIGIN\r +\r <HTML><HEAD><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\"> <TITLE>302 Moved</TITLE></HEAD><BODY> <H1>302 Moved</H1> @@ -354,13 +354,13 @@ The document has moved {400, "\r\n\r\n\r\n\r\n\r\n\r\n"}, {400, "GET / HTTP/1.1\r\nHost: ninenines.eu\r\n\r\n"}, {400, "GET http://proxy/ HTTP/1.1\r\n\r\n"}, - {400, ResponsePacket}, + {505, ResponsePacket}, {408, "GET / HTTP/1.1\r\n"}, {408, "GET / HTTP/1.1\r\nHost: localhost"}, {408, "GET / HTTP/1.1\r\nHost: localhost\r\n"}, {408, "GET / HTTP/1.1\r\nHost: localhost\r\n\r"}, - {413, Huge}, - {413, "GET / HTTP/1.1\r\n" ++ Huge}, + {414, Huge}, + {400, "GET / HTTP/1.1\r\n" ++ Huge}, {505, "GET / HTTP/1.2\r\nHost: localhost\r\n\r\n"}, {closed, ""}, {closed, "\r\n"}, @@ -552,8 +552,8 @@ multipart(Config) -> {ok, RespBody, _} = cowboy_client:response_body(Client3), Parts = binary_to_term(RespBody), Parts = [ - {[{<<"X-Name">>, <<"answer">>}], <<"42">>}, - {[{'Server', <<"Cowboy">>}], <<"It rocks!\r\n">>} + {[{<<"x-name">>, <<"answer">>}], <<"42">>}, + {[{<<"server">>, <<"Cowboy">>}], <<"It rocks!\r\n">>} ]. nc_reqs(Config, Input) -> @@ -599,7 +599,7 @@ onrequest_reply(Config) -> onrequest_hook(Req) -> case cowboy_req:qs_val(<<"reply">>, Req) of {undefined, Req2} -> - cowboy_req:set_resp_header('Server', <<"Serenity">>, Req2); + cowboy_req:set_resp_header(<<"server">>, <<"Serenity">>, Req2); {_, Req2} -> {ok, Req3} = cowboy_req:reply( 200, [], <<"replied!">>, Req2), diff --git a/test/http_handler_init_shutdown.erl b/test/http_handler_init_shutdown.erl index c26fa97..edea1a0 100644 --- a/test/http_handler_init_shutdown.erl +++ b/test/http_handler_init_shutdown.erl @@ -6,7 +6,7 @@ init({_Transport, http}, Req, _Opts) -> {ok, Req2} = cowboy_req:reply(<<"666 Init Shutdown Testing">>, - [{'Connection', <<"close">>}], Req), + [{<<"connection">>, <<"close">>}], Req), {shutdown, Req2, undefined}. handle(Req, State) -> diff --git a/test/http_handler_set_resp.erl b/test/http_handler_set_resp.erl index 806bca8..70ddf79 100644 --- a/test/http_handler_set_resp.erl +++ b/test/http_handler_set_resp.erl @@ -11,12 +11,12 @@ init({_Transport, http}, Req, Opts) -> cowboy_req:set_resp_header(Name, Value, R) end, Req, Headers), Req3 = cowboy_req:set_resp_body(Body, Req2), - Req4 = cowboy_req:set_resp_header(<<"X-Cowboy-Test">>, <<"ok">>, Req3), + Req4 = cowboy_req:set_resp_header(<<"x-cowboy-test">>, <<"ok">>, Req3), Req5 = cowboy_req:set_resp_cookie(<<"cake">>, <<"lie">>, [], Req4), {ok, Req5, undefined}. handle(Req, State) -> - case cowboy_req:has_resp_header(<<"X-Cowboy-Test">>, Req) of + case cowboy_req:has_resp_header(<<"x-cowboy-test">>, Req) of false -> {ok, Req, State}; true -> case cowboy_req:has_resp_body(Req) of diff --git a/test/proper_SUITE.erl b/test/proper_SUITE.erl deleted file mode 100644 index 113e135..0000000 --- a/test/proper_SUITE.erl +++ /dev/null @@ -1,37 +0,0 @@ -%% Copyright (c) 2011, Loïc Hoguin <[email protected]> -%% -%% Permission to use, copy, modify, and/or distribute this software for any -%% purpose with or without fee is hereby granted, provided that the above -%% copyright notice and this permission notice appear in all copies. -%% -%% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -%% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -%% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -%% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -%% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -%% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -%% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - --module(proper_SUITE). - --include_lib("common_test/include/ct.hrl"). - --export([all/0, groups/0]). %% ct. --export([dispatcher_split_host/1]). %% cowboy_dispatcher. - -%% ct. - -all() -> - [{group, dispatcher}]. - -groups() -> - [{dispatcher, [], [dispatcher_split_host]}]. - -%% cowboy_dispatcher. - -dispatcher_split_host(_Config) -> - true = proper:quickcheck(dispatcher_prop:prop_split_host_symmetric(), - [{on_output, fun(Format, Data) -> - io:format(user, Format, Data), %% Console. - io:format(Format, Data) %% Logs. - end}]). diff --git a/test/rest_forbidden_resource.erl b/test/rest_forbidden_resource.erl index d34e7b2..63aac7e 100644 --- a/test/rest_forbidden_resource.erl +++ b/test/rest_forbidden_resource.erl @@ -10,7 +10,7 @@ rest_init(Req, [Forbidden]) -> {ok, Req, Forbidden}. allowed_methods(Req, State) -> - {['GET', 'HEAD', 'POST'], Req, State}. + {[<<"GET">>, <<"HEAD">>, <<"POST">>], Req, State}. forbidden(Req, State=true) -> {true, Req, State}; diff --git a/test/rest_nodelete_resource.erl b/test/rest_nodelete_resource.erl index 8c83422..9f9670c 100644 --- a/test/rest_nodelete_resource.erl +++ b/test/rest_nodelete_resource.erl @@ -6,7 +6,7 @@ init(_Transport, _Req, _Opts) -> {upgrade, protocol, cowboy_rest}. allowed_methods(Req, State) -> - {['GET', 'HEAD', 'DELETE'], Req, State}. + {[<<"GET">>, <<"HEAD">>, <<"DELETE">>], Req, State}. content_types_provided(Req, State) -> |