aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/test
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2017-05-12 16:11:13 +0200
committerHans Nilsson <[email protected]>2017-05-12 16:17:44 +0200
commitde3c2e70b3bf3387877b6624b6772395664039d6 (patch)
tree12e5914dde3ebabc2947547447b270ed74c18e7a /lib/ssh/test
parent1af2d325a63ca378e250eef6c3c97d065a9eff3d (diff)
downloadotp-de3c2e70b3bf3387877b6624b6772395664039d6.tar.gz
otp-de3c2e70b3bf3387877b6624b6772395664039d6.tar.bz2
otp-de3c2e70b3bf3387877b6624b6772395664039d6.zip
ssh: Tests for ext-info extension (ext-info-c)
Diffstat (limited to 'lib/ssh/test')
-rw-r--r--lib/ssh/test/ssh_protocol_SUITE.erl62
1 files changed, 61 insertions, 1 deletions
diff --git a/lib/ssh/test/ssh_protocol_SUITE.erl b/lib/ssh/test/ssh_protocol_SUITE.erl
index cdabd839b6..0385e30ad1 100644
--- a/lib/ssh/test/ssh_protocol_SUITE.erl
+++ b/lib/ssh/test/ssh_protocol_SUITE.erl
@@ -94,7 +94,8 @@ groups() ->
]},
{ext_info, [], [no_ext_info_s1,
no_ext_info_s2,
- ext_info_s
+ ext_info_s,
+ ext_info_c
]}
].
@@ -697,6 +698,65 @@ ext_info_s(Config) ->
AfterKexState),
ssh:stop_daemon(Pid).
+%%%--------------------------------------------------------------------
+%%% The client sends the extension
+ext_info_c(Config) ->
+ {User,_Pwd} = server_user_password(Config),
+
+ %% Create a listening socket as server socket:
+ {ok,InitialState} = ssh_trpt_test_lib:exec(listen),
+ HostPort = ssh_trpt_test_lib:server_host_port(InitialState),
+
+ Parent = self(),
+ %% Start a process handling one connection on the server side:
+ Pid =
+ spawn_link(
+ fun() ->
+ Result =
+ ssh_trpt_test_lib:exec(
+ [{set_options, [print_ops, print_messages]},
+ {accept, [{system_dir, system_dir(Config)},
+ {user_dir, user_dir(Config)},
+ {recv_ext_info, true}
+ ]},
+ receive_hello,
+ {send, hello},
+
+ {send, ssh_msg_kexinit},
+ {match, #ssh_msg_kexinit{_='_'}, receive_msg},
+
+ {match, #ssh_msg_kexdh_init{_='_'}, receive_msg},
+ {send, ssh_msg_kexdh_reply},
+
+ {send, #ssh_msg_newkeys{}},
+ {match, #ssh_msg_newkeys{_='_'}, receive_msg},
+
+ {match, #ssh_msg_ext_info{_='_'}, receive_msg},
+
+ close_socket,
+ print_state
+ ],
+ InitialState),
+ Parent ! {result,self(),Result}
+ end),
+
+ %% connect to it with a regular Erlang SSH client
+ %% (expect error due to the close_socket in daemon):
+ {error,_} = std_connect(HostPort, Config,
+ [{preferred_algorithms,[{kex,[?DEFAULT_KEX]},
+ {cipher,?DEFAULT_CIPHERS}
+ ]},
+ {tstflg, [{ext_info_client,true}]},
+ {send_ext_info, true}
+ ]
+ ),
+
+ %% Check that the daemon got expected result:
+ receive
+ {result, Pid, {ok,_}} -> ok;
+ {result, Pid, Error} -> ct:fail("Error: ~p",[Error])
+ end.
+
%%%================================================================
%%%==== Internal functions ========================================
%%%================================================================