aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/handlers/content_types_provided_h.erl5
-rw-r--r--test/rest_handler_SUITE.erl12
2 files changed, 17 insertions, 0 deletions
diff --git a/test/handlers/content_types_provided_h.erl b/test/handlers/content_types_provided_h.erl
index 5220c19..397026b 100644
--- a/test/handlers/content_types_provided_h.erl
+++ b/test/handlers/content_types_provided_h.erl
@@ -11,9 +11,14 @@
init(Req, Opts) ->
{cowboy_rest, Req, Opts}.
+content_types_provided(Req=#{qs := <<"invalid-type">>}, State) ->
+ ct_helper:ignore(cowboy_rest, normalize_content_types, 2),
+ {[{{'*', '*', '*'}, get_text_plain}], Req, State};
content_types_provided(Req=#{qs := <<"wildcard-param">>}, State) ->
{[{{<<"text">>, <<"plain">>, '*'}, get_text_plain}], Req, State}.
+get_text_plain(Req=#{qs := <<"invalid-type">>}, State) ->
+ {<<"invalid-type">>, Req, State};
get_text_plain(Req=#{qs := <<"wildcard-param">>}, State) ->
{_, _, Param} = maps:get(media_type, Req),
Body = if
diff --git a/test/rest_handler_SUITE.erl b/test/rest_handler_SUITE.erl
index 6c1f1c1..324a50c 100644
--- a/test/rest_handler_SUITE.erl
+++ b/test/rest_handler_SUITE.erl
@@ -404,6 +404,18 @@ content_types_accepted_wildcard_param_content_type_with_param(Config) ->
{response, fin, 204, _} = gun:await(ConnPid, Ref),
ok.
+content_types_provided_invalid_type(Config) ->
+ doc("When an invalid type is returned from the "
+ "content_types_provided callback, the "
+ "resource is incorrect and a 500 response is expected."),
+ ConnPid = gun_open(Config),
+ Ref = gun:get(ConnPid, "/content_types_provided?invalid-type", [
+ {<<"accept">>, <<"*/*">>},
+ {<<"accept-encoding">>, <<"gzip">>}
+ ]),
+ {response, _, 500, _} = do_maybe_h3_error(gun:await(ConnPid, Ref)),
+ ok.
+
content_types_provided_wildcard_param_no_accept_param(Config) ->
doc("When a wildcard is returned for parameters from the "
"content_types_provided callback, an accept header "