Csistck

 view release on metacpan or  search on metacpan

lib/Csistck/Test/FileBase.pm  view on Meta::CPAN

    if ($fh) {
        my $curmode = sprintf "%04o", $fh->mode & 07777;
        debug("File mode: file=<$file> mode=<$curmode>");
        return 1 if ($curmode eq $mode);
    }
}

sub mode_repair {
    my ($file, $mode) = @_;
    debug("Chmod file: file=<$file> mode=<$mode>");
    chmod(oct($mode), $file);
}

# UID operations
sub uid_check {
    my ($file, $uid) = @_;
    my $fh = stat($file);
    my $curuid = undef;
    if ($fh) {
        my $curuid = $fh->uid;
        debug("File owner: file=<$file> uid=<$uid>");

t/20file.t  view on Meta::CPAN

use Test::Exception;
use Csistck;
use File::Temp;
use File::stat;

plan tests => 13;

my $h = File::Temp->new();
my $file = $h->filename;
print $h "Test";
chmod(oct('0666'), $file);

my $t = file($file, mode => '0660');

isa_ok($t, Csistck::Test);
ok($t->can('check'), 'Has check');
ok($t->check, 'Manual check');
isa_ok($t->check, Csistck::Test::Return, 'Manual check return');

# Expect fail, repair should pass, then check should pass 
my $ret;

t/20permission.t  view on Meta::CPAN

use Csistck;
use File::Temp;
use File::stat;

plan tests => 6;

# Make file and test array (due to glob)
my $h = File::Temp->new();
my $file = $h->filename;
print $h "Test";
chmod(oct('0666'), $file);
my $perm = Csistck::Test::File->new($file, mode => '0660');

# Get first test, make sure we are what we are
isa_ok($perm, Csistck::Test);
ok($perm->can('check'));

# Expect check to fail first, as well as manual. Repair and final check should
# succeed, throw in a manual check again to test Csistck::Test abstraction
ok($perm->check, "Manual check of mode" );
isa_ok($perm->check, Csistck::Test::Return, "Manual check return");

t/20template.t  view on Meta::CPAN

use Test::Exception;
use Csistck;
use File::Temp;
use File::stat;

plan tests => 13;

my $h = File::Temp->new();
my $file = $h->filename;
print $h "Test";
chmod(oct('0666'), $file);

my $t = template($file, mode => '0660');

isa_ok($t, Csistck::Test);
ok($t->can('check'), 'Has check');
ok($t->check, 'Manual check');
isa_ok($t->check, Csistck::Test::Return, 'Manual check return');

# Expect fail, repair should pass, then check should pass 
my $ret;



( run in 0.280 second using v1.01-cache-2.11-cpan-8d75d55dd25 )