diff options
author | Ingela Anderton Andin <[email protected]> | 2010-09-09 17:11:15 +0200 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2010-09-09 17:11:15 +0200 |
commit | a4c1adcdbb8bcf6be85b22232ea3093cf2299b83 (patch) | |
tree | 4f5c78c8a358a4de68cedc360118b1f20f9330c8 /lib/ssl/test/ssl_packet_SUITE.erl | |
parent | a8bf03083ce7a72f8104c119f30e7862e2596bd1 (diff) | |
parent | 38d3d67646c6ac3b4215a1bdff422fc8d3160e7e (diff) | |
download | otp-a4c1adcdbb8bcf6be85b22232ea3093cf2299b83.tar.gz otp-a4c1adcdbb8bcf6be85b22232ea3093cf2299b83.tar.bz2 otp-a4c1adcdbb8bcf6be85b22232ea3093cf2299b83.zip |
Merge branch 'ia/ssl-http-error-test' into dev
* ia/ssl-http-error-test:
Add test suite for packet http_error.
Diffstat (limited to 'lib/ssl/test/ssl_packet_SUITE.erl')
-rw-r--r-- | lib/ssl/test/ssl_packet_SUITE.erl | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/ssl/test/ssl_packet_SUITE.erl b/lib/ssl/test/ssl_packet_SUITE.erl index 1e7cde1c25..88d2d99ef8 100644 --- a/lib/ssl/test/ssl_packet_SUITE.erl +++ b/lib/ssl/test/ssl_packet_SUITE.erl @@ -149,6 +149,7 @@ all(suite) -> packet_http_decode, packet_http_decode_list, packet_http_bin_decode_multi, + packet_http_error_passive, packet_line_decode, packet_line_decode_list, packet_asn1_decode, @@ -1737,6 +1738,71 @@ client_http_bin_decode(Socket, HttpRequest, Count) when Count > 0 -> client_http_bin_decode(Socket, HttpRequest, Count - 1); client_http_bin_decode(_, _, _) -> ok. + +%%-------------------------------------------------------------------- +packet_http_error_passive(doc) -> + ["Test setting the packet option {packet, http}, {active, false}" + " with a incorrect http header." ]; +packet_http_error_passive(suite) -> + []; +packet_http_error_passive(Config) when is_list(Config) -> + ClientOpts = ?config(client_opts, Config), + ServerOpts = ?config(server_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Request = "GET / HTTP/1.1\r\n" + "host: www.example.com\r\n" + "user-agent HttpTester\r\n" + "\r\n", + Response = "HTTP/1.1 200 OK\r\n" + "\r\n" + "Hello!", + + Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, server_http_decode_error, + [Response]}}, + {options, [{active, false}, binary, + {packet, http} | + ServerOpts]}]), + + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {?MODULE, client_http_decode_list, + [Request]}}, + {options, [{active, true}, list, + {packet, http} | + ClientOpts]}]), + + ssl_test_lib:check_result(Server, ok, Client, ok), + + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). + + +server_http_decode_error(Socket, HttpResponse) -> + assert_packet_opt(Socket, http), + + {ok, {http_request, 'GET', _, {1,1}}} = ssl:recv(Socket, 0), + + assert_packet_opt(Socket, http), + + {ok, {http_header, _, 'Host', _, "www.example.com"}} = ssl:recv(Socket, 0), + assert_packet_opt(Socket, http), + + {ok, {http_error, _}} = ssl:recv(Socket, 0), + + assert_packet_opt(Socket, http), + + {ok, http_eoh} = ssl:recv(Socket, 0), + + assert_packet_opt(Socket, http), + ok = ssl:send(Socket, HttpResponse), + ok. + + %%-------------------------------------------------------------------- packet_line_decode(doc) -> ["Test setting the packet option {packet, line}, {mode, binary}"]; |