Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
root_t now work on MacOSX; new credentials tests
- Loading branch information
Vyacheslav Matyukhin
committed
Jun 15, 2012
1 parent
f9f28fb
commit 14080e1
Showing
4 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use lib 'lib'; | ||
|
||
use Test::More; | ||
use parent qw(Test::Class); | ||
|
||
use Ubic::Credentials; | ||
use t::Utils; | ||
|
||
sub setup :Test(setup) { | ||
rebuild_tfiles(); | ||
xsystem('chmod -R 777 tfiles'); | ||
} | ||
|
||
sub current :Tests { | ||
my $c = Ubic::Credentials->new; | ||
|
||
is($c->user, 'root'); | ||
|
||
my @pwnam = getpwnam 'root'; | ||
my $root_group = (getgrgid( (getpwnam 'root')[3] ))[0]; | ||
my ($group) = $c->group; | ||
is($group, $root_group, "main group is $root_group"); | ||
} | ||
|
||
sub set :Tests { | ||
my $file = 'tfiles/blah'; | ||
my $user = 'nobody'; | ||
my $group = 'daemon'; | ||
|
||
my $c = Ubic::Credentials->new(user => $user, group => $group); | ||
|
||
my $pid = fork; | ||
die "fork failed" unless defined $pid; | ||
unless ($pid) { | ||
eval { | ||
$c->set; | ||
die "Tainted" if ${^TAINT}; | ||
xsystem("touch $file"); | ||
}; | ||
warn "subprocess failed: $@" if $@; | ||
exit; | ||
} | ||
|
||
waitpid($pid, 0); | ||
ok(-f $file); | ||
my @stat = stat($file); | ||
is($stat[4], scalar(getpwnam($user)), "$file belongs to $user"); | ||
is($stat[5], scalar(getgrnam($group)), "$file group is $group") unless $^O eq 'darwin'; | ||
} | ||
|
||
__PACKAGE__->new->runtests; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters