����JFIF���������
__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
use strict;
use Test::Builder::Tester;
use Test::More;
use Test::File;
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#let's test with the first file we find in the current dir
my( $filename, $file_gid, $owner_uid, $owner_name, $file_group_name );
eval
{
$filename = glob( "*" );
die "Could not find a file" unless defined $filename;
$owner_uid = ( stat $filename )[4];
die "failed to find ${filename}'s owner\n" unless defined $owner_uid;
$file_gid = ( stat $filename )[5];
die "failed to find ${filename}'s owner\n" unless defined $file_gid;
$owner_name = ( getpwuid $owner_uid )[0];
die "failed to find ${filename}'s owner as name\n" unless defined $owner_name;
$file_group_name = ( getgrgid $file_gid )[0];
die "failed to find ${filename}'s group as name\n" unless defined $file_group_name;
};
plan skip_all => "I can't find a file to test with: $@" if $@;
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# find some name that isn't the one we found before
my( $other_name, $other_uid, $other_group_name, $other_gid );
eval
{
for( my $i = 0; $i < 65535; $i++ )
{
next if $i == $owner_uid;
my @stats = getpwuid $i;
next unless @stats;
( $other_uid, $other_name ) = ( $i, $stats[0] );
last;
}
# XXX: why the for loop?
for( my $i = 0; $i < 65535; $i++ )
{
next if $i == $file_gid;
my @stats = getgrgid $i;
next unless @stats;
( $other_gid, $other_group_name ) = ( $i, $stats[0] );
last;
}
die "Failed to find another uid" unless defined $other_uid;
die "Failed to find name for other uid ($other_uid)"
unless defined $other_name;
die "Failed to find another gid" unless defined $other_gid;
die "Failed to find name for other gid ($other_gid)"
unless defined $other_group_name;
};
plan skip_all => "I can't find a second user id to test with: $@" if $@;
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# find some names that don't exist, to test bad input
my( $invalid_user_name, $invalid_group_name );
eval
{
foreach my $user ( 'aaaa' .. 'zzzz' )
{
my @stats = getpwnam $user;
next if @stats;
$invalid_user_name = $user;
#diag "Using invalid user [$user] for tests";
last;
}
foreach my $group ( 'aaaa' .. 'zzzz' )
{
my @stats = getpwnam $group;
next if @stats;
$invalid_group_name = $group;
#diag "Using invalid group [$group] for tests";
last;
}
diag "Failed to find an invalid username" unless defined $other_uid;
diag "Failed to find another gid" unless defined $other_gid;
};
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# test owner stuff
owner_is( $filename, $owner_name, 'owner_is with text username' );
owner_is( $filename, $owner_uid, 'owner_is with numeric UID' );
owner_isnt( $filename, $other_name, 'owner_isnt with text username' );
owner_isnt( $filename, $other_uid, 'owner_isnt with numeric UID' );
my $name = 'Intentional owner_is failure with wrong user';
my $testname = "$filename belongs to $other_name";
test_out( "not ok 1 - $testname");
test_diag(
"file [$filename] belongs to $owner_name ($owner_uid), not $other_name " .
"($other_uid)\n" .
"# Failed test '$testname'\n".
"# at t/owner.t line " . line_num(+6) . "."
);
owner_is( $filename, $other_name );
test_test( $name );
$name = "Intentional owner_is failure with invalid user [$invalid_user_name]";
$testname = "$filename belongs to $invalid_user_name";
test_out( "not ok 1 - $testname");
test_diag(
"user [$invalid_user_name] does not exist on this system\n" .
"# Failed test '$testname'\n".
"# at t/owner.t line " . line_num(+5) . "."
);
owner_is( $filename, $invalid_user_name );
test_test( $name );
$name = 'owner_isnt for non-existent name';
$testname = "$filename doesn't belong to $invalid_user_name";
test_out( "ok 1 - $testname");
owner_isnt( $filename, $invalid_user_name );
test_test( $name );
$name = 'Intentional owner_isnt failure';
$testname = "$filename doesn't belong to $owner_name";
test_out( "not ok 1 - $testname");
test_diag(
"file [$filename] belongs to $owner_name ($owner_uid)\n" .
"# Failed test '$testname'\n" .
"# at t/owner.t line " . line_num(+5) . "."
);
owner_isnt( $filename, $owner_name );
test_test( $name );
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# test group stuff
group_is( $filename, $file_group_name, 'group_is with text groupname' );
group_is( $filename, $file_group_name );
group_is( $filename, $file_gid, 'group_is with numeric GID' );
group_isnt( $filename, $other_group_name, 'group_isnt with text groupname' );
group_isnt( $filename, $other_gid, 'group_isnt with numeric GID' );
group_isnt( $filename, $other_gid );
$name = 'Intentional group_is failure';
test_out( "not ok 1 - $name");
test_diag(
"file [$filename] belongs to $file_group_name ($file_gid), not ".
"$other_group_name " .
"($other_gid)\n" .
"# Failed test '$name'\n".
"# at t/owner.t line " . line_num(+7) . "."
);
group_is( $filename, $other_group_name, $name );
test_test( $name );
$name = "Intentional group_is failure with invalid group [$invalid_group_name]";
test_out( "not ok 1 - $name");
test_diag(
"group [$invalid_group_name] does not exist on this system\n" .
"# Failed test '$name'\n".
"# at t/owner.t line " . line_num(+5) . "."
);
group_is( $filename, $invalid_group_name, $name );
test_test( $name );
$name = 'Intentional group_isnt failure';
test_out( "not ok 1 - $name");
test_diag(
"file [$filename] belongs to $file_group_name ($file_gid)\n" .
"# Failed test '$name'\n" .
"# at t/owner.t line " . line_num(+5) . "."
);
group_isnt( $filename, $file_group_name, $name );
test_test( $name );
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
done_testing();
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| rt | Folder | 0755 |
|
|
| dm_skeleton.t | File | 1.51 KB | 0644 |
|
| file_contains.t | File | 5.05 KB | 0644 |
|
| file_contains_encoded.t | File | 2.96 KB | 0644 |
|
| file_contains_utf8.t | File | 2.97 KB | 0644 |
|
| file_mtime.t | File | 3.02 KB | 0644 |
|
| file_sizes.t | File | 4.71 KB | 0644 |
|
| line_counters.t | File | 5.21 KB | 0644 |
|
| link_counts.t | File | 2.47 KB | 0644 |
|
| links.t | File | 5.23 KB | 0644 |
|
| load.t | File | 158 B | 0644 |
|
| normalize.t | File | 1.81 KB | 0644 |
|
| obviously_non_multi_user.t | File | 1.53 KB | 0644 |
|
| owner.t | File | 5.75 KB | 0644 |
|
| pod.t | File | 129 B | 0644 |
|
| pod_coverage.t | File | 161 B | 0644 |
|
| setup_common | File | 1.89 KB | 0644 |
|
| test_dirs.t | File | 1.42 KB | 0644 |
|
| test_files.t | File | 9.99 KB | 0644 |
|
| test_manifest | File | 282 B | 0644 |
|
| win32.t | File | 929 B | 0644 |
|