mirror of
https://github.com/duncs/clusterssh.git
synced 2025-04-22 01:12:24 +00:00
Correct tests for recent changes
This commit is contained in:
parent
b3fa4348ce
commit
c02196067b
1 changed files with 89 additions and 55 deletions
144
t/10host.t
144
t/10host.t
|
@ -12,14 +12,18 @@ BEGIN { use_ok("App::ClusterSSH::Host") }
|
|||
my $host;
|
||||
|
||||
eval { $host = App::ClusterSSH::Host->new(); };
|
||||
like( $@, qr/hostname is undefined/, 'eval error - hostname is undefined (method)' );
|
||||
like(
|
||||
$@,
|
||||
qr/hostname is undefined/,
|
||||
'eval error - hostname is undefined (method)'
|
||||
);
|
||||
|
||||
diag('Checking IPv4 type addresses') if ( $ENV{TEST_VERBOSE} );
|
||||
$host = App::ClusterSSH::Host->new( hostname => 'hostname' );
|
||||
is( $host, 'hostname', 'stringify works' );
|
||||
is( $host->get_hostname, 'hostname', 'hostname set' );
|
||||
is( $host->get_port, undef, 'checking set works' );
|
||||
is( $host->get_username, undef, 'username is undef' );
|
||||
is( $host->get_port, q{}, 'checking set works' );
|
||||
is( $host->get_username, q{}, 'username is unset' );
|
||||
is( $host->get_realname, 'hostname', 'realname set' );
|
||||
|
||||
$host->set_port(2323);
|
||||
|
@ -27,14 +31,14 @@ $host->set_port(2323);
|
|||
is( $host, 'hostname', 'stringify works' );
|
||||
is( $host->get_hostname, 'hostname', 'checking set works' );
|
||||
is( $host->get_port, 2323, 'checking set works' );
|
||||
is( $host->get_username, undef, 'username is undef' );
|
||||
is( $host->get_username, q{}, 'username is unset' );
|
||||
is( $host->get_realname, 'hostname', 'realname set' );
|
||||
|
||||
$host->set_username('username');
|
||||
|
||||
is( $host->get_hostname, 'hostname', 'checking set works' );
|
||||
is( $host->get_port, 2323, 'checking set works' );
|
||||
is( $host->get_username, 'username', 'username is undef' );
|
||||
is( $host->get_username, 'username', 'username is unset' );
|
||||
is( $host->get_realname, 'hostname', 'realname set' );
|
||||
|
||||
$host = undef;
|
||||
|
@ -45,8 +49,8 @@ isa_ok( $host, "App::ClusterSSH::Host" );
|
|||
|
||||
is( $host, 'hostname', 'stringify works' );
|
||||
is( $host->get_hostname, 'hostname', 'hostname set' );
|
||||
is( $host->get_port, undef, 'checking set works' );
|
||||
is( $host->get_username, undef, 'username is undef' );
|
||||
is( $host->get_port, q{}, 'checking set works' );
|
||||
is( $host->get_username, q{}, 'username is unset' );
|
||||
is( $host->get_realname, 'hostname', 'realname set' );
|
||||
|
||||
$host->set_port(2323);
|
||||
|
@ -54,14 +58,14 @@ $host->set_port(2323);
|
|||
is( $host, 'hostname', 'stringify works' );
|
||||
is( $host->get_hostname, 'hostname', 'checking set works' );
|
||||
is( $host->get_port, 2323, 'checking set works' );
|
||||
is( $host->get_username, undef, 'username is undef' );
|
||||
is( $host->get_username, q{}, 'username is unset' );
|
||||
is( $host->get_realname, 'hostname', 'realname set' );
|
||||
|
||||
$host->set_username('username');
|
||||
|
||||
is( $host->get_hostname, 'hostname', 'checking set works' );
|
||||
is( $host->get_port, 2323, 'checking set works' );
|
||||
is( $host->get_username, 'username', 'username is undef' );
|
||||
is( $host->get_username, 'username', 'username is unset' );
|
||||
is( $host->get_realname, 'hostname', 'realname set' );
|
||||
|
||||
$host = undef;
|
||||
|
@ -76,14 +80,14 @@ isa_ok( $host, "App::ClusterSSH::Host" );
|
|||
is( $host, 'hostname', 'stringify works' );
|
||||
is( $host->get_hostname, 'hostname', 'hostname set' );
|
||||
is( $host->get_port, 2323, 'checking set works' );
|
||||
is( $host->get_username, undef, 'username is undef' );
|
||||
is( $host->get_username, q{}, 'username is unset' );
|
||||
is( $host->get_realname, 'hostname', 'realname set' );
|
||||
|
||||
$host->set_username('username');
|
||||
|
||||
is( $host->get_hostname, 'hostname', 'checking set works' );
|
||||
is( $host->get_port, 2323, 'checking set works' );
|
||||
is( $host->get_username, 'username', 'username is undef' );
|
||||
is( $host->get_username, 'username', 'username is unset' );
|
||||
is( $host->get_realname, 'hostname', 'realname set' );
|
||||
|
||||
$host = undef;
|
||||
|
@ -97,7 +101,7 @@ isa_ok( $host, "App::ClusterSSH::Host" );
|
|||
|
||||
is( $host, 'hostname', 'stringify works' );
|
||||
is( $host->get_hostname, 'hostname', 'hostname set' );
|
||||
is( $host->get_port, undef, 'checking set works' );
|
||||
is( $host->get_port, q{}, 'checking set works' );
|
||||
is( $host->get_username, 'username', 'username is set' );
|
||||
is( $host->get_realname, 'hostname', 'realname set' );
|
||||
|
||||
|
@ -134,16 +138,16 @@ $host = App::ClusterSSH::Host->parse_host_string('hostname');
|
|||
isa_ok( $host, "App::ClusterSSH::Host" );
|
||||
is( $host, 'hostname', 'stringify works' );
|
||||
is( $host->get_hostname, 'hostname', 'checking set works' );
|
||||
is( $host->get_port, undef, 'checking set works' );
|
||||
is( $host->get_username, undef, 'username is undef' );
|
||||
is( $host->get_port, q{}, 'checking set works' );
|
||||
is( $host->get_username, q{}, 'username is unset' );
|
||||
is( $host->get_realname, 'hostname', 'realname set' );
|
||||
|
||||
$host = App::ClusterSSH::Host->parse_host_string('host%name');
|
||||
isa_ok( $host, "App::ClusterSSH::Host" );
|
||||
is( $host, 'host%name', 'stringify works' );
|
||||
is( $host->get_hostname, 'host%name', 'checking set works' );
|
||||
is( $host->get_port, undef, 'checking set works' );
|
||||
is( $host->get_username, undef, 'username is undef' );
|
||||
is( $host->get_port, q{}, 'checking set works' );
|
||||
is( $host->get_username, q{}, 'username is unset' );
|
||||
is( $host->get_realname, 'host%name', 'realname set' );
|
||||
|
||||
$host = undef;
|
||||
|
@ -154,7 +158,7 @@ isa_ok( $host, "App::ClusterSSH::Host" );
|
|||
is( $host, 'hostname', 'stringify works' );
|
||||
is( $host->get_hostname, 'hostname', 'checking set works' );
|
||||
is( $host->get_port, 2323, 'checking set works' );
|
||||
is( $host->get_username, undef, 'username is undef' );
|
||||
is( $host->get_username, q{}, 'username is unset' );
|
||||
is( $host->get_realname, 'hostname', 'realname set' );
|
||||
|
||||
$host = App::ClusterSSH::Host->parse_host_string('host%name:2323');
|
||||
|
@ -162,7 +166,7 @@ isa_ok( $host, "App::ClusterSSH::Host" );
|
|||
is( $host, 'host%name', 'stringify works' );
|
||||
is( $host->get_hostname, 'host%name', 'checking set works' );
|
||||
is( $host->get_port, 2323, 'checking set works' );
|
||||
is( $host->get_username, undef, 'username is undef' );
|
||||
is( $host->get_username, q{}, 'username is unset' );
|
||||
is( $host->get_realname, 'host%name', 'realname set' );
|
||||
|
||||
$host = undef;
|
||||
|
@ -191,7 +195,7 @@ $host = App::ClusterSSH::Host->parse_host_string('username@hostname');
|
|||
isa_ok( $host, "App::ClusterSSH::Host" );
|
||||
is( $host, 'hostname', 'stringify works' );
|
||||
is( $host->get_hostname, 'hostname', 'checking set works' );
|
||||
is( $host->get_port, undef, 'checking set works' );
|
||||
is( $host->get_port, q{}, 'checking set works' );
|
||||
is( $host->get_username, 'username', 'username is set' );
|
||||
is( $host->get_realname, 'hostname', 'realname set' );
|
||||
|
||||
|
@ -199,7 +203,7 @@ $host = App::ClusterSSH::Host->parse_host_string('username@host%name');
|
|||
isa_ok( $host, "App::ClusterSSH::Host" );
|
||||
is( $host, 'host%name', 'stringify works' );
|
||||
is( $host->get_hostname, 'host%name', 'checking set works' );
|
||||
is( $host->get_port, undef, 'checking set works' );
|
||||
is( $host->get_port, q{}, 'checking set works' );
|
||||
is( $host->get_username, 'username', 'username is set' );
|
||||
is( $host->get_realname, 'host%name', 'realname set' );
|
||||
|
||||
|
@ -209,8 +213,8 @@ $host = App::ClusterSSH::Host->parse_host_string('127.0.0.1');
|
|||
isa_ok( $host, "App::ClusterSSH::Host" );
|
||||
is( $host, '127.0.0.1', 'stringify works' );
|
||||
is( $host->get_hostname, '127.0.0.1', 'checking set works' );
|
||||
is( $host->get_port, undef, 'checking set works' );
|
||||
is( $host->get_username, undef, 'username is undef' );
|
||||
is( $host->get_port, q{}, 'checking set works' );
|
||||
is( $host->get_username, q{}, 'username is unset' );
|
||||
is( $host->get_realname, '127.0.0.1', 'realname set' );
|
||||
|
||||
$host = undef;
|
||||
|
@ -222,7 +226,7 @@ isa_ok( $host, "App::ClusterSSH::Host" );
|
|||
is( $host, '127.0.0.1', 'stringify works' );
|
||||
is( $host->get_hostname, '127.0.0.1', 'checking set works' );
|
||||
is( $host->get_port, 2323, 'checking set works' );
|
||||
is( $host->get_username, undef, 'username is undef' );
|
||||
is( $host->get_username, q{}, 'username is unset' );
|
||||
is( $host->get_realname, '127.0.0.1', 'realname set' );
|
||||
|
||||
$host = undef;
|
||||
|
@ -244,7 +248,7 @@ isa_ok( $host, "App::ClusterSSH::Host" );
|
|||
|
||||
is( $host, '127.0.0.1', 'stringify works' );
|
||||
is( $host->get_hostname, '127.0.0.1', 'checking set works' );
|
||||
is( $host->get_port, undef, 'checking set works' );
|
||||
is( $host->get_port, q{}, 'checking set works' );
|
||||
is( $host->get_username, 'username', 'username is set' );
|
||||
is( $host->get_realname, '127.0.0.1', 'realname set' );
|
||||
|
||||
|
@ -257,8 +261,8 @@ $host = App::ClusterSSH::Host->parse_host_string('::1');
|
|||
isa_ok( $host, "App::ClusterSSH::Host" );
|
||||
is( $host, '::1', 'stringify works' );
|
||||
is( $host->get_hostname, '::1', 'checking set works' );
|
||||
is( $host->get_port, undef, 'port is undef' );
|
||||
is( $host->get_username, undef, 'username is undef' );
|
||||
is( $host->get_port, q{}, 'port is unset' );
|
||||
is( $host->get_username, q{}, 'username is unset' );
|
||||
is( $host->get_realname, '::1', 'realname set' );
|
||||
|
||||
$host = undef;
|
||||
|
@ -268,9 +272,9 @@ $host = App::ClusterSSH::Host->parse_host_string('username@::1');
|
|||
isa_ok( $host, "App::ClusterSSH::Host" );
|
||||
is( $host, '::1', 'stringify works' );
|
||||
is( $host->get_hostname, '::1', 'checking set works' );
|
||||
is( $host->get_port, undef, 'port is undef' );
|
||||
is( $host->get_port, q{}, 'port is unset' );
|
||||
is( $host->get_username, 'username', 'username is set' );
|
||||
is( $host->get_realname, '::1', 'realname set' );
|
||||
is( $host->get_realname, '::1', 'realname set' );
|
||||
|
||||
$host = undef;
|
||||
is( $host, undef, 'starting afresh' );
|
||||
|
@ -279,8 +283,8 @@ $host = App::ClusterSSH::Host->parse_host_string('[::1]');
|
|||
isa_ok( $host, "App::ClusterSSH::Host" );
|
||||
is( $host, '::1', 'stringify works' );
|
||||
is( $host->get_hostname, '::1', 'checking set works' );
|
||||
is( $host->get_port, undef, 'port is undef' );
|
||||
is( $host->get_username, undef, 'username is undef' );
|
||||
is( $host->get_port, q{}, 'port is unset' );
|
||||
is( $host->get_username, q{}, 'username is unset' );
|
||||
is( $host->get_realname, '::1', 'realname set' );
|
||||
|
||||
$host = undef;
|
||||
|
@ -290,9 +294,9 @@ $host = App::ClusterSSH::Host->parse_host_string('username@[::1]');
|
|||
isa_ok( $host, "App::ClusterSSH::Host" );
|
||||
is( $host, '::1', 'stringify works' );
|
||||
is( $host->get_hostname, '::1', 'checking set works' );
|
||||
is( $host->get_port, undef, 'port is undef' );
|
||||
is( $host->get_port, q{}, 'port is unset' );
|
||||
is( $host->get_username, 'username', 'username is set' );
|
||||
is( $host->get_realname, '::1', 'realname set' );
|
||||
is( $host->get_realname, '::1', 'realname set' );
|
||||
|
||||
$host = undef;
|
||||
is( $host, undef, 'starting afresh' );
|
||||
|
@ -302,7 +306,7 @@ isa_ok( $host, "App::ClusterSSH::Host" );
|
|||
is( $host, '::1', 'stringify works' );
|
||||
is( $host->get_hostname, '::1', 'checking set works' );
|
||||
is( $host->get_port, 22, 'checking port set' );
|
||||
is( $host->get_username, undef, 'username is undef' );
|
||||
is( $host->get_username, q{}, 'username is unset' );
|
||||
is( $host->get_realname, '::1', 'realname set' );
|
||||
|
||||
$host = undef;
|
||||
|
@ -314,66 +318,96 @@ is( $host, '::1', 'stringify works' );
|
|||
is( $host->get_hostname, '::1', 'checking set works' );
|
||||
is( $host->get_port, 22, 'checking port set' );
|
||||
is( $host->get_username, 'username', 'username is set' );
|
||||
is( $host->get_realname, '::1', 'realname set' );
|
||||
is( $host->get_realname, '::1', 'realname set' );
|
||||
|
||||
$host = undef;
|
||||
is( $host, undef, 'starting afresh' );
|
||||
|
||||
$host = App::ClusterSSH::Host->parse_host_string('2001:0db8:85a3:0000:0000:8a2e:0370:7334');
|
||||
$host = App::ClusterSSH::Host->parse_host_string(
|
||||
'2001:0db8:85a3:0000:0000:8a2e:0370:7334');
|
||||
isa_ok( $host, "App::ClusterSSH::Host" );
|
||||
is( $host, '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'stringify works' );
|
||||
is( $host->get_hostname, '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'checking set works' );
|
||||
is( $host->get_port, undef, 'port is undef' );
|
||||
is( $host->get_username, undef, 'username is undef' );
|
||||
is( $host->get_realname, '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'realname set' );
|
||||
is( $host, '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'stringify works' );
|
||||
is( $host->get_hostname,
|
||||
'2001:0db8:85a3:0000:0000:8a2e:0370:7334',
|
||||
'checking set works'
|
||||
);
|
||||
is( $host->get_port, q{}, 'port is unset' );
|
||||
is( $host->get_username, q{}, 'username is unset' );
|
||||
is( $host->get_realname, '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
|
||||
'realname set' );
|
||||
|
||||
$host = undef;
|
||||
is( $host, undef, 'starting afresh' );
|
||||
|
||||
trap {
|
||||
$host = App::ClusterSSH::Host->parse_host_string('2001:0db8:85a3::8a2e:0370:7334');
|
||||
$host = App::ClusterSSH::Host->parse_host_string(
|
||||
'2001:0db8:85a3::8a2e:0370:7334');
|
||||
};
|
||||
is( $trap->leaveby, 'return', 'returned ok' );
|
||||
is( $trap->die, undef, 'returned ok' );
|
||||
isa_ok( $host, "App::ClusterSSH::Host" );
|
||||
is( $host, '2001:0db8:85a3::8a2e:0370:7334', 'stringify works' );
|
||||
|
||||
is( $trap->stdout, '', 'Expecting no STDOUT' );
|
||||
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
||||
is( $trap->stderr =~ tr/\n//, 2, 'got correct number of print lines' );
|
||||
like( $trap->stderr, qr/^Ambiguous host string: "2001:0db8:85a3::8a2e:0370:7334/, 'checking warning output' );
|
||||
like( $trap->stderr, qr/Assuming you meant "\[2001:0db8:85a3::8a2e:0370:7334\]"?/, 'checking warning output' );
|
||||
like(
|
||||
$trap->stderr,
|
||||
qr/^Ambiguous host string: "2001:0db8:85a3::8a2e:0370:7334/,
|
||||
'checking warning output'
|
||||
);
|
||||
like(
|
||||
$trap->stderr,
|
||||
qr/Assuming you meant "\[2001:0db8:85a3::8a2e:0370:7334\]"?/,
|
||||
'checking warning output'
|
||||
);
|
||||
|
||||
is( $host->get_hostname, '2001:0db8:85a3::8a2e:0370:7334', 'checking set works' );
|
||||
is( $host->get_port, undef, 'port is undef' );
|
||||
is( $host->get_username, undef, 'username is undef' );
|
||||
is( $host->get_hostname,
|
||||
'2001:0db8:85a3::8a2e:0370:7334',
|
||||
'checking set works'
|
||||
);
|
||||
is( $host->get_port, q{}, 'port is unset' );
|
||||
is( $host->get_username, q{}, 'username is unset' );
|
||||
is( $host->get_realname, '2001:0db8:85a3::8a2e:0370:7334', 'realname set' );
|
||||
|
||||
$host = undef;
|
||||
is( $host, undef, 'starting afresh' );
|
||||
|
||||
trap {
|
||||
$host = App::ClusterSSH::Host->new( hostname => 'ssh_test', ssh_config => $Bin . '/10host_ssh_config', );
|
||||
$host = App::ClusterSSH::Host->new(
|
||||
hostname => 'ssh_test',
|
||||
ssh_config => $Bin . '/10host_ssh_config',
|
||||
);
|
||||
};
|
||||
is( $trap->leaveby, 'return', 'returned ok' );
|
||||
is( $trap->die, undef, 'returned ok' );
|
||||
isa_ok( $host, "App::ClusterSSH::Host" );
|
||||
is( $host, 'ssh_test', 'stringify works' );
|
||||
is( $host->check_ssh_hostname, 0, 'check_ssh_hostname ok for ssh_test', );
|
||||
is( $host, 'ssh_test', 'stringify works' );
|
||||
is( $host->check_ssh_hostname, 0, 'check_ssh_hostname ok for ssh_test', );
|
||||
|
||||
for my $hostname ( 'server1', 'server2', 'server3', 'server4', 'server-5', 'server5.domain.name', 'server-6.domain.name' ) {
|
||||
for my $hostname (
|
||||
'server1', 'server2',
|
||||
'server3', 'server4',
|
||||
'server-5', 'server5.domain.name',
|
||||
'server-6.domain.name'
|
||||
)
|
||||
{
|
||||
|
||||
$host = undef;
|
||||
is( $host, undef, 'starting afresh for ssh hostname checks' );
|
||||
|
||||
trap {
|
||||
$host = App::ClusterSSH::Host->new( hostname => $hostname, ssh_config => $Bin . '/10host_ssh_config', );
|
||||
$host = App::ClusterSSH::Host->new(
|
||||
hostname => $hostname,
|
||||
ssh_config => $Bin . '/10host_ssh_config',
|
||||
);
|
||||
};
|
||||
is( $trap->leaveby, 'return', 'returned ok' );
|
||||
is( $trap->die, undef, 'returned ok' );
|
||||
isa_ok( $host, "App::ClusterSSH::Host" );
|
||||
is( $host, $hostname, 'stringify works' );
|
||||
is( $host->check_ssh_hostname, 1, 'check_ssh_hostname ok for '. $hostname );
|
||||
is( $host->get_realname, $hostname, 'realname set' );
|
||||
is( $host, $hostname, 'stringify works' );
|
||||
is( $host->check_ssh_hostname, 1,
|
||||
'check_ssh_hostname ok for ' . $hostname );
|
||||
is( $host->get_realname, $hostname, 'realname set' );
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue