# Copyright (c) 2005-2009 bivio Software, Inc. All Rights Reserved. # $Id: realm-file.btest,v 1.19 2011/04/12 23:38:14 moeller Exp $ test_setup('PetShop', 'groupware'); home_page(); visit_uri('/btest_read/public-file/file.txt'); verify_content_type('text/plain'); verify_text('text/plain'); test_deviance(); visit_uri('/btest_read/public-file/private/file.html'); visit_uri('/btest_read/private/file.html'); test_conformance(); home_page(); login_as('btest_read'); visit_uri('/btest_read/file/private/file.html'); verify_content_type('text/html'); verify_text('text/html'); visit_uri('/btest_read/file/private/image.gif'); verify_content_type('image/gif'); home_page(); login_as('root'); visit_uri('/fourem/files'); if (get_content() =~ m,"/fourem/file/realm-file-btest.txt",) { follow_link_in_table('Name', 'Name', qr{realm-file-btest.txt}, 'Actions', 'Modify'); fixup_files_uri('DELETE'); submit_form(OK => { 'Comments:' => 'deleted by acceptance test', }); } follow_link_in_table('Name', 'Name', '/', 'Actions', 'Modify'); fixup_files_uri('TEXT_FILE'); submit_form(OK => { 'Name:' => 'realm-file-btest.txt', _anon => my $c = random_string(), 'Comments:' => 'x', }); follow_link('realm-file-btest.txt'); verify_text($c); visit_uri('/fourem/files'); follow_link_in_table('Name', 'Name', '/', 'Actions', 'Modify'); fixup_files_uri('ADD_SUBFOLDER'); submit_form(OK => { 'Name:' => 'Empty Folder', }); test_deviance(); follow_link('Empty Folder'); test_conformance(); follow_link_in_table('Name', 'Name', 'Empty Folder', 'Actions', 'Modify'); fixup_files_uri('TEXT_FILE'); submit_form(OK => { 'Name:' => 'no-longer-empty.txt', _anon => my $c2 = random_string(), 'Comments:' => 'x', }); follow_link('Empty Folder'); follow_link('no-longer-empty.txt'); verify_text($c2); visit_uri('/fourem/files'); follow_link_in_table('Name', 'Name', 'Empty Folder', 'Actions', 'Modify'); fixup_files_uri('DELETE'); submit_form(OK => { 'Comments:' => 'cleanup for next test run', }); follow_link(qr/^site$/, 'Files', 'Public', 'WikiData'); verify_table('Name', [ ['Name', 'Size'], ['logo.pdf', '9 KB'], ]); my($email) = generate_local_email('root'); my($subj) = random_string(); do_test_backdoor(RealmFile => "-realm demo send_file_via_mail $email $subj /private/image.gif"); my($msg) = verify_local_mail($email, $subj); test_equals(qr{filename="image.gif"}, $msg); visit_uri('/fourem/files'); my($folder) = 'folder ' . random_string(); unless (text_exists($folder)) { follow_link_in_table('Name', 'Name', '/', 'Actions', 'Modify'); fixup_files_uri('ADD_SUBFOLDER'); submit_form(OK => { 'Name:' => $folder, }); } follow_link_in_table('Name', 'Name', $folder, 'Actions', 'Modify'); fixup_files_uri('TEXT_FILE'); submit_form(OK => { 'Name:' => my $f1 = random_string(), _anon => my $c3 = random_string(), }); follow_link_in_table('Name', 'Name', $folder, 'Actions', 'Modify'); fixup_files_uri('DELETE'); submit_form('OK'); verify_no_text($folder); follow_link('Archived', $folder, "$f1;1"); verify_text($c3); visit_uri('/fourem/files'); follow_link('Archived', $folder); verify_table('Name', [ ['Name', 'Actions'], [$folder, qr/^Restore$/], [$f1, qr/^Restore, Delete Permanently$/], ]); follow_link_in_table('Name', 'Name', $folder, 'Actions', 'Restore'); verify_text(qr{want to restore.*/Archived/$folder}); submit_form('Restore'); verify_table('Name', [ ['Name', 'Actions'], [$folder, qr/^$/], [$f1, qr/^Restore, Delete Permanently$/], ]); follow_link_in_table('Name', 'Name', $f1, 'Actions', 'Delete Permanently'); verify_text(qr{delete.*/Archived/$folder/$f1;1.*permanently}); submit_form('Delete Permanently'); verify_table('Name', [ ['Name', 'Actions'], [$folder, qr/^Delete Permanently$/], ]); follow_link_in_table('Name', 'Name', $folder, 'Actions', 'Delete Permanently'); verify_text(qr{delete.*/Archived/$folder.*permanently}); submit_form('Delete Permanently'); follow_link(qr/^fourem$/, 'Files', $folder); follow_link($f1); verify_text($c3);