Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:25
erlang
0578-inets-Add-tests-for-mime_type-and-default_...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0578-inets-Add-tests-for-mime_type-and-default_type.patch of Package erlang
From d5f1df87c18304bfc26d49a53ed9d8f102081359 Mon Sep 17 00:00:00 2001 From: Erika Rowland <accounts@erikarowland.com> Date: Tue, 28 Nov 2023 18:44:03 +0000 Subject: [PATCH 2/2] inets: Add tests for mime_type and default_type --- lib/inets/test/httpd_SUITE.erl | 87 +++++++++++++++++++ .../htdocs/file.with_nonstandard_extension | 5 ++ .../server_root/htdocs/file_without_extension | 5 ++ 3 files changed, 97 insertions(+) create mode 100644 lib/inets/test/httpd_SUITE_data/server_root/htdocs/file.with_nonstandard_extension create mode 100644 lib/inets/test/httpd_SUITE_data/server_root/htdocs/file_without_extension diff --git a/lib/inets/test/httpd_SUITE.erl b/lib/inets/test/httpd_SUITE.erl index 4a9f01baf1..deac6122ce 100644 --- a/lib/inets/test/httpd_SUITE.erl +++ b/lib/inets/test/httpd_SUITE.erl @@ -72,6 +72,9 @@ all() -> {group, https_security}, {group, http_reload}, {group, https_reload}, + {group, http_default_type}, + {group, http_mime_type}, + {group, http_mime_and_default_type}, {group, http_mime_types}, {group, http_logging}, {group, http_post}, @@ -108,6 +111,9 @@ groups() -> {http_not_sup, [], [{group, not_sup}]}, {https_not_sup, [], [{group, not_sup}]}, {https_alert, [], [tls_alert]}, + {http_default_type, [], [default_type]}, + {http_mime_type, [], [mime_type]}, + {http_mime_and_default_type, [], [mime_and_default_type]}, {http_mime_types, [], [alias_1_1, alias_1_0]}, {limit, [], [content_length, max_clients_1_1]}, {custom, [], [customize, add_default]}, @@ -240,6 +246,9 @@ init_per_group(Group, Config0) when Group == http_basic; Group == http_reload; Group == http_not_sup; Group == http_post; + Group == http_default_type; + Group == http_mime_type; + Group == http_mime_and_default_type; Group == http_mime_types -> ok = start_apps(Group), @@ -282,6 +291,9 @@ end_per_group(Group, _Config) when Group == http_basic; Group == http_security; Group == http_reload; Group == http_post; + Group == http_default_type; + Group == http_mime_type; + Group == http_mime_and_default_type; Group == http_mime_types -> inets:stop(); @@ -1146,6 +1158,72 @@ cgi_chunked_encoding_test(Config) when is_list(Config) -> proplists:get_value(node, Config), Requests). %%------------------------------------------------------------------------- +default_type() -> + [{doc, "Test default_type"}]. + +default_type(Config) when is_list(Config) -> + TestURIs200 = [ + {"GET /file_without_extension ", 200, "text/html"}, + {"GET /file.with_nonstandard_extension ", 200, "text/html"} + ], + Test200 = + fun({Request, ResultCode, ContentType}) -> + ct:log("Request: ~s Expecting: ~p ~s", + [Request, ResultCode, ContentType]), + ok = http_status(Request, Config, + [{statuscode, ResultCode}, + {header, "Content-Type", ContentType}, + {header, "Server"}, + {header, "Date"}]) + end, + [Test200(T) || T <- TestURIs200], + ok. + +%%------------------------------------------------------------------------- +mime_type() -> + [{doc, "Test mime_type"}]. + +mime_type(Config) when is_list(Config) -> + TestURIs200 = [ + {"GET /file_without_extension ", 200, "text/html"}, + {"GET /file.with_nonstandard_extension ", 200, "text/html"} + ], + Test200 = + fun({Request, ResultCode, ContentType}) -> + ct:log("Request: ~s Expecting: ~p ~s", + [Request, ResultCode, ContentType]), + ok = http_status(Request, Config, + [{statuscode, ResultCode}, + {header, "Content-Type", ContentType}, + {header, "Server"}, + {header, "Date"}]) + end, + [Test200(T) || T <- TestURIs200], + ok. + +%%------------------------------------------------------------------------- +mime_and_default_type() -> + [{doc, "Test that mime_type takes precedence over default_type"}]. + +mime_and_default_type(Config) when is_list(Config) -> + TestURIs200 = [ + {"GET /file_without_extension ", 200, "text/html"}, + {"GET /file.with_nonstandard_extension ", 200, "text/html"} + ], + Test200 = + fun({Request, ResultCode, ContentType}) -> + ct:log("Request: ~s Expecting: ~p ~s", + [Request, ResultCode, ContentType]), + ok = http_status(Request, Config, + [{statuscode, ResultCode}, + {header, "Content-Type", ContentType}, + {header, "Server"}, + {header, "Date"}]) + end, + [Test200(T) || T <- TestURIs200], + ok. + +%%------------------------------------------------------------------------- alias_1_1() -> [{doc, "Test mod_alias"}]. @@ -2031,6 +2109,9 @@ start_apps(Group) when Group == http_basic; Group == http_logging; Group == http_reload; Group == http_post; + Group == http_default_type; + Group == http_mime_type; + Group == http_mime_and_default_type; Group == http_mime_types; Group == http_rel_path_script_alias; Group == http_not_sup; @@ -2129,6 +2210,12 @@ server_config(https_security, Config) -> tl(auth_conf(ServerRoot)) ++ security_conf(ServerRoot) ++ server_config(https, Config); server_config(http_logging, Config) -> log_conf() ++ server_config(http, Config); +server_config(http_default_type, Config) -> + [{default_type, "text/html"}] ++ basic_conf() ++ server_config(http, Config); +server_config(http_mime_type, Config) -> + [{mime_type, "text/html"}] ++ basic_conf() ++ server_config(http, Config); +server_config(http_mime_and_default_type, Config) -> + [{default_type, "text/richtext"}, {mime_type, "text/html"}] ++ basic_conf() ++ server_config(http, Config); server_config(http_mime_types, Config0) -> Config1 = basic_conf() ++ server_config(http, Config0), ServerRoot = proplists:get_value(server_root, Config0), diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/file.with_nonstandard_extension b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/file.with_nonstandard_extension new file mode 100644 index 0000000000..5501959a6f --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/file.with_nonstandard_extension @@ -0,0 +1,5 @@ +<html> +<body> +An file with a strange extension for testing mime_type defaults +</body +</html> diff --git a/lib/inets/test/httpd_SUITE_data/server_root/htdocs/file_without_extension b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/file_without_extension new file mode 100644 index 0000000000..8c39799102 --- /dev/null +++ b/lib/inets/test/httpd_SUITE_data/server_root/htdocs/file_without_extension @@ -0,0 +1,5 @@ +<html> +<body> +An file without an extension for testing mime_type defaults +</body +</html> -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor