summaryrefslogtreecommitdiff
path: root/lib/inets/test/httpd_SUITE.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/inets/test/httpd_SUITE.erl')
-rw-r--r--lib/inets/test/httpd_SUITE.erl80
1 files changed, 49 insertions, 31 deletions
diff --git a/lib/inets/test/httpd_SUITE.erl b/lib/inets/test/httpd_SUITE.erl
index 9645937c36..1df6251d41 100644
--- a/lib/inets/test/httpd_SUITE.erl
+++ b/lib/inets/test/httpd_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2013-2022. All Rights Reserved.
+%% Copyright Ericsson AB 2013-2023. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
%%
%% ct:run("../inets_test", httpd_SUITE).
%%
-
+-compile({no_auto_import,[alias/1]}).
-module(httpd_SUITE).
-include_lib("kernel/include/file.hrl").
@@ -30,7 +30,7 @@
-include_lib("public_key/include/public_key.hrl").
-include_lib("inets/include/httpd.hrl").
-include("inets_test_lib.hrl").
-
+-include_lib("stdlib/include/assert.hrl").
%% Note: This directive should only be used in test suites.
-compile(export_all).
@@ -1043,7 +1043,7 @@ cgi() ->
cgi(Config) when is_list(Config) ->
{Script, Script2, Script3} =
- case test_server:os_type() of
+ case os:type() of
{win32, _} ->
{"printenv.bat", "printenv.sh", "cgi_echo.exe"};
_ ->
@@ -1118,7 +1118,7 @@ cgi_chunked_encoding_test() ->
cgi_chunked_encoding_test(Config) when is_list(Config) ->
Host = proplists:get_value(host, Config),
Script =
- case test_server:os_type() of
+ case os:type() of
{win32, _} ->
"/cgi-bin/printenv.bat";
_ ->
@@ -1148,30 +1148,48 @@ alias_1_0(Config) when is_list(Config) ->
alias() ->
[{doc, "Test mod_alias"}].
-alias(Config) when is_list(Config) ->
- ok = http_status("GET /pics/icon.sheet.gif ", Config,
- [{statuscode, 200},
- {header, "Content-Type","image/gif"},
- {header, "Server"},
- {header, "Date"}]),
-
- ok = http_status("GET / ", Config,
- [{statuscode, 200},
- {header, "Content-Type","text/html"},
- {header, "Server"},
- {header, "Date"}]),
-
- ok = http_status("GET /misc/ ", Config,
- [{statuscode, 200},
- {header, "Content-Type","text/html"},
- {header, "Server"},
- {header, "Date"}]),
-
- %% Check redirection if trailing slash is missing.
- ok = http_status("GET /misc ", Config,
- [{statuscode, 301},
- {header, "Location"},
- {header, "Content-Type","text/html"}]).
+alias(Config) when is_list(Config) ->
+ TestURIs200 = [
+ {"GET /pics/icon.sheet.gif ", 200, "image/gif"},
+ {"GET / ", 200, "text/html"},
+ {"GET /misc/ ", 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],
+ TestURIs301 =
+ [
+ %% Check redirection if trailing slash is missing.
+ {"GET /misc ", 301, "text/html", "&#47;misc&#47;$"},
+ %% slash character expected after path(misc) not query component
+ {"GET /misc?test=test ", 301, "text/html", "&#47;misc&#47;\\?test=test$"}
+ ],
+ Test301 =
+ fun({Request, ResultCode, ContentType, TargetLinkRegexp}) ->
+ ct:log("Request: ~s Expecting: ~p ~s RE: ~s",
+ [Request, ResultCode, ContentType, TargetLinkRegexp]),
+ {ok, [RedirectLink]} =
+ http_status(Request, Config,
+ [{statuscode, ResultCode},
+ {header, "Content-Type", ContentType},
+ {header, "Server"},
+ {header, "Date"},
+ {fetch_hrefs, true}]),
+ ReResult = re:run(RedirectLink, TargetLinkRegexp),
+ ct:log("RedirectLink = ~p", [RedirectLink]),
+ ?assertMatch({match, _}, ReResult)
+ end,
+ [Test301(T) || T <- TestURIs301],
+ ok.
+
%%-------------------------------------------------------------------------
actions() ->
[{doc, "Test mod_actions"}].
@@ -1958,7 +1976,7 @@ setup_server_dirs(ServerRoot, DocRoot, DataDir) ->
inets_test_lib:copy_dirs(PicsSrc, PicsDir),
inets_test_lib:copy_dirs(ConfigSrc, ConfigDir),
- Cgi = case test_server:os_type() of
+ Cgi = case os:type() of
{win32, _} ->
"cgi_echo.exe";
_ ->
@@ -2125,7 +2143,7 @@ server_config(http_rel_path_script_alias, Config) ->
server_config(https, Config) ->
SSLConf = proplists:get_value(ssl_conf, Config),
ServerConf = proplists:get_value(server_config, SSLConf),
- [{socket_type, {essl,
+ [{socket_type, {ssl,
[{nodelay, true} | ServerConf]}}]
++ proplists:delete(socket_type, server_config(http, Config)).