Skip permissions check test when run as root

This is because root has access to the file even when it is locked down in this simple test, so it always fails

Github issue: 11

Thanks to Deny Dias
This commit is contained in:
Duncan Ferguson 2014-09-19 22:39:48 +01:00
parent a93b3f3cac
commit 26e783be1c
3 changed files with 30 additions and 24 deletions

View file

@ -1,5 +1,6 @@
4.03_03 0000-00-00 Duncan Ferguson <duncan_ferguson@user.sf.net>
- Force tests to have English locale when user has something else set (Github issue: 10) (thanks to Emanuele Tomasi)
- Skip permissions check test when run as root as the results are invalid (Github issue: 11) (thanks to Deny Dias)
4.03_02 2014-08-10 Duncan Ferguson <duncan_ferguson@user.sf.net>
- Fix behaviour when external cluster command is not defined or doesn't exist

1
THANKS
View file

@ -43,3 +43,4 @@ Brandon Perkins
Oliver Meissner
Andrew Stevenson
Emanuele Tomasi
Deny Dias

View file

@ -1,10 +1,10 @@
use strict;
use warnings;
# Force use of English in tests for the moment, for those users that
# Force use of English in tests for the moment, for those users that
# have a different locale set, since errors are hardcoded below
use POSIX qw(setlocale locale_h);
setlocale(LC_ALL, "C");
setlocale( LC_ALL, "C" );
use FindBin qw($Bin $Script);
use lib "$Bin/../lib";
@ -468,28 +468,32 @@ is( $trap->stderr,
'Expecting no STDERR'
);
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} );
SKIP: {
skip "Test inappropriate when running as root", 5, $< == 0;
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} );
}
note('check failure to write default config is caught');
$ENV{HOME} = tempdir( CLEANUP => 1 );