summaryrefslogtreecommitdiff
path: root/lib/inets/test
diff options
context:
space:
mode:
authorJakub Witczak <kuba@erlang.org>2022-02-02 17:40:05 +0100
committerJakub Witczak <kuba@erlang.org>2022-02-08 17:56:12 +0100
commitece10667cf7b3fe5aa53dad7e4bfa9a4216a2f2b (patch)
treeaf03b0890267720d1343bf296ba2a3100cc2945a /lib/inets/test
parent2e612c1b4e9c551a6dd80743205f586ad38ed9e1 (diff)
downloaderlang-ece10667cf7b3fe5aa53dad7e4bfa9a4216a2f2b.tar.gz
inets: remove deprecated functions from http_uri
- remove http_uri:parse/1 - remove http_uri:parse/2 - remove http_uri:scheme_defaults/0 - delay removal of http_uri:encode/1 until OTP-26 - delay removal of http_uri:decode/1 until OTP-26 - mark httpd_util:decode_hex/1 as deprecated
Diffstat (limited to 'lib/inets/test')
-rw-r--r--lib/inets/test/uri_SUITE.erl255
1 files changed, 1 insertions, 254 deletions
diff --git a/lib/inets/test/uri_SUITE.erl b/lib/inets/test/uri_SUITE.erl
index db6a8bdfc3..b17d03015c 100644
--- a/lib/inets/test/uri_SUITE.erl
+++ b/lib/inets/test/uri_SUITE.erl
@@ -41,20 +41,7 @@ suite() ->
[{ct_hooks,[ts_install_cth]}].
all() ->
- [
- ipv4,
- ipv6,
- host,
- userinfo,
- scheme,
- queries,
- fragments,
- escaped,
- hexed_query,
- scheme_validation,
- scheme_validation_bin,
- encode_decode
- ].
+ [encode_decode].
%%--------------------------------------------------------------------
@@ -74,225 +61,6 @@ end_per_testcase(_Case, _Config) ->
%% Test cases starts here.
%%-------------------------------------------------------------------------
-ipv4(Config) when is_list(Config) ->
- {ok, {http,[],"127.0.0.1",80,"/foobar.html",[]}} =
- http_uri:parse("http://127.0.0.1/foobar.html"),
-
- {ok, {http,<<>>,<<"127.0.0.1">>,80,<<"/foobar.html">>,<<>>}} =
- http_uri:parse(<<"http://127.0.0.1/foobar.html">>).
-
-ipv6(Config) when is_list(Config) ->
- {ok, {http,[],"2010:836B:4179::836B:4179",80,"/foobar.html",[]}} =
- http_uri:parse("http://[2010:836B:4179::836B:4179]/foobar.html"),
- {ok, {http,[],"[2010:836B:4179::836B:4179]",80,"/foobar.html",[]}} =
- http_uri:parse("http://[2010:836B:4179::836B:4179]/foobar.html",
- [{ipv6_host_with_brackets, true}]),
- {ok, {http,[],"2010:836B:4179::836B:4179",80,"/foobar.html",[]}} =
- http_uri:parse("http://[2010:836B:4179::836B:4179]/foobar.html",
- [{ipv6_host_with_brackets, false}]),
- {ok, {http,[],"2010:836B:4179::836B:4179",80,"/foobar.html",[]}} =
- http_uri:parse("http://[2010:836B:4179::836B:4179]/foobar.html",
- [{foo, false}]),
- {error,
- {malformed_url, _, "http://2010:836B:4179::836B:4179/foobar.html"}} =
- http_uri:parse("http://2010:836B:4179::836B:4179/foobar.html"),
-
- {ok, {http,<<>>,<<"2010:836B:4179::836B:4179">>,80,<<"/foobar.html">>,<<>>}} =
- http_uri:parse(<<"http://[2010:836B:4179::836B:4179]/foobar.html">>),
- {ok, {http,<<>>,<<"[2010:836B:4179::836B:4179]">>,80,<<"/foobar.html">>,<<>>}} =
- http_uri:parse(<<"http://[2010:836B:4179::836B:4179]/foobar.html">>,
- [{ipv6_host_with_brackets, true}]),
- {ok, {http,<<>>,<<"2010:836B:4179::836B:4179">>,80,<<"/foobar.html">>,<<>>}} =
- http_uri:parse(<<"http://[2010:836B:4179::836B:4179]/foobar.html">>,
- [{ipv6_host_with_brackets, false}]),
- {ok, {http,<<>>,<<"2010:836B:4179::836B:4179">>,80,<<"/foobar.html">>,<<>>}} =
- http_uri:parse(<<"http://[2010:836B:4179::836B:4179]/foobar.html">>,
- [{foo, false}]),
- {error,
- {malformed_url, _, <<"http://2010:836B:4179::836B:4179/foobar.html">>}} =
- http_uri:parse(<<"http://2010:836B:4179::836B:4179/foobar.html">>).
-
-host(Config) when is_list(Config) ->
- {ok, {http,[],"localhost",8888,"/foobar.html",[]}} =
- http_uri:parse("http://localhost:8888/foobar.html"),
-
- {ok, {http,<<>>,<<"localhost">>,8888,<<"/foobar.html">>,<<>>}} =
- http_uri:parse(<<"http://localhost:8888/foobar.html">>).
-
-userinfo(Config) when is_list(Config) ->
- {ok, {http,"nisse:foobar","localhost",8888,"/foobar.html",[]}} =
- http_uri:parse("http://nisse:foobar@localhost:8888/foobar.html"),
-
- {ok, {http,<<"nisse:foobar">>,<<"localhost">>,8888,<<"/foobar.html">>,<<>>}} =
- http_uri:parse(<<"http://nisse:foobar@localhost:8888/foobar.html">>).
-
-scheme(Config) when is_list(Config) ->
- {error, no_scheme} = http_uri:parse("localhost/foobar.html"),
- {error, {malformed_url, _, _}} =
- http_uri:parse("localhost:8888/foobar.html"),
-
- {error, no_scheme} = http_uri:parse(<<"localhost/foobar.html">>),
- {error, {malformed_url, _, _}} =
- http_uri:parse(<<"localhost:8888/foobar.html">>).
-
-queries(Config) when is_list(Config) ->
- {ok, {http,[],"localhost",8888,"/foobar.html","?foo=bar&foobar=42"}} =
- http_uri:parse("http://localhost:8888/foobar.html?foo=bar&foobar=42"),
-
- {ok, {http,<<>>,<<"localhost">>,8888,<<"/foobar.html">>,<<"?foo=bar&foobar=42">>}} =
- http_uri:parse(<<"http://localhost:8888/foobar.html?foo=bar&foobar=42">>).
-
-fragments(Config) when is_list(Config) ->
- {ok, {http,[],"localhost",80,"/",""}} =
- http_uri:parse("http://localhost#fragment"),
- {ok, {http,[],"localhost",80,"/path",""}} =
- http_uri:parse("http://localhost/path#fragment"),
- {ok, {http,[],"localhost",80,"/","?query"}} =
- http_uri:parse("http://localhost?query#fragment"),
- {ok, {http,[],"localhost",80,"/path","?query"}} =
- http_uri:parse("http://localhost/path?query#fragment"),
- {ok, {http,[],"localhost",80,"/","","#fragment"}} =
- http_uri:parse("http://localhost#fragment", [{fragment,true}]),
- {ok, {http,[],"localhost",80,"/path","","#fragment"}} =
- http_uri:parse("http://localhost/path#fragment", [{fragment,true}]),
- {ok, {http,[],"localhost",80,"/","?query","#fragment"}} =
- http_uri:parse("http://localhost?query#fragment", [{fragment,true}]),
- {ok, {http,[],"localhost",80,"/path","?query","#fragment"}} =
- http_uri:parse("http://localhost/path?query#fragment",
- [{fragment,true}]),
- {ok, {http,[],"localhost",80,"/","",""}} =
- http_uri:parse("http://localhost", [{fragment,true}]),
- {ok, {http,[],"localhost",80,"/path","",""}} =
- http_uri:parse("http://localhost/path", [{fragment,true}]),
- {ok, {http,[],"localhost",80,"/","?query",""}} =
- http_uri:parse("http://localhost?query", [{fragment,true}]),
- {ok, {http,[],"localhost",80,"/path","?query",""}} =
- http_uri:parse("http://localhost/path?query", [{fragment,true}]),
- {ok, {http,[],"localhost",80,"/","","#"}} =
- http_uri:parse("http://localhost#", [{fragment,true}]),
- {ok, {http,[],"localhost",80,"/path","","#"}} =
- http_uri:parse("http://localhost/path#", [{fragment,true}]),
- {ok, {http,[],"localhost",80,"/","?query","#"}} =
- http_uri:parse("http://localhost?query#", [{fragment,true}]),
- {ok, {http,[],"localhost",80,"/path","?query","#"}} =
- http_uri:parse("http://localhost/path?query#", [{fragment,true}]),
-
-
- {ok, {http,<<>>,<<"localhost">>,80,<<"/">>,<<"">>}} =
- http_uri:parse(<<"http://localhost#fragment">>),
- {ok, {http,<<>>,<<"localhost">>,80,<<"/path">>,<<"">>}} =
- http_uri:parse(<<"http://localhost/path#fragment">>),
- {ok, {http,<<>>,<<"localhost">>,80,<<"/">>,<<"?query">>}} =
- http_uri:parse(<<"http://localhost?query#fragment">>),
- {ok, {http,<<>>,<<"localhost">>,80,<<"/path">>,<<"?query">>}} =
- http_uri:parse(<<"http://localhost/path?query#fragment">>),
- {ok, {http,<<>>,<<"localhost">>,80,<<"/">>,<<"">>,<<"#fragment">>}} =
- http_uri:parse(<<"http://localhost#fragment">>, [{fragment,true}]),
- {ok, {http,<<>>,<<"localhost">>,80,<<"/path">>,<<"">>,<<"#fragment">>}} =
- http_uri:parse(<<"http://localhost/path#fragment">>, [{fragment,true}]),
- {ok, {http,<<>>,<<"localhost">>,80,<<"/">>,<<"?query">>,<<"#fragment">>}} =
- http_uri:parse(<<"http://localhost?query#fragment">>, [{fragment,true}]),
- {ok, {http,<<>>,<<"localhost">>,80,<<"/path">>,<<"?query">>,<<"#fragment">>}} =
- http_uri:parse(<<"http://localhost/path?query#fragment">>,
- [{fragment,true}]),
- {ok, {http,<<>>,<<"localhost">>,80,<<"/">>,<<"">>,<<"">>}} =
- http_uri:parse(<<"http://localhost">>, [{fragment,true}]),
- {ok, {http,<<>>,<<"localhost">>,80,<<"/path">>,<<"">>,<<"">>}} =
- http_uri:parse(<<"http://localhost/path">>, [{fragment,true}]),
- {ok, {http,<<>>,<<"localhost">>,80,<<"/">>,<<"?query">>,<<"">>}} =
- http_uri:parse(<<"http://localhost?query">>, [{fragment,true}]),
- {ok, {http,<<>>,<<"localhost">>,80,<<"/path">>,<<"?query">>,<<"">>}} =
- http_uri:parse(<<"http://localhost/path?query">>, [{fragment,true}]),
- {ok, {http,<<>>,<<"localhost">>,80,<<"/">>,<<"">>,<<"#">>}} =
- http_uri:parse(<<"http://localhost#">>, [{fragment,true}]),
- {ok, {http,<<>>,<<"localhost">>,80,<<"/path">>,<<"">>,<<"#">>}} =
- http_uri:parse(<<"http://localhost/path#">>, [{fragment,true}]),
- {ok, {http,<<>>,<<"localhost">>,80,<<"/">>,<<"?query">>,<<"#">>}} =
- http_uri:parse(<<"http://localhost?query#">>, [{fragment,true}]),
- {ok, {http,<<>>,<<"localhost">>,80,<<"/path">>,<<"?query">>,<<"#">>}} =
- http_uri:parse(<<"http://localhost/path?query#">>, [{fragment,true}]),
- ok.
-
-escaped(Config) when is_list(Config) ->
- {ok, {http,[],"www.somedomain.com",80,"/%2Eabc",[]}} =
- http_uri:parse("http://www.somedomain.com/%2Eabc"),
- {ok, {http,[],"www.somedomain.com",80,"/%252Eabc",[]}} =
- http_uri:parse("http://www.somedomain.com/%252Eabc"),
- {ok, {http,[],"www.somedomain.com",80,"/%25abc",[]}} =
- http_uri:parse("http://www.somedomain.com/%25abc"),
- {ok, {http,[],"www.somedomain.com",80,"/%25abc", "?foo=bar"}} =
- http_uri:parse("http://www.somedomain.com/%25abc?foo=bar"),
-
- {ok, {http,<<>>,<<"www.somedomain.com">>,80,<<"/%2Eabc">>,<<>>}} =
- http_uri:parse(<<"http://www.somedomain.com/%2Eabc">>),
- {ok, {http,<<>>,<<"www.somedomain.com">>,80,<<"/%252Eabc">>,<<>>}} =
- http_uri:parse(<<"http://www.somedomain.com/%252Eabc">>),
- {ok, {http,<<>>,<<"www.somedomain.com">>,80,<<"/%25abc">>,<<>>}} =
- http_uri:parse(<<"http://www.somedomain.com/%25abc">>),
- {ok, {http,<<>>,<<"www.somedomain.com">>,80,<<"/%25abc">>, <<"?foo=bar">>}} =
- http_uri:parse(<<"http://www.somedomain.com/%25abc?foo=bar">>).
-
-hexed_query(doc) ->
- [{doc, "Solves OTP-6191"}];
-hexed_query(Config) when is_list(Config) ->
- Google = ?GOOGLE,
- GoogleSearch = "http://" ++ Google ++ "/search",
- Search1 = "?hl=en&q=a%D1%85%D1%83%D0%B9&btnG=Google+Search",
- URI1 = GoogleSearch ++ Search1,
- Search2 = "?hl=en&q=%25%25",
- URI2 = GoogleSearch ++ Search2,
- Search3 = "?hl=en&q=%foo",
- URI3 = GoogleSearch ++ Search3,
-
- Verify1 =
- fun({http, [], ?GOOGLE, 80, "/search", _}) -> ok;
- (_) -> error
- end,
- Verify2 = Verify1,
- Verify3 = Verify1,
- verify_uri(URI1, Verify1),
- verify_uri(URI2, Verify2),
- verify_uri(URI3, Verify3).
-
-scheme_validation(Config) when is_list(Config) ->
- {ok, {http,[],"localhost",80,"/",""}} =
- http_uri:parse("http://localhost#fragment"),
-
- ValidationFun =
- fun("http") -> valid;
- (_) -> {error, bad_scheme}
- end,
-
- {ok, {http,[],"localhost",80,"/",""}} =
- http_uri:parse("http://localhost#fragment",
- [{scheme_validation_fun, ValidationFun}]),
- {error, bad_scheme} =
- http_uri:parse("https://localhost#fragment",
- [{scheme_validation_fun, ValidationFun}]),
- %% non-fun scheme_validation_fun works as no option passed
- {ok, {https,[],"localhost",443,"/",""}} =
- http_uri:parse("https://localhost#fragment",
- [{scheme_validation_fun, none}]).
-
-scheme_validation_bin(Config) when is_list(Config) ->
- {ok, {http,<<>>,<<"localhost">>,80,<<"/">>,<<>>}} =
- http_uri:parse(<<"http://localhost#fragment">>),
-
- ValidationFun =
- fun(<<"http">>) -> valid;
- (_) -> {error, bad_scheme}
- end,
-
- {ok, {http,<<>>,<<"localhost">>,80,<<"/">>,<<>>}} =
- http_uri:parse(<<"http://localhost#fragment">>,
- [{scheme_validation_fun, ValidationFun}]),
- {error, bad_scheme} =
- http_uri:parse(<<"https://localhost#fragment">>,
- [{scheme_validation_fun, ValidationFun}]),
- %% non-fun scheme_validation_fun works as no option passed
- {ok, {https,<<>>,<<"localhost">>,443,<<"/">>,<<>>}} =
- http_uri:parse(<<"https://localhost#fragment">>,
- [{scheme_validation_fun, none}]).
encode_decode(Config) when is_list(Config) ->
?assertEqual("foo%20bar", http_uri:encode("foo bar")),
@@ -304,24 +72,3 @@ encode_decode(Config) when is_list(Config) ->
?assertEqual(<<"foo bar">>, http_uri:decode(<<"foo%20bar">>)),
?assertEqual("foo\r\n", http_uri:decode("foo%0D%0A")),
?assertEqual(<<"foo\r\n">>, http_uri:decode(<<"foo%0D%0A">>)).
-
-
-%%--------------------------------------------------------------------
-%% Internal Functions ------------------------------------------------
-%%--------------------------------------------------------------------
-
-
-verify_uri(URI, Verify) ->
- case http_uri:parse(URI) of
- {ok, ParsedURI} ->
- case Verify(ParsedURI) of
- ok ->
- ok;
- error ->
- Reason = {unexpected_parse_result, URI, ParsedURI},
- ERROR = {error, Reason},
- throw(ERROR)
- end;
- {error, _} = ERROR ->
- throw(ERROR)
- end.