mirror of
https://github.com/duncs/clusterssh.git
synced 2025-07-03 09:53:23 +00:00
Fix test when run as root
Root user cannot easily be prevented from accessing a no-access file so don't run the test if run as root
This commit is contained in:
parent
c8e66fbcdd
commit
5edca936ed
2 changed files with 28 additions and 20 deletions
1
Changes
1
Changes
|
@ -11,6 +11,7 @@
|
||||||
* Remove doc references to 'always_tile' as renamed 'window_tiling' (Debian bug ID #697371)
|
* Remove doc references to 'always_tile' as renamed 'window_tiling' (Debian bug ID #697371)
|
||||||
* Updated manpage whatis entries (patch by Tony Mancill)
|
* Updated manpage whatis entries (patch by Tony Mancill)
|
||||||
* Fix watch line expression to catch 4.x series tarballs (Debian patch LP ID #1076897)
|
* Fix watch line expression to catch 4.x series tarballs (Debian patch LP ID #1076897)
|
||||||
|
* Allow tests to pass successfully when run as root
|
||||||
|
|
||||||
2012-12-09 Duncan Ferguson <duncan_ferguson@user.sf.net> - v4.01_02
|
2012-12-09 Duncan Ferguson <duncan_ferguson@user.sf.net> - v4.01_02
|
||||||
* Fix logic when using 'autoclose' on the command line or config file
|
* Fix logic when using 'autoclose' on the command line or config file
|
||||||
|
|
|
@ -8,6 +8,7 @@ use Test::More;
|
||||||
use Test::Trap;
|
use Test::Trap;
|
||||||
use File::Which qw(which);
|
use File::Which qw(which);
|
||||||
use File::Temp qw(tempdir);
|
use File::Temp qw(tempdir);
|
||||||
|
use English '-no_match_vars';
|
||||||
|
|
||||||
use Readonly;
|
use Readonly;
|
||||||
|
|
||||||
|
@ -27,24 +28,33 @@ $cluster1->register_tag( 'people', @expected );
|
||||||
|
|
||||||
my @got = $cluster2->get_tag('people');
|
my @got = $cluster2->get_tag('people');
|
||||||
|
|
||||||
is_deeply( \@got, \@expected,
|
is_deeply( \@got, \@expected, 'Shared cluster object' );
|
||||||
'Shared cluster object' );
|
|
||||||
|
|
||||||
# should pass without issue
|
# should pass without issue
|
||||||
trap {
|
trap {
|
||||||
$cluster1->read_cluster_file( $Bin . '/30cluster.doesnt exist' );
|
$cluster1->read_cluster_file( $Bin . '/30cluster.doesnt exist' );
|
||||||
};
|
};
|
||||||
is( ! $trap, '', 'coped with missing file ok' );
|
is( !$trap, '', 'coped with missing file ok' );
|
||||||
isa_ok( $cluster1, 'App::ClusterSSH::Cluster' );
|
isa_ok( $cluster1, 'App::ClusterSSH::Cluster' );
|
||||||
|
|
||||||
my $no_read=$Bin . '/30cluster.cannot_read';
|
# no point running this test as root since root cannot be blocked
|
||||||
chmod 0000, $no_read;
|
# from accessing the file
|
||||||
trap {
|
if ( $EUID != 0 ) {
|
||||||
$cluster1->read_cluster_file( $no_read );
|
my $no_read = $Bin . '/30cluster.cannot_read';
|
||||||
};
|
chmod 0000, $no_read;
|
||||||
chmod 0644, $no_read;
|
trap {
|
||||||
isa_ok( $trap->die, 'App::ClusterSSH::Exception::Cluster' );
|
$cluster1->read_cluster_file($no_read);
|
||||||
is( $trap->die, "Unable to read file $no_read: Permission denied", 'Error on reading an existing file ok');
|
};
|
||||||
|
chmod 0644, $no_read;
|
||||||
|
isa_ok( $trap->die, 'App::ClusterSSH::Exception::Cluster' );
|
||||||
|
is( $trap->die,
|
||||||
|
"Unable to read file $no_read: Permission denied",
|
||||||
|
'Error on reading an existing file ok'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pass('Cannot test for lack of read access when run as root');
|
||||||
|
}
|
||||||
|
|
||||||
@expected = ('host1');
|
@expected = ('host1');
|
||||||
$cluster1->read_cluster_file( $Bin . '/30cluster.file1' );
|
$cluster1->read_cluster_file( $Bin . '/30cluster.file1' );
|
||||||
|
@ -53,18 +63,15 @@ is_deeply( \@got, \@expected, 'read simple file OK' );
|
||||||
|
|
||||||
@expected = ('host1');
|
@expected = ('host1');
|
||||||
$cluster1->read_cluster_file( $Bin . '/30cluster.file2' );
|
$cluster1->read_cluster_file( $Bin . '/30cluster.file2' );
|
||||||
@got=$cluster1->get_tag('tag1');
|
@got = $cluster1->get_tag('tag1');
|
||||||
is_deeply( \@got,
|
is_deeply( \@got, \@expected, 'read more complex file OK' );
|
||||||
\@expected, 'read more complex file OK' );
|
|
||||||
|
|
||||||
@expected = ('host2');
|
@expected = ('host2');
|
||||||
@got=$cluster1->get_tag('tag2');
|
@got = $cluster1->get_tag('tag2');
|
||||||
is_deeply( \@got,
|
is_deeply( \@got, \@expected, 'read more complex file OK' );
|
||||||
\@expected, 'read more complex file OK' );
|
|
||||||
|
|
||||||
@expected = ( 'host3', 'host4' );
|
@expected = ( 'host3', 'host4' );
|
||||||
@got=$cluster1->get_tag('tag3');
|
@got = $cluster1->get_tag('tag3');
|
||||||
is_deeply( \@got,
|
is_deeply( \@got, \@expected, 'read more complex file OK' );
|
||||||
\@expected, 'read more complex file OK' );
|
|
||||||
|
|
||||||
done_testing();
|
done_testing();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue