App-ClusterSSH
view release on metacpan or search on metacpan
username => q{},
realname => '127.0.0.1',
geometry => q{},
type => 'ipv4',
},
'127.0.0.1:3232=1x1+1+1' => {
hostname => '127.0.0.1',
port => 3232,
username => q{},
realname => '127.0.0.1',
geometry => '1x1+1+1',
type => 'ipv4',
},
'user@127.0.0.1' => {
hostname => '127.0.0.1',
port => q{},
username => 'user',
realname => '127.0.0.1',
geometry => q{},
type => 'ipv4',
},
'user@127.0.0.1:2323' => {
hostname => '127.0.0.1',
port => 2323,
username => 'user',
realname => '127.0.0.1',
geometry => q{},
type => 'ipv4',
},
'user@127.0.0.1=2x2+2+2' => {
hostname => '127.0.0.1',
port => q{},
username => 'user',
realname => '127.0.0.1',
geometry => '2x2+2+2',
type => 'ipv4',
},
'user@127.0.0.1:3232=1x1+1+1' => {
hostname => '127.0.0.1',
port => 3232,
username => 'user',
realname => '127.0.0.1',
geometry => '1x1+1+1',
type => 'ipv4',
},
'::1' => {
hostname => '::1',
port => q{},
username => q{},
realname => '::1',
geometry => q{},
type => 'ipv6',
},
'::1:2323' => {
hostname => '::1:2323',
port => q{},
username => q{},
realname => '::1:2323',
geometry => q{},
type => 'ipv6',
stderr => qr{Ambiguous host string:.*Assuming you meant}ms
},
'::1/2323' => {
hostname => '::1',
port => 2323,
username => q{},
realname => '::1',
geometry => q{},
type => 'ipv6',
},
'::1:2323=3x3+3+3' => {
hostname => '::1:2323',
port => q{},
username => q{},
realname => '::1:2323',
geometry => '3x3+3+3',
type => 'ipv6',
stderr => qr{Ambiguous host string:.*Assuming you meant}ms
},
'::1/2323=3x3+3+3' => {
hostname => '::1',
port => 2323,
username => q{},
realname => '::1',
geometry => '3x3+3+3',
type => 'ipv6',
},
'user@::1' => {
hostname => '::1',
port => q{},
username => 'user',
realname => '::1',
geometry => q{},
type => 'ipv6',
},
'user@::1:4242' => {
hostname => '::1:4242',
port => q{},
username => 'user',
realname => '::1:4242',
geometry => q{},
type => 'ipv6',
stderr => qr{Ambiguous host string:.*Assuming you meant}ms
},
'user@::1/4242' => {
hostname => '::1',
port => 4242,
username => 'user',
realname => '::1',
geometry => q{},
type => 'ipv6',
},
'user@::1=5x5+5+5' => {
hostname => '::1',
port => q{},
username => 'user',
realname => '::1',
geometry => '5x5+5+5',
type => 'ipv6',
},
'user@::1:4242=5x5+5+5' => {
hostname => '::1:4242',
port => q{},
username => 'user',
realname => '::1:4242',
geometry => '5x5+5+5',
type => 'ipv6',
stderr => qr{Ambiguous host string:.*Assuming you meant}ms
},
'user@::1/4242=5x5+5+5' => {
hostname => '::1',
port => 4242,
username => 'user',
realname => '::1',
geometry => '5x5+5+5',
type => 'ipv6',
},
'[::1]' => {
hostname => '::1',
port => q{},
username => q{},
realname => '::1',
geometry => q{},
type => 'ipv6',
},
'[::1]:2323' => {
hostname => '::1',
port => 2323,
username => q{},
realname => '::1',
geometry => q{},
type => 'ipv6',
},
'[::1]:2323=3x3+3+3' => {
hostname => '::1',
port => 2323,
username => q{},
realname => '::1',
geometry => '3x3+3+3',
type => 'ipv6',
},
'user@[::1]' => {
hostname => '::1',
port => q{},
username => 'user',
realname => '::1',
geometry => q{},
type => 'ipv6',
},
'user@[::1]:4242' => {
hostname => '::1',
port => 4242,
username => 'user',
realname => '::1',
geometry => q{},
type => 'ipv6',
},
'user@[::1]=5x5+5+5' => {
hostname => '::1',
port => q{},
username => 'user',
realname => '::1',
geometry => '5x5+5+5',
type => 'ipv6',
},
'user@[::1]:4242=5x5+5+5' => {
hostname => '::1',
port => 4242,
username => q{},
realname => '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
geometry => q{},
type => 'ipv6',
},
'2001:0db8:85a3:0000:0000:8a2e:0370:7334/22' => {
hostname => '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
port => 22,
username => q{},
realname => '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
geometry => q{},
type => 'ipv6',
},
'[2001:0db8:85a3:0000:0000:8a2e:0370:7334]' => {
hostname => '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
port => q{},
username => q{},
realname => '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
geometry => q{},
type => 'ipv6',
},
'jo@[2001:0db8:85a3:0000:0000:8a2e:0370:7334]' => {
hostname => '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
port => q{},
username => 'jo',
realname => '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
geometry => q{},
type => 'ipv6',
},
'[2001:0db8:85a3:0000:0000:8a2e:0370:7334]=9x9+9+9' => {
hostname => '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
port => q{},
username => q{},
realname => '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
geometry => '9x9+9+9',
type => 'ipv6',
},
'jo@[2001:0db8:85a3:0000:0000:8a2e:0370:7334]=8x8+8+8' => {
hostname => '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
port => q{},
username => 'jo',
realname => '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
geometry => '8x8+8+8',
type => 'ipv6',
},
'[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:22' => {
hostname => '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
port => 22,
username => q{},
realname => '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
geometry => q{},
type => 'ipv6',
},
'2001:0db8:85a3::8a2e:0370:7334' => {
hostname => '2001:0db8:85a3::8a2e:0370:7334',
port => q{},
username => q{},
realname => '2001:0db8:85a3::8a2e:0370:7334',
geometry => q{},
type => 'ipv6',
stderr => qr{Ambiguous host string:.*Assuming you meant}ms
},
'2001:0db8:85a3::8a2e:0370/7334' => {
hostname => '2001:0db8:85a3::8a2e:0370',
port => 7334,
username => q{},
realname => '2001:0db8:85a3::8a2e:0370',
geometry => q{},
type => 'ipv6',
stderr => qr{Ambiguous host string:.*Assuming you meant}ms
},
'pete@2001:0db8:85a3::8a2e:0370:7334' => {
hostname => '2001:0db8:85a3::8a2e:0370:7334',
port => q{},
username => 'pete',
realname => '2001:0db8:85a3::8a2e:0370:7334',
geometry => q{},
type => 'ipv6',
stderr => qr{Ambiguous host string:.*Assuming you meant}ms
},
'pete@2001:0db8:85a3::8a2e:0370/7334' => {
hostname => '2001:0db8:85a3::8a2e:0370',
port => 7334,
username => 'pete',
realname => '2001:0db8:85a3::8a2e:0370',
geometry => q{},
type => 'ipv6',
stderr => qr{Ambiguous host string:.*Assuming you meant}ms
},
'pete@2001:0db8:85a3::8a2e:0370:7334=2x3+4+5' => {
hostname => '2001:0db8:85a3::8a2e:0370:7334',
port => q{},
username => 'pete',
realname => '2001:0db8:85a3::8a2e:0370:7334',
geometry => '2x3+4+5',
type => 'ipv6',
stderr => qr{Ambiguous host string:.*Assuming you meant}ms
},
'pete@2001:0db8:85a3::8a2e:0370/7334=2x3+4+5' => {
hostname => '2001:0db8:85a3::8a2e:0370',
port => 7334,
username => 'pete',
realname => '2001:0db8:85a3::8a2e:0370',
geometry => '2x3+4+5',
type => 'ipv6',
stderr => qr{Ambiguous host string:.*Assuming you meant}ms
},
'2001:0db8:85a3::8a2e:0370:7334=2x3+4+5' => {
hostname => '2001:0db8:85a3::8a2e:0370:7334',
port => q{},
username => q{},
realname => '2001:0db8:85a3::8a2e:0370:7334',
geometry => '2x3+4+5',
type => 'ipv6',
stderr => qr{Ambiguous host string:.*Assuming you meant}ms
},
'2001:0db8:85a3::8a2e:0370/7334=2x3+4+5' => {
hostname => '2001:0db8:85a3::8a2e:0370',
port => 7334,
username => q{},
realname => '2001:0db8:85a3::8a2e:0370',
geometry => '2x3+4+5',
type => 'ipv6',
stderr => qr{Ambiguous host string:.*Assuming you meant}ms
},
'[2001:0db8:85a3::8a2e:0370:7334]' => {
hostname => '2001:0db8:85a3::8a2e:0370:7334',
port => q{},
username => q{},
realname => '2001:0db8:85a3::8a2e:0370:7334',
geometry => q{},
type => 'ipv6',
},
'pete@[2001:0db8:85a3::8a2e:0370:7334]' => {
hostname => '2001:0db8:85a3::8a2e:0370:7334',
port => q{},
username => 'pete',
realname => '2001:0db8:85a3::8a2e:0370:7334',
geometry => q{},
type => 'ipv6',
},
'pete@[2001:0db8:85a3::8a2e:0370:7334]=2x3+4+5' => {
hostname => '2001:0db8:85a3::8a2e:0370:7334',
port => q{},
username => 'pete',
realname => '2001:0db8:85a3::8a2e:0370:7334',
geometry => '2x3+4+5',
type => 'ipv6',
},
'[2001:0db8:85a3::8a2e:0370:7334]=2x3+4+5' => {
hostname => '2001:0db8:85a3::8a2e:0370:7334',
port => q{},
username => q{},
realname => '2001:0db8:85a3::8a2e:0370:7334',
geometry => '2x3+4+5',
type => 'ipv6',
},
'pete@[2001:0db8:8a2e:0370:7334]' => {
hostname => '2001:0db8:8a2e:0370:7334',
port => q{},
username => 'pete',
realname => '2001:0db8:8a2e:0370:7334',
geometry => q{},
type => 'ipv6',
},
'2001:0db8:8a2e:0370:7334:2001:0db8:8a2e:0370:7334:4535:3453:3453:3455'
=> { die => qr{Unable to parse hostname from}ms, },
'some random rubbish' => { die => qr{Unable to parse hostname from}ms, },
);
foreach my $ident ( keys(%parse_tests) ) {
$host = undef;
trap {
$host = App::ClusterSSH::Host->parse_host_string($ident);
};
if ( $parse_tests{$ident}{die} ) {
is( $trap->leaveby, 'die', $ident . ' died correctly' );
like(
$trap->die,
$parse_tests{$ident}{die},
$ident . ' died correctly'
);
next;
}
is( $trap->leaveby, 'return', $ident . ' returned correctly' );
is( $host,
$parse_tests{$ident}{hostname},
'stringify works on: ' . $ident
);
isa_ok( $host, "App::ClusterSSH::Host" );
for my $trap_type (qw/ die /) {
if ( !$parse_tests{$ident}{$trap_type} ) {
is( $trap->$trap_type,
$parse_tests{$ident}{$trap_type},
"$ident $trap_type"
);
}
else {
like(
$trap->$trap_type,
$parse_tests{$ident}{$trap_type},
"$ident $trap_type"
);
}
}
for my $trap_empty (qw/ stdout stderr /) {
like(
$trap->$trap_empty,
$parse_tests{$ident}{$trap_empty} || qr{^$},
"$ident $trap_empty"
);
}
for my $attr (qw/ hostname type port username realname geometry /) {
my $method = "get_$attr";
is( $host->$method,
$parse_tests{$ident}{$attr},
"$ident $attr: " . $host->$method
);
}
is( $host->check_ssh_hostname, 0, $ident . ' not from ssh' );
}
# check for a non-existant file
trap {
$host = App::ClusterSSH::Host->new(
hostname => 'ssh_test',
ssh_config => $Bin . '/some_bad_filename',
);
};
is( $trap->leaveby, 'return', 'returned ok' );
is( $trap->die, undef, 'returned ok' );
is( $trap->stdout, '', 'No unexpected STDOUT' );
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', );
trap {
$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' );
is( $trap->stdout, '', 'No unexpected STDOUT' );
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->get_type, q{}, 'hostname type is correct for ssh_test', );
for my $ssh_file (qw/ 10host_ssh_config 10host_ssh_include/) {
my @hosts = (
'server1', 'server2',
'server3', 'server4',
'server-5', 'server5.domain.name',
'server-6.domain.name'
);
push @hosts, 'server_ssh_included' if ( $ssh_file =~ m/include/ );
for my $hostname (@hosts) {
$host = undef;
is( $host, undef, 'starting afresh for ssh hostname checks' );
trap {
$host = App::ClusterSSH::Host->new(
( run in 0.803 second using v1.01-cache-2.11-cpan-85f18b9d64f )