Apache-Sling

 view release on metacpan or  search on metacpan

t/External/Apache-Sling-Authz.t  view on Meta::CPAN

my $authz = Apache::Sling::Authz->new( \$authn, $verbose, $log );
isa_ok $authz, 'Apache::Sling::Authz', 'authz';
# user object:
my $user = Apache::Sling::User->new( \$authn, $verbose, $log );
isa_ok $user, 'Apache::Sling::User', 'user';

# Run tests:
ok( $content->add( $test_content1, \@test_properties ),
    "Content Test: Content \"$test_content1\" added successfully." );

ok ( ! $authz->get_acl( 'bad_content_does_not_exist' ), 'Check get_acl function with bad content location' );

ok( $authz->get_acl( $test_content1 ),
    "Authz Test: Content \"$test_content1\" ACL fetched successfully." );

my @grant_privileges;
my @deny_privileges;

# add user:
ok( $user->add( $test_user, $test_pass ),
    "User Test: User \"$test_user\" added successfully." );

ok( $authz->modify_privileges( $test_content1, $test_user, \@grant_privileges, \@deny_privileges ),
    "Authz Test: Content \"$test_content1\" ACL privileges successfully modified." );

ok( ! $authz->modify_privileges( 'bad_content_does_not_exist', $test_user, \@grant_privileges, \@deny_privileges ),
    "Authz Test: Content \"bad_content_does_not_exist\" ACL privileges not modified." );

push @grant_privileges, 'read';

ok( $authz->modify_privileges( $test_content1, $test_user, \@grant_privileges, \@deny_privileges ),
    "Authz Test: Content \"$test_content1\" ACL privileges successfully modified." );

ok( ! $authz->del( 'bad_content_does_not_exist', $test_user ),
    "Authz Test: Content \"bad_content_does_not_exist\" ACL privileges not removed for principal: \"$test_user\"." );

ok( $authz->del( $test_content1, $test_user ),
    "Authz Test: Content \"$test_content1\" ACL privileges successfully removed for principal: \"$test_user\"." );

# Authz:
ok( my $authz_config = Apache::Sling::Authz->config($sling), 'check authz_config function' );

ok( Apache::Sling::Authz->run($sling,$authz_config), 'check authz_run function' );

$authz_config->{'write'} = \1;

t/External/Apache-Sling-Content.t  view on Meta::CPAN


my ( $tmp_content_handle, $tmp_content_name ) = File::Temp::tempfile();
my $tmp_content_basename = basename $tmp_content_name;
print {$tmp_content_handle} "Test file\n";
# You need to flush the tmp content handle to actually write data
# out to the file on disk:
close $tmp_content_handle;
my $test_path = "content_test_path_$$";
ok( ! $content->upload_file($tmp_content_name,".."), 'Check upload_file function fails with remote path that is not allowed' );
ok( $content->upload_file($tmp_content_name,$test_path), 'Check upload_file function' );
ok( ! $content->view("$test_path/this_file_does_not_exist"), 'Check view function with non-existent file' );
ok( $content->view("$test_path/$tmp_content_basename"), 'Check view function' );
ok( $content->view_file("$test_path/$tmp_content_basename"), 'Check view file function' );
ok( ! $content->view_file("$test_path/this_file_does_not_exist"), 'Check view file function with non-existent file' );
throws_ok{ $content->view_file()} qr{No file to view specified!}, 'Check view_file function croaks with a missing remote path';
ok( $content->view_full_json("$test_path/$tmp_content_basename"), 'Check view_full_json function' );
ok( ! $content->view_full_json("$test_path/this_file_does_not_exist"), 'Check view_full_json function with non-existent file' );
throws_ok{ $content->view_full_json()} qr{No file to view specified!}, 'Check view_full_json function croaks with a missing remote path';
ok( $content->upload_file($tmp_content_name,$test_path,$test_content1), 'Check upload_file function with filename specified' );
ok( $content->view("$test_path/$test_content1"), 'Check view function on named file' );
ok( $content->view_file("$test_path/$test_content1"), 'Check view file function on named file' );

my $upload = "$tmp_content_name\n";
throws_ok{ $content->upload_from_file(\$upload)} qr{Problem parsing content to add}, 'Check upload_file function croaks with a missing remote path';
$upload = "$tmp_content_name,$test_content1\n";
ok( $content->upload_from_file(\$upload,0,1), 'Check upload_from_file function' );
my ( $tmp_content2_handle, $tmp_content2_name ) = File::Temp::tempfile();

t/External/Apache-Sling-GroupMember.t  view on Meta::CPAN

    "Group Test: 1 Member in \"$test_group2\"." );

ok( $group_member->add( $test_group1, $test_group2 ),
    "Group Test: Member \"$test_group2\" added to \"$test_group1\"." );
ok( $group_member->check_exists( $test_group1, $test_group2 ),
    "Group Test: Member \"$test_group2\" exists in \"$test_group1\"." );
ok( $group_member->view( $test_group1 ) == 2,
    "Group Test: 2 Members in \"$test_group1\"." );

TODO: {
    local $TODO = "This should give an error, not a 200 as the group does _not_ get added!";
    ok( ! $group_member->add( $test_group2, $test_group1 ),
        "Group Test: Member \"$test_group1\" should not be added to \"$test_group2\"." );
}
ok( ! $group_member->check_exists( $test_group2, $test_group1 ),
    "Group Test: Member \"$test_group1\" should not exist in \"$test_group2\"." );
ok( $group_member->view( $test_group2 ) == 1,
    "Group Test: Still 1 Member in \"$test_group2\"." );

# Delete members from groups:
ok( $group_member->del( $test_group1, $test_user ),



( run in 0.487 second using v1.01-cache-2.11-cpan-cc502c75498 )