aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ssh')
-rw-r--r--lib/ssh/test/ssh_connection_SUITE.erl66
-rw-r--r--lib/ssh/test/ssh_to_openssh_SUITE.erl45
2 files changed, 88 insertions, 23 deletions
diff --git a/lib/ssh/test/ssh_connection_SUITE.erl b/lib/ssh/test/ssh_connection_SUITE.erl
index 3c537d719c..553d0f5720 100644
--- a/lib/ssh/test/ssh_connection_SUITE.erl
+++ b/lib/ssh/test/ssh_connection_SUITE.erl
@@ -36,7 +36,7 @@
all() ->
[
- {group, openssh_payload},
+ {group, openssh},
start_subsystem_on_closed_channel,
interrupted_send,
start_shell,
@@ -49,11 +49,19 @@ all() ->
stop_listener
].
groups() ->
- [{openssh_payload, [], [simple_exec,
- small_cat,
- big_cat,
- send_after_exit
- ]}].
+ [{openssh, [], payload() ++ ptty()}].
+
+payload() ->
+ [simple_exec,
+ small_cat,
+ big_cat,
+ send_after_exit].
+
+ptty() ->
+ [ptty_alloc_default,
+ ptty_alloc,
+ ptty_alloc_pixel].
+
%%--------------------------------------------------------------------
init_per_suite(Config) ->
case catch crypto:start() of
@@ -67,7 +75,7 @@ end_per_suite(_Config) ->
crypto:stop().
%%--------------------------------------------------------------------
-init_per_group(openssh_payload, _Config) ->
+init_per_group(openssh, _Config) ->
case gen_tcp:connect("localhost", 22, []) of
{error,econnrefused} ->
{skip,"No openssh deamon"};
@@ -242,6 +250,42 @@ send_after_exit(Config) when is_list(Config) ->
end.
%%--------------------------------------------------------------------
+ptty_alloc_default() ->
+ [{doc, "Test sending PTTY alloc message with only defaults."}].
+
+ptty_alloc_default(Config) when is_list(Config) ->
+ ConnectionRef = ssh_test_lib:connect(?SSH_DEFAULT_PORT, [{silently_accept_hosts, true},
+ {user_interaction, false}]),
+ {ok, ChannelId} = ssh_connection:session_channel(ConnectionRef, infinity),
+ success = ssh_connection:ptty_alloc(ConnectionRef, ChannelId, []),
+ ssh:close(ConnectionRef).
+
+%%--------------------------------------------------------------------
+ptty_alloc() ->
+ [{doc, "Test sending PTTY alloc message with width,height options."}].
+
+ptty_alloc(Config) when is_list(Config) ->
+ ConnectionRef = ssh_test_lib:connect(?SSH_DEFAULT_PORT, [{silently_accept_hosts, true},
+ {user_interaction, false}]),
+ {ok, ChannelId} = ssh_connection:session_channel(ConnectionRef, infinity),
+ success = ssh_connection:ptty_alloc(ConnectionRef, ChannelId,
+ [{term, default_term()}, {width, 70}, {high, 20}]),
+ ssh:close(ConnectionRef).
+
+
+%%--------------------------------------------------------------------
+ptty_alloc_pixel() ->
+ [{doc, "Test sending PTTY alloc message pixel options."}].
+
+ptty_alloc_pixel(Config) when is_list(Config) ->
+ ConnectionRef = ssh_test_lib:connect(?SSH_DEFAULT_PORT, [{silently_accept_hosts, true},
+ {user_interaction, false}]),
+ {ok, ChannelId} = ssh_connection:session_channel(ConnectionRef, infinity),
+ success = ssh_connection:ptty_alloc(ConnectionRef, ChannelId,
+ [{term, default_term()}, {pixel_widh, 630}, {pixel_hight, 470}]),
+ ssh:close(ConnectionRef).
+
+%%--------------------------------------------------------------------
start_subsystem_on_closed_channel(Config) ->
PrivDir = ?config(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
@@ -603,3 +647,11 @@ ssh_exec(Cmd) ->
spawn(fun() ->
io:format(Cmd ++ "\n")
end).
+
+default_term() ->
+ case os:getenv("TERM") of
+ false ->
+ "vt100";
+ Str when is_list(Str)->
+ Str
+ end.
diff --git a/lib/ssh/test/ssh_to_openssh_SUITE.erl b/lib/ssh/test/ssh_to_openssh_SUITE.erl
index 41fbd324c4..af70eeb46c 100644
--- a/lib/ssh/test/ssh_to_openssh_SUITE.erl
+++ b/lib/ssh/test/ssh_to_openssh_SUITE.erl
@@ -120,13 +120,8 @@ erlang_shell_client_openssh_server(Config) when is_list(Config) ->
receive_hej(),
IO ! {input, self(), "exit\n"},
receive_logout(),
- receive
- {'EXIT', Shell, normal} ->
- ok;
- Other1 ->
- ct:fail({unexpected_msg, Other1})
- end.
-
+ receive_normal_exit(Shell).
+
%--------------------------------------------------------------------
erlang_client_openssh_server_exec() ->
[{doc, "Test api function ssh_connection:exec"}].
@@ -529,11 +524,22 @@ erlang_client_openssh_server_nonexistent_subsystem(Config) when is_list(Config)
%%--------------------------------------------------------------------
receive_hej() ->
receive
- <<"Hej\n">> = Hej->
+ <<"Hej", _binary>> = Hej ->
+ ct:pal("Expected result: ~p~n", [Hej]);
+ <<"Hej\n", _binary>> = Hej ->
+ ct:pal("Expected result: ~p~n", [Hej]);
+ <<"Hej\r\n", _/binary>> = Hej ->
ct:pal("Expected result: ~p~n", [Hej]);
Info ->
- ct:pal("Extra info: ~p~n", [Info]),
- receive_hej()
+ Lines = binary:split(Info, [<<"\r\n">>], [global]),
+ case lists:member(<<"Hej">>, Lines) of
+ true ->
+ ct:pal("Expected result found in lines: ~p~n", [Lines]),
+ ok;
+ false ->
+ ct:pal("Extra info: ~p~n", [Info]),
+ receive_hej()
+ end
end.
receive_logout() ->
@@ -543,13 +549,20 @@ receive_logout() ->
<<"Connection closed">> ->
ok
end;
- <<"TERM environment variable not set.\n">> -> %% Windows work around
- receive_logout();
- Other0 ->
- ct:fail({unexpected_msg, Other0})
- end.
-
+ Info ->
+ ct:pal("Extra info when logging out: ~p~n", [Info]),
+ receive_logout()
+ end.
+receive_normal_exit(Shell) ->
+ receive
+ {'EXIT', Shell, normal} ->
+ ok;
+ <<"\r\n">> ->
+ receive_normal_exit(Shell);
+ Other ->
+ ct:fail({unexpected_msg, Other})
+ end.
%%--------------------------------------------------------------------
%%--------------------------------------------------------------------