X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FApp-EzPz.git;a=blobdiff_plain;f=t%2Flists.t;fp=t%2Flists.t;h=a91e5b24517010a90dc53c34d014176a8c94da02;hp=0000000000000000000000000000000000000000;hb=fb960e0eb2ad6ad19c2c695b6aa87716ae299a23;hpb=8dbc46889fe504dede2f94e854254e919ce68416 diff --git a/t/lists.t b/t/lists.t new file mode 100644 index 0000000..a91e5b2 --- /dev/null +++ b/t/lists.t @@ -0,0 +1,68 @@ +use if (!-d 'test-setup'), 'Test::More', skip_all => 'List testing skipped'; +use Test::More; +use IO::All; +use App::EzPz::TestSetup; +use App::EzPz::UserStore; +use App::EzPz::Web; +use strictures 1; + +unless (-d 'test-setup/ezmlm') { + create_install( + 'src/ezmlm-idx-7.1.1.tar.gz', + 'test-setup/build', + 'test-setup/ezmlm' + ); +} + +my $lists_base = io->dir('test-setup/lists'); + +$lists_base->rmtree; +$lists_base->mkpath; + +create_list('test-setup/ezmlm/bin', 'test-setup/lists', $_) + for qw(list1 list2 list3); + +pass('Setup completed successfully'); + +my $us = App::EzPz::UserStore->new( + htpasswd_file => 'test-setup/lists/htpasswd', + ezmlm_config => { + bindir => 'test-setup/ezmlm/bin', + list_base_dir => 'test-setup/lists' + } +); + +for my $user ($us->add({ username => 'mst', password => 'boromir' })) { + $user->add_list_name($_) for qw(list1 list2 list3); + for my $list ($user->get_list('list1')) { + $list->add_member('joe@example.com'); + $list->add_member('bob@example.com'); + $list->deny->add_member('evil@monkey.com'); + $list->deny->add_member('evil@gibbon.com'); + } +} + +my $app = App::EzPz::Web->new(users => $us); + +is($app->run_test_request(GET => '/')->code, 401, 'Auth fail without pw'); + +is( + $app->run_test_request(GET => 'bob:boromir@/')->code, 401, + 'Auth fail with wrong user' +); + +is( + $app->run_test_request(GET => 'mst:spoon@/')->code, 401, + 'Auth fail with wrong pw' +); + +my $res = $app->run_test_request(GET => 'mst:boromir@/'); + +is($res->code, 200, 'Auth ok with user+pass'); + +like($res->content, qr/Welcome user .*mst/, 'Welcome mst'); + +like($res->content, qr{/list/$_/}, "List $_ on /") + for qw(list1 list2 list3); + +done_testing;