2011-07-08 13:00:29 +01:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2014-09-19 22:39:48 +01:00
|
|
|
# Force use of English in tests for the moment, for those users that
|
2014-09-19 22:33:33 +01:00
|
|
|
# have a different locale set, since errors are hardcoded below
|
|
|
|
use POSIX qw(setlocale locale_h);
|
2014-09-19 22:39:48 +01:00
|
|
|
setlocale( LC_ALL, "C" );
|
2014-09-19 22:33:33 +01:00
|
|
|
|
2011-07-09 09:00:24 +01:00
|
|
|
use FindBin qw($Bin $Script);
|
2011-07-08 13:00:29 +01:00
|
|
|
use lib "$Bin/../lib";
|
|
|
|
|
2016-03-26 08:18:48 +00:00
|
|
|
# fix path for finding our fake xterm on headless systems that do
|
|
|
|
# not have it installed, such as TravisCI via github
|
|
|
|
BEGIN {
|
|
|
|
$ENV{PATH} = $ENV{PATH} . ':' . $Bin . '/bin';
|
|
|
|
}
|
|
|
|
|
2011-07-08 13:00:29 +01:00
|
|
|
use Test::More;
|
|
|
|
use Test::Trap;
|
2011-07-21 08:23:49 +01:00
|
|
|
use File::Which qw(which);
|
2011-07-25 18:23:07 +01:00
|
|
|
use File::Temp qw(tempdir);
|
2012-11-26 21:42:06 +00:00
|
|
|
use Test::Differences;
|
2011-07-08 13:00:29 +01:00
|
|
|
|
2011-07-09 09:00:24 +01:00
|
|
|
use Readonly;
|
|
|
|
|
2011-08-31 21:01:12 +01:00
|
|
|
BEGIN {
|
|
|
|
use_ok("App::ClusterSSH::Config") || BAIL_OUT('failed to use module');
|
|
|
|
}
|
2011-07-08 13:00:29 +01:00
|
|
|
|
|
|
|
my $config;
|
|
|
|
|
|
|
|
$config = App::ClusterSSH::Config->new();
|
|
|
|
isa_ok( $config, 'App::ClusterSSH::Config' );
|
|
|
|
|
2011-07-09 09:00:24 +01:00
|
|
|
Readonly::Hash my %default_config => {
|
2013-02-15 08:47:09 +00:00
|
|
|
terminal => "xterm",
|
2011-07-08 13:00:29 +01:00
|
|
|
terminal_args => "",
|
|
|
|
terminal_title_opt => "-T",
|
|
|
|
terminal_colorize => 1,
|
|
|
|
terminal_bg_style => 'dark',
|
|
|
|
terminal_allow_send_events => "-xrm '*.VT100.allowSendEvents:true'",
|
|
|
|
terminal_font => "6x13",
|
|
|
|
terminal_size => "80x24",
|
|
|
|
|
|
|
|
use_hotkeys => "yes",
|
2015-11-26 08:53:51 +00:00
|
|
|
key_quit => "Alt-q",
|
2011-07-08 13:00:29 +01:00
|
|
|
key_addhost => "Control-Shift-plus",
|
|
|
|
key_clientname => "Alt-n",
|
|
|
|
key_history => "Alt-h",
|
2013-04-21 22:13:54 +01:00
|
|
|
key_localname => "Alt-l",
|
2011-07-08 13:00:29 +01:00
|
|
|
key_retilehosts => "Alt-r",
|
2014-01-13 18:44:12 +00:00
|
|
|
key_macros_enable => "Alt-p",
|
2011-07-08 13:00:29 +01:00
|
|
|
key_paste => "Control-v",
|
2013-04-21 22:05:17 +01:00
|
|
|
key_username => "Alt-u",
|
2011-07-08 13:00:29 +01:00
|
|
|
mouse_paste => "Button-2",
|
|
|
|
auto_quit => "yes",
|
2011-11-24 21:48:35 +00:00
|
|
|
auto_close => 5,
|
2011-07-08 13:00:29 +01:00
|
|
|
window_tiling => "yes",
|
|
|
|
window_tiling_direction => "right",
|
|
|
|
console_position => "",
|
|
|
|
|
|
|
|
screen_reserve_top => 0,
|
|
|
|
screen_reserve_bottom => 60,
|
|
|
|
screen_reserve_left => 0,
|
|
|
|
screen_reserve_right => 0,
|
|
|
|
|
|
|
|
terminal_reserve_top => 5,
|
|
|
|
terminal_reserve_bottom => 0,
|
|
|
|
terminal_reserve_left => 5,
|
|
|
|
terminal_reserve_right => 0,
|
|
|
|
|
|
|
|
terminal_decoration_height => 10,
|
|
|
|
terminal_decoration_width => 8,
|
|
|
|
|
2011-11-17 22:51:54 +00:00
|
|
|
ssh => '/usr/bin/ssh',
|
|
|
|
|
2013-02-26 20:10:01 +00:00
|
|
|
console => 'console',
|
|
|
|
console_args => '',
|
|
|
|
rsh => 'rsh',
|
|
|
|
rsh_args => "",
|
|
|
|
telnet => 'telnet',
|
|
|
|
telnet_args => "",
|
|
|
|
ssh => 'ssh',
|
|
|
|
ssh_args => "",
|
2015-11-15 22:53:04 +00:00
|
|
|
sftp => 'sftp',
|
|
|
|
sftp_args => "",
|
2011-07-08 13:00:29 +01:00
|
|
|
|
2016-01-23 17:02:52 +00:00
|
|
|
extra_tag_file => "",
|
2013-04-15 21:56:19 +01:00
|
|
|
extra_cluster_file => "",
|
2013-03-25 13:13:03 +00:00
|
|
|
external_cluster_command => '',
|
2017-12-22 11:36:09 +00:00
|
|
|
external_command_mode => '0600',
|
|
|
|
external_command_pipe => '',
|
2011-07-08 13:00:29 +01:00
|
|
|
|
|
|
|
unmap_on_redraw => "no",
|
|
|
|
|
|
|
|
show_history => 0,
|
|
|
|
history_width => 40,
|
|
|
|
history_height => 10,
|
|
|
|
|
|
|
|
command => q{},
|
2012-11-26 21:42:06 +00:00
|
|
|
title => q{15CONFIG.T},
|
|
|
|
comms => q{ssh},
|
2016-09-07 09:25:44 +01:00
|
|
|
hide_menu => 0,
|
2011-07-08 13:00:29 +01:00
|
|
|
max_host_menu_items => 30,
|
|
|
|
|
2014-01-13 18:44:12 +00:00
|
|
|
macros_enabled => 'yes',
|
|
|
|
macro_servername => '%s',
|
|
|
|
macro_hostname => '%h',
|
|
|
|
macro_username => '%u',
|
|
|
|
macro_newline => '%n',
|
|
|
|
macro_version => '%v',
|
|
|
|
|
2011-07-08 13:00:29 +01:00
|
|
|
max_addhost_menu_cluster_items => 6,
|
|
|
|
menu_send_autotearoff => 0,
|
|
|
|
menu_host_autotearoff => 0,
|
|
|
|
|
2016-10-18 21:23:15 +01:00
|
|
|
unique_servers => 0,
|
2011-11-18 22:31:12 +00:00
|
|
|
use_all_a_records => 0,
|
2015-09-21 22:35:16 +01:00
|
|
|
use_natural_sort => 0,
|
2011-11-18 22:31:12 +00:00
|
|
|
|
2015-09-26 09:25:52 -07:00
|
|
|
send_menu_xml_file => $ENV{HOME} . '/.clusterssh/send_menu',
|
2011-07-08 13:00:29 +01:00
|
|
|
|
2017-03-07 22:01:27 +00:00
|
|
|
# Debian #842965
|
|
|
|
auto_wm_decoration_offsets => "no",
|
|
|
|
|
2011-07-08 13:00:29 +01:00
|
|
|
# other bits inheritted from App::ClusterSSH::Base
|
2017-03-04 18:36:44 +00:00
|
|
|
lang => 'en',
|
2013-03-08 07:58:39 +00:00
|
|
|
user => '',
|
2017-04-29 17:08:22 +02:00
|
|
|
rows => -1,
|
|
|
|
cols => -1,
|
2017-05-01 17:24:04 +02:00
|
|
|
|
|
|
|
fillscreen => 'no',
|
2011-07-08 13:00:29 +01:00
|
|
|
};
|
2011-07-09 09:00:24 +01:00
|
|
|
my %expected = %default_config;
|
|
|
|
is_deeply( $config, \%expected, 'default config is correct' );
|
2011-07-08 13:00:29 +01:00
|
|
|
|
2011-07-11 21:00:43 +01:00
|
|
|
$config = App::ClusterSSH::Config->new();
|
2011-07-08 13:00:29 +01:00
|
|
|
trap {
|
2011-07-09 09:00:24 +01:00
|
|
|
$config = $config->validate_args(
|
|
|
|
whoops => 'not there',
|
2011-07-08 14:30:03 +01:00
|
|
|
doesnt_exist => 'whoops',
|
|
|
|
);
|
2011-07-08 13:00:29 +01:00
|
|
|
};
|
2011-07-08 14:30:03 +01:00
|
|
|
isa_ok( $trap->die, 'App::ClusterSSH::Exception::Config' );
|
|
|
|
is( $trap->die,
|
2013-02-26 20:10:01 +00:00
|
|
|
'Unknown configuration parameters: doesnt_exist,whoops' . $/,
|
2011-07-08 14:30:03 +01:00
|
|
|
'got correct error message'
|
|
|
|
);
|
2011-07-09 09:00:24 +01:00
|
|
|
is_deeply(
|
|
|
|
$trap->die->unknown_config,
|
|
|
|
[ 'doesnt_exist', 'whoops' ],
|
|
|
|
'Picked up unknown config array'
|
|
|
|
);
|
2011-07-11 21:00:43 +01:00
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
2011-07-08 14:30:03 +01:00
|
|
|
|
2011-07-09 09:00:24 +01:00
|
|
|
$expected{extra_cluster_file} = '/etc/filename';
|
|
|
|
$expected{rsh_args} = 'some args';
|
|
|
|
$expected{max_addhost_menu_cluster_items} = 120;
|
2011-07-08 14:30:03 +01:00
|
|
|
trap {
|
|
|
|
$config = $config->validate_args(
|
|
|
|
extra_cluster_file => '/etc/filename',
|
|
|
|
rsh_args => 'some args',
|
|
|
|
max_addhost_menu_cluster_items => 120,
|
|
|
|
);
|
|
|
|
};
|
|
|
|
is( $trap->die, undef, 'validated ok' );
|
2011-07-11 21:00:43 +01:00
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
2011-07-09 09:00:24 +01:00
|
|
|
is_deeply( $config, \%expected, 'default config is correct' );
|
|
|
|
|
2011-07-11 22:07:57 +01:00
|
|
|
$config = App::ClusterSSH::Config->new();
|
2011-07-09 09:00:24 +01:00
|
|
|
%expected = %default_config;
|
|
|
|
|
|
|
|
my $file = "$Bin/$Script.doesntexist";
|
|
|
|
trap {
|
|
|
|
$config = $config->parse_config_file( $file, );
|
|
|
|
};
|
2013-03-16 21:56:56 +00:00
|
|
|
isa_ok( $trap->die, 'App::ClusterSSH::Exception::LoadFile' );
|
2011-07-09 09:00:24 +01:00
|
|
|
is( $trap->die,
|
2013-03-16 21:56:56 +00:00
|
|
|
"Unable to read file $file: No such file or directory" . $/,
|
2011-07-09 09:00:24 +01:00
|
|
|
'got correct error message'
|
|
|
|
);
|
2011-07-08 13:00:29 +01:00
|
|
|
|
2011-07-11 21:00:43 +01:00
|
|
|
$file = "$Bin/$Script.file1";
|
|
|
|
note("using $file");
|
2011-07-11 22:07:57 +01:00
|
|
|
$config = App::ClusterSSH::Config->new();
|
|
|
|
%expected = %default_config;
|
|
|
|
$expected{screen_reserve_left} = 100;
|
|
|
|
$expected{screen_reserve_right} = 100;
|
|
|
|
$expected{screen_reserve_top} = 100;
|
|
|
|
$expected{screen_reserve_bottom} = 160;
|
2011-07-11 21:00:43 +01:00
|
|
|
trap {
|
|
|
|
$config = $config->parse_config_file( $file, );
|
|
|
|
};
|
|
|
|
is( $trap->leaveby, 'return', 'returned ok' );
|
|
|
|
is( $trap->die, undef, 'returned ok' );
|
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
|
|
|
is( $trap->stderr, q{}, 'Expecting no STDERR' );
|
|
|
|
is_deeply( $config, \%expected, 'amended config is correct' );
|
|
|
|
|
|
|
|
$file = "$Bin/$Script.file2";
|
|
|
|
note("using $file");
|
2011-07-11 22:07:57 +01:00
|
|
|
$config = App::ClusterSSH::Config->new();
|
2011-07-11 21:00:43 +01:00
|
|
|
%expected = %default_config;
|
|
|
|
trap {
|
|
|
|
$config = $config->parse_config_file( $file, );
|
|
|
|
};
|
|
|
|
is( $trap->leaveby, 'die', 'died ok' );
|
|
|
|
isa_ok( $trap->die, 'App::ClusterSSH::Exception::Config' );
|
2011-07-21 08:23:49 +01:00
|
|
|
is( $trap->die,
|
2013-02-26 20:10:01 +00:00
|
|
|
'Unknown configuration parameters: missing,rubbish' . $/,
|
2011-07-21 08:23:49 +01:00
|
|
|
'die message correct'
|
|
|
|
);
|
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
2011-07-11 21:00:43 +01:00
|
|
|
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
|
|
|
is( $trap->stderr, q{}, 'Expecting no STDERR' );
|
|
|
|
is_deeply( $config, \%expected, 'amended config is correct' );
|
|
|
|
|
2011-07-11 22:07:57 +01:00
|
|
|
$file = "$Bin/$Script.file3";
|
|
|
|
note("using $file");
|
|
|
|
$config = App::ClusterSSH::Config->new();
|
|
|
|
%expected = %default_config;
|
|
|
|
trap {
|
|
|
|
$config = $config->parse_config_file( $file, );
|
|
|
|
};
|
|
|
|
|
|
|
|
is( $trap->leaveby, 'return', 'returned ok' );
|
|
|
|
is( $trap->die, undef, 'returned ok' );
|
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
2011-11-24 21:48:35 +00:00
|
|
|
is( $trap->stderr, q{}, 'Expecting no STDERR' );
|
2011-07-11 22:07:57 +01:00
|
|
|
|
2011-07-21 08:23:49 +01:00
|
|
|
note('find_binary tests');
|
|
|
|
my $path;
|
|
|
|
$config = App::ClusterSSH::Config->new();
|
|
|
|
trap {
|
|
|
|
$path = $config->find_binary();
|
|
|
|
};
|
|
|
|
is( $trap->leaveby, 'die', 'died ok' );
|
|
|
|
isa_ok( $trap->die, 'App::ClusterSSH::Exception::Config' );
|
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
2013-02-26 20:10:01 +00:00
|
|
|
is( $trap->die, 'argument not provided' . $/, 'die message correct' );
|
2011-07-21 08:23:49 +01:00
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
|
|
|
is( $trap->stderr, q{}, 'Expecting no STDERR' );
|
|
|
|
is_deeply( $config, \%expected, 'amended config is correct' );
|
|
|
|
|
|
|
|
trap {
|
|
|
|
$path = $config->find_binary('missing');
|
|
|
|
};
|
|
|
|
is( $trap->leaveby, 'die', 'died ok' );
|
|
|
|
isa_ok( $trap->die, 'App::ClusterSSH::Exception::Config' );
|
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
2011-08-31 21:01:12 +01:00
|
|
|
is( $trap->die,
|
2013-02-26 20:10:01 +00:00
|
|
|
'"missing" binary not found - please amend $PATH or the cssh config file'
|
|
|
|
. $/,
|
2011-08-31 21:01:12 +01:00
|
|
|
'die message correct'
|
|
|
|
);
|
2011-07-21 08:23:49 +01:00
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
|
|
|
is( $trap->stderr, q{}, 'Expecting no STDERR' );
|
|
|
|
is_deeply( $config, \%expected, 'amended config is correct' );
|
|
|
|
|
|
|
|
trap {
|
|
|
|
$path = $config->find_binary('ls');
|
|
|
|
};
|
|
|
|
is( $trap->leaveby, 'return', 'returned ok' );
|
2011-08-31 21:01:12 +01:00
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
2011-07-21 08:23:49 +01:00
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
|
|
|
is( $trap->stderr, q{}, 'Expecting no STDERR' );
|
|
|
|
is_deeply( $config, \%expected, 'amended config is correct' );
|
2014-12-12 17:18:19 +00:00
|
|
|
is( $path, 'ls', 'Found correct path to "ls"' );
|
2011-07-21 08:23:49 +01:00
|
|
|
|
2011-11-25 22:09:33 +00:00
|
|
|
# check for a binary already found
|
|
|
|
my $newpath;
|
|
|
|
trap {
|
|
|
|
$newpath = $config->find_binary($path);
|
|
|
|
};
|
|
|
|
is( $trap->leaveby, 'return', 'returned ok' );
|
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
|
|
|
is( $trap->stderr, q{}, 'Expecting no STDERR' );
|
|
|
|
is_deeply( $config, \%expected, 'amended config is correct' );
|
2014-12-12 17:18:19 +00:00
|
|
|
is( $path, 'ls', 'Found correct path to "ls"' );
|
|
|
|
is( $path, $newpath, 'No change made from find_binary' );
|
2011-11-25 22:09:33 +00:00
|
|
|
|
|
|
|
# give false path to force another search
|
|
|
|
trap {
|
2012-11-26 21:42:06 +00:00
|
|
|
$newpath = $config->find_binary( '/does/not/exist/' . $path );
|
2011-11-25 22:09:33 +00:00
|
|
|
};
|
|
|
|
is( $trap->leaveby, 'return', 'returned ok' );
|
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
|
|
|
is( $trap->stderr, q{}, 'Expecting no STDERR' );
|
|
|
|
is_deeply( $config, \%expected, 'amended config is correct' );
|
2014-12-12 17:18:19 +00:00
|
|
|
is( $path, 'ls', 'Found correct path to "ls"' );
|
|
|
|
is( $path, $newpath, 'No change made from find_binary' );
|
2011-11-25 22:09:33 +00:00
|
|
|
|
2011-07-25 18:23:07 +01:00
|
|
|
note('Checks on loading configs');
|
|
|
|
note('empty dir');
|
|
|
|
$ENV{HOME} = tempdir( CLEANUP => 1 );
|
|
|
|
$config = App::ClusterSSH::Config->new();
|
|
|
|
trap {
|
|
|
|
$config->load_configs();
|
|
|
|
};
|
|
|
|
is( $trap->leaveby, 'return', 'returned ok' );
|
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
2011-08-31 21:01:12 +01:00
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
is( $trap->die, undef, 'die message correct' );
|
|
|
|
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
2013-02-13 22:10:30 +00:00
|
|
|
is( $trap->stderr,
|
2013-02-26 20:10:01 +00:00
|
|
|
'Created new configuration file within $HOME/.clusterssh/' . $/,
|
2013-02-13 22:10:30 +00:00
|
|
|
'Got correct STDERR output for .csshrc'
|
|
|
|
);
|
2011-08-31 21:01:12 +01:00
|
|
|
|
2011-07-25 18:23:07 +01:00
|
|
|
#note(qx/ls -laR $ENV{HOME}/);
|
2011-08-31 21:01:12 +01:00
|
|
|
ok( -d $ENV{HOME} . '/.clusterssh', '.clusterssh dir exists' );
|
|
|
|
ok( -f $ENV{HOME} . '/.clusterssh/config', '.clusterssh config file exists' );
|
2011-07-25 18:23:07 +01:00
|
|
|
is_deeply( $config, \%expected, 'amended config is correct' );
|
|
|
|
$ENV{HOME} = undef;
|
|
|
|
|
|
|
|
note('.csshrc warning');
|
|
|
|
$ENV{HOME} = tempdir( CLEANUP => 1 );
|
2011-08-31 21:01:12 +01:00
|
|
|
open( my $csshrc, '>', $ENV{HOME} . '/.csshrc' );
|
2011-07-25 18:23:07 +01:00
|
|
|
print $csshrc 'auto_quit = no', $/;
|
|
|
|
close($csshrc);
|
2011-08-31 21:01:12 +01:00
|
|
|
$expected{auto_quit} = 'no';
|
2011-07-25 18:23:07 +01:00
|
|
|
$config = App::ClusterSSH::Config->new();
|
|
|
|
trap {
|
|
|
|
$config->load_configs();
|
|
|
|
};
|
|
|
|
is( $trap->leaveby, 'return', 'returned ok' );
|
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
2011-08-31 21:01:12 +01:00
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
is( $trap->die, undef, 'die message correct' );
|
|
|
|
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
|
|
|
is( $trap->stderr,
|
2014-01-13 18:44:12 +00:00
|
|
|
'Moved $HOME/.csshrc to $HOME/.csshrc.DISABLED'
|
2013-02-26 20:10:01 +00:00
|
|
|
. $/
|
|
|
|
. 'Created new configuration file within $HOME/.clusterssh/'
|
|
|
|
. $/,
|
2011-08-31 21:01:12 +01:00
|
|
|
'Got correct STDERR output for .csshrc'
|
|
|
|
);
|
|
|
|
ok( -d $ENV{HOME} . '/.clusterssh', '.clusterssh dir exists' );
|
|
|
|
ok( -f $ENV{HOME} . '/.clusterssh/config', '.clusterssh config file exists' );
|
2011-07-25 18:23:07 +01:00
|
|
|
is_deeply( $config, \%expected, 'amended config is correct' );
|
|
|
|
|
|
|
|
note('.csshrc warning and .clusterssh dir plus config');
|
2013-02-26 20:10:01 +00:00
|
|
|
|
2013-02-13 22:10:30 +00:00
|
|
|
# need to recreate .csshrc as it was just moved
|
|
|
|
open( $csshrc, '>', $ENV{HOME} . '/.csshrc' );
|
|
|
|
print $csshrc 'auto_quit = no', $/;
|
|
|
|
close($csshrc);
|
|
|
|
$expected{auto_quit} = 'no';
|
2011-08-31 21:01:12 +01:00
|
|
|
open( $csshrc, '>', $ENV{HOME} . '/.clusterssh/config' );
|
2011-07-25 18:23:07 +01:00
|
|
|
print $csshrc 'window_tiling = no', $/;
|
|
|
|
close($csshrc);
|
2011-08-31 21:01:12 +01:00
|
|
|
$expected{window_tiling} = 'no';
|
2011-07-25 18:23:07 +01:00
|
|
|
$config = App::ClusterSSH::Config->new();
|
|
|
|
trap {
|
|
|
|
$config->load_configs();
|
|
|
|
};
|
|
|
|
is( $trap->leaveby, 'return', 'returned ok' );
|
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
2011-08-31 21:01:12 +01:00
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
is( $trap->die, undef, 'die message correct' );
|
|
|
|
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
|
|
|
is( $trap->stderr,
|
2013-02-26 20:10:01 +00:00
|
|
|
'Moved $HOME/.csshrc to $HOME/.csshrc.DISABLED' . $/,
|
2011-08-31 21:01:12 +01:00
|
|
|
'Got correct STDERR output for .csshrc'
|
|
|
|
);
|
|
|
|
ok( -d $ENV{HOME} . '/.clusterssh', '.clusterssh dir exists' );
|
|
|
|
ok( -f $ENV{HOME} . '/.clusterssh/config', '.clusterssh config file exists' );
|
2011-07-25 18:23:07 +01:00
|
|
|
is_deeply( $config, \%expected, 'amended config is correct' );
|
|
|
|
|
|
|
|
note('no .csshrc warning and .clusterssh dir');
|
2011-08-31 21:01:12 +01:00
|
|
|
unlink( $ENV{HOME} . '/.csshrc' );
|
|
|
|
$expected{auto_quit} = 'yes';
|
2011-07-25 18:23:07 +01:00
|
|
|
$config = App::ClusterSSH::Config->new();
|
|
|
|
trap {
|
|
|
|
$config->load_configs();
|
|
|
|
};
|
|
|
|
is( $trap->leaveby, 'return', 'returned ok' );
|
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
2011-08-31 21:01:12 +01:00
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
is( $trap->die, undef, 'die message correct' );
|
|
|
|
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
|
|
|
is( $trap->stderr, '', 'Expecting no STDERR' );
|
|
|
|
ok( -d $ENV{HOME} . '/.clusterssh', '.clusterssh dir exists' );
|
|
|
|
ok( -f $ENV{HOME} . '/.clusterssh/config', '.clusterssh config file exists' );
|
2011-07-25 18:23:07 +01:00
|
|
|
is_deeply( $config, \%expected, 'amended config is correct' );
|
|
|
|
|
|
|
|
note('no .csshrc warning, .clusterssh dir plus config + extra config');
|
2011-08-31 21:01:12 +01:00
|
|
|
open( $csshrc, '>', $ENV{HOME} . '/clusterssh.config' );
|
2014-12-12 17:18:19 +00:00
|
|
|
print $csshrc 'terminal_args = something', $/;
|
2011-07-25 18:23:07 +01:00
|
|
|
close($csshrc);
|
2014-12-12 17:18:19 +00:00
|
|
|
$expected{terminal_args} = 'something';
|
2011-07-25 18:23:07 +01:00
|
|
|
$config = App::ClusterSSH::Config->new();
|
|
|
|
trap {
|
2011-08-31 21:01:12 +01:00
|
|
|
$config->load_configs( $ENV{HOME} . '/clusterssh.config' );
|
2011-07-25 18:23:07 +01:00
|
|
|
};
|
|
|
|
is( $trap->leaveby, 'return', 'returned ok' );
|
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
2011-08-31 21:01:12 +01:00
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
is( $trap->die, undef, 'die message correct' );
|
|
|
|
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
|
|
|
is( $trap->stderr, '', 'Expecting no STDERR' );
|
|
|
|
ok( -d $ENV{HOME} . '/.clusterssh', '.clusterssh dir exists' );
|
|
|
|
ok( -f $ENV{HOME} . '/.clusterssh/config', '.clusterssh config file exists' );
|
2011-07-25 18:23:07 +01:00
|
|
|
is_deeply( $config, \%expected, 'amended config is correct' );
|
|
|
|
|
|
|
|
note('no .csshrc warning, .clusterssh dir plus config + more extra configs');
|
2011-08-31 21:01:12 +01:00
|
|
|
open( $csshrc, '>', $ENV{HOME} . '/.clusterssh/config_ABC' );
|
2011-07-25 18:23:07 +01:00
|
|
|
print $csshrc 'ssh_args = something', $/;
|
|
|
|
close($csshrc);
|
2011-08-31 21:01:12 +01:00
|
|
|
$expected{ssh_args} = 'something';
|
2011-07-25 18:23:07 +01:00
|
|
|
$config = App::ClusterSSH::Config->new();
|
|
|
|
trap {
|
2011-08-31 21:01:12 +01:00
|
|
|
$config->load_configs( $ENV{HOME} . '/clusterssh.config', 'ABC' );
|
2011-07-25 18:23:07 +01:00
|
|
|
};
|
|
|
|
is( $trap->leaveby, 'return', 'returned ok' );
|
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
2011-08-31 21:01:12 +01:00
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
is( $trap->die, undef, 'die message correct' );
|
|
|
|
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
|
|
|
is( $trap->stderr, '', 'Expecting no STDERR' );
|
|
|
|
ok( -d $ENV{HOME} . '/.clusterssh', '.clusterssh dir exists' );
|
|
|
|
ok( -f $ENV{HOME} . '/.clusterssh/config', '.clusterssh config file exists' );
|
2011-07-25 18:23:07 +01:00
|
|
|
is_deeply( $config, \%expected, 'amended config is correct' );
|
|
|
|
|
|
|
|
note('check .clusterssh file is an error');
|
|
|
|
$ENV{HOME} = tempdir( CLEANUP => 1 );
|
2011-08-31 21:01:12 +01:00
|
|
|
open( $csshrc, '>', $ENV{HOME} . '/.clusterssh' );
|
2011-07-25 18:23:07 +01:00
|
|
|
print $csshrc 'should_be_dir_not_file = PROBLEM', $/;
|
|
|
|
close($csshrc);
|
|
|
|
$config = App::ClusterSSH::Config->new();
|
|
|
|
trap {
|
|
|
|
$config->write_user_config_file();
|
|
|
|
};
|
|
|
|
is( $trap->leaveby, 'die', 'died ok' );
|
|
|
|
isa_ok( $trap->die, 'App::ClusterSSH::Exception::Config' );
|
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
2011-08-31 21:01:12 +01:00
|
|
|
is( $trap->die,
|
2013-02-26 20:10:01 +00:00
|
|
|
'Unable to create directory $HOME/.clusterssh: File exists' . $/,
|
2011-08-31 21:01:12 +01:00
|
|
|
'die message correct'
|
|
|
|
);
|
2011-07-25 18:23:07 +01:00
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
|
|
|
is( $trap->stderr, q{}, 'Expecting no STDERR' );
|
|
|
|
|
|
|
|
note('check failure to write default config is caught');
|
|
|
|
$ENV{HOME} = tempdir( CLEANUP => 1 );
|
2011-08-31 21:01:12 +01:00
|
|
|
mkdir( $ENV{HOME} . '/.clusterssh' );
|
|
|
|
mkdir( $ENV{HOME} . '/.clusterssh/config' );
|
2011-07-25 18:23:07 +01:00
|
|
|
$config = App::ClusterSSH::Config->new();
|
|
|
|
trap {
|
|
|
|
$config->write_user_config_file();
|
|
|
|
};
|
|
|
|
is( $trap->leaveby, 'die', 'died ok' );
|
|
|
|
isa_ok( $trap->die, 'App::ClusterSSH::Exception::Config' );
|
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
2011-08-31 21:01:12 +01:00
|
|
|
is( $trap->die,
|
2013-02-26 20:10:01 +00:00
|
|
|
'Unable to write default $HOME/.clusterssh/config: Is a directory' . $/,
|
2011-08-31 21:01:12 +01:00
|
|
|
'die message correct'
|
|
|
|
);
|
2011-07-25 18:23:07 +01:00
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
|
|
|
is( $trap->stderr, q{}, 'Expecting no STDERR' );
|
|
|
|
|
|
|
|
note('check .clusterssh errors via load_configs are not fatal');
|
|
|
|
$ENV{HOME} = tempdir( CLEANUP => 1 );
|
2011-08-31 21:01:12 +01:00
|
|
|
open( $csshrc, '>', $ENV{HOME} . '/.clusterssh' );
|
2011-07-25 18:23:07 +01:00
|
|
|
print $csshrc 'should_be_dir_not_file = PROBLEM', $/;
|
|
|
|
close($csshrc);
|
|
|
|
$config = App::ClusterSSH::Config->new();
|
|
|
|
trap {
|
|
|
|
$config->load_configs();
|
|
|
|
};
|
|
|
|
is( $trap->leaveby, 'return', 'died ok' );
|
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
2011-08-31 21:01:12 +01:00
|
|
|
is( $trap->stderr,
|
2013-02-13 17:50:26 +00:00
|
|
|
q{Unable to create directory $HOME/.clusterssh: File exists} . $/ . $/,
|
2011-08-31 21:01:12 +01:00
|
|
|
'Expecting no STDERR'
|
|
|
|
);
|
2011-07-25 18:23:07 +01:00
|
|
|
|
2014-09-19 22:39:48 +01:00
|
|
|
SKIP: {
|
2016-07-24 11:50:16 +02:00
|
|
|
skip "Test inappropriate when running as root", 5 if $< == 0;
|
2014-09-19 22:39:48 +01:00
|
|
|
note('move of .csshrc failure');
|
|
|
|
$ENV{HOME} = tempdir( CLEANUP => 1 );
|
|
|
|
open( $csshrc, '>', $ENV{HOME} . '/.csshrc' );
|
|
|
|
print $csshrc "Something", $/;
|
|
|
|
close($csshrc);
|
|
|
|
open( $csshrc, '>', $ENV{HOME} . '/.csshrc.DISABLED' );
|
|
|
|
print $csshrc "Something else", $/;
|
|
|
|
close($csshrc);
|
|
|
|
chmod( 0666, $ENV{HOME} . '/.csshrc.DISABLED', $ENV{HOME} );
|
|
|
|
$config = App::ClusterSSH::Config->new();
|
|
|
|
trap {
|
|
|
|
$config->write_user_config_file();
|
|
|
|
};
|
|
|
|
is( $trap->leaveby, 'die', 'died ok' );
|
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
|
|
|
is( $trap->stderr, q{}, 'Expecting no STDERR' );
|
|
|
|
is( $trap->die,
|
|
|
|
q{Unable to create directory $HOME/.clusterssh: Permission denied}
|
|
|
|
. $/,
|
|
|
|
'Expected die msg ' . $trap->stderr
|
|
|
|
);
|
|
|
|
chmod( 0755, $ENV{HOME} . '/.csshrc.DISABLED', $ENV{HOME} );
|
|
|
|
}
|
2014-07-02 22:39:36 +01:00
|
|
|
|
2011-07-25 18:23:07 +01:00
|
|
|
note('check failure to write default config is caught');
|
|
|
|
$ENV{HOME} = tempdir( CLEANUP => 1 );
|
2011-08-31 21:01:12 +01:00
|
|
|
mkdir( $ENV{HOME} . '/.clusterssh' );
|
|
|
|
mkdir( $ENV{HOME} . '/.clusterssh/config' );
|
2011-07-25 18:23:07 +01:00
|
|
|
$config = App::ClusterSSH::Config->new();
|
|
|
|
trap {
|
|
|
|
$config->load_configs();
|
|
|
|
};
|
2011-07-28 10:23:49 +01:00
|
|
|
is( $trap->leaveby, 'return', 'returned ok' );
|
2011-08-31 21:01:12 +01:00
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
2011-07-25 18:23:07 +01:00
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
|
|
|
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
2011-08-31 21:01:12 +01:00
|
|
|
is( $trap->stderr,
|
2014-01-13 18:44:12 +00:00
|
|
|
q{Unable to write default $HOME/.clusterssh/config: Is a directory}
|
2013-02-26 20:10:01 +00:00
|
|
|
. $/
|
|
|
|
. $/,
|
2011-08-31 21:01:12 +01:00
|
|
|
'Expecting no STDERR'
|
|
|
|
);
|
2011-07-25 18:23:07 +01:00
|
|
|
|
2011-07-28 10:23:49 +01:00
|
|
|
note('Checking dump');
|
2012-11-26 21:42:06 +00:00
|
|
|
$config = App::ClusterSSH::Config->new(
|
2015-11-15 21:12:10 +00:00
|
|
|
send_menu_xml_file => $ENV{HOME} . '/.clusterssh/send_menu', );
|
2015-11-09 22:46:02 +00:00
|
|
|
|
2011-08-31 21:01:12 +01:00
|
|
|
trap {
|
2011-07-28 10:23:49 +01:00
|
|
|
$config->dump();
|
|
|
|
};
|
2017-03-04 18:34:02 +00:00
|
|
|
my $expected = qq{# Configuration dump produced by "cssh -d"
|
2011-11-24 21:48:35 +00:00
|
|
|
auto_close=5
|
2011-08-31 21:01:12 +01:00
|
|
|
auto_quit=yes
|
2017-03-07 22:01:27 +00:00
|
|
|
auto_wm_decoration_offsets=no
|
2017-04-29 17:08:22 +02:00
|
|
|
cols=-1
|
2013-02-26 20:10:01 +00:00
|
|
|
console=console
|
|
|
|
console_args=
|
2011-08-31 21:01:12 +01:00
|
|
|
console_position=
|
2013-03-25 13:13:03 +00:00
|
|
|
external_cluster_command=
|
2017-12-22 11:36:09 +00:00
|
|
|
external_command_mode=0600
|
|
|
|
external_command_pipe=
|
2011-08-31 21:01:12 +01:00
|
|
|
extra_cluster_file=
|
2016-01-23 17:02:52 +00:00
|
|
|
extra_tag_file=
|
2017-05-01 17:24:04 +02:00
|
|
|
fillscreen=no
|
2016-09-07 09:25:44 +01:00
|
|
|
hide_menu=0
|
2011-08-31 21:01:12 +01:00
|
|
|
history_height=10
|
|
|
|
history_width=40
|
2011-07-28 10:23:49 +01:00
|
|
|
key_addhost=Control-Shift-plus
|
|
|
|
key_clientname=Alt-n
|
2011-08-31 21:01:12 +01:00
|
|
|
key_history=Alt-h
|
2013-04-21 22:13:54 +01:00
|
|
|
key_localname=Alt-l
|
2014-01-13 18:44:12 +00:00
|
|
|
key_macros_enable=Alt-p
|
2011-08-31 21:01:12 +01:00
|
|
|
key_paste=Control-v
|
2015-11-26 08:53:51 +00:00
|
|
|
key_quit=Alt-q
|
2011-07-28 10:23:49 +01:00
|
|
|
key_retilehosts=Alt-r
|
2013-04-21 22:05:17 +01:00
|
|
|
key_username=Alt-u
|
2011-08-31 21:01:12 +01:00
|
|
|
lang=en
|
2014-01-13 18:44:12 +00:00
|
|
|
macro_hostname=%h
|
|
|
|
macro_newline=%n
|
|
|
|
macro_servername=%s
|
|
|
|
macro_username=%u
|
|
|
|
macro_version=%v
|
|
|
|
macros_enabled=yes
|
2011-08-31 21:01:12 +01:00
|
|
|
max_addhost_menu_cluster_items=6
|
|
|
|
max_host_menu_items=30
|
|
|
|
menu_host_autotearoff=0
|
|
|
|
menu_send_autotearoff=0
|
|
|
|
mouse_paste=Button-2
|
2017-04-29 17:08:22 +02:00
|
|
|
rows=-1
|
2013-02-13 21:41:30 +00:00
|
|
|
rsh=rsh
|
2011-07-28 10:23:49 +01:00
|
|
|
rsh_args=
|
2011-08-31 21:01:12 +01:00
|
|
|
screen_reserve_bottom=60
|
|
|
|
screen_reserve_left=0
|
|
|
|
screen_reserve_right=0
|
2011-07-28 10:23:49 +01:00
|
|
|
screen_reserve_top=0
|
2015-09-26 09:25:52 -07:00
|
|
|
send_menu_xml_file=} . $ENV{HOME} . qq{/.clusterssh/send_menu
|
2015-11-15 22:53:04 +00:00
|
|
|
sftp=sftp
|
|
|
|
sftp_args=
|
2011-08-31 21:01:12 +01:00
|
|
|
show_history=0
|
2013-02-13 21:41:30 +00:00
|
|
|
ssh=ssh
|
2011-08-31 21:01:12 +01:00
|
|
|
ssh_args=
|
2013-02-13 21:41:30 +00:00
|
|
|
telnet=telnet
|
2011-08-31 21:01:12 +01:00
|
|
|
telnet_args=
|
2013-02-15 08:47:09 +00:00
|
|
|
terminal=xterm
|
2011-08-31 21:01:12 +01:00
|
|
|
terminal_allow_send_events=-xrm '*.VT100.allowSendEvents:true'
|
2011-07-28 10:23:49 +01:00
|
|
|
terminal_args=
|
2011-08-31 21:01:12 +01:00
|
|
|
terminal_bg_style=dark
|
|
|
|
terminal_colorize=1
|
|
|
|
terminal_decoration_height=10
|
2011-07-28 10:23:49 +01:00
|
|
|
terminal_decoration_width=8
|
|
|
|
terminal_font=6x13
|
|
|
|
terminal_reserve_bottom=0
|
2011-08-31 21:01:12 +01:00
|
|
|
terminal_reserve_left=5
|
|
|
|
terminal_reserve_right=0
|
|
|
|
terminal_reserve_top=5
|
2011-07-28 10:23:49 +01:00
|
|
|
terminal_size=80x24
|
2011-08-31 21:01:12 +01:00
|
|
|
terminal_title_opt=-T
|
2016-10-18 21:23:15 +01:00
|
|
|
unique_servers=0
|
2011-08-31 21:01:12 +01:00
|
|
|
unmap_on_redraw=no
|
2011-11-18 22:31:12 +00:00
|
|
|
use_all_a_records=0
|
2011-08-31 21:01:12 +01:00
|
|
|
use_hotkeys=yes
|
2015-09-21 22:35:16 +01:00
|
|
|
use_natural_sort=0
|
2013-03-08 07:58:39 +00:00
|
|
|
#user=
|
2011-08-31 21:01:12 +01:00
|
|
|
window_tiling=yes
|
|
|
|
window_tiling_direction=right
|
2012-11-26 21:42:06 +00:00
|
|
|
};
|
2012-09-21 02:11:03 -03:00
|
|
|
|
2011-07-28 10:23:49 +01:00
|
|
|
isa_ok( $config, "App::ClusterSSH::Config" );
|
2012-11-26 21:42:06 +00:00
|
|
|
is( $trap->die, undef, 'die message correct' );
|
|
|
|
eq_or_diff( $trap->stdout, $expected, 'Expecting no STDOUT' );
|
|
|
|
is( $trap->stderr, q{}, 'Expecting no STDERR' );
|
2011-07-28 10:23:49 +01:00
|
|
|
|
2011-07-08 13:00:29 +01:00
|
|
|
done_testing();
|