From: Manni H. <man...@us...> - 2008-04-10 15:17:35
|
Update of /cvsroot/popfile/engine/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2153/tests Modified Files: TestIMAP.tst Log Message: 1. Make the IMAP module aware of multi-user mode. - Get an administrator session key in service() - get a list of users in the DB - Keep track of the user-id that the module is currently working with. TODO: - Add a per-user configuration variable that let's users en/disable the use of IMAP. - Check this variable in service(). 2. Update the IMAP tests in the test suite. - Get an administrato session key - Correctly call History::get_slot_fields(). => The tests now run without errors TODO: Make this work in multi-user mode. Index: TestIMAP.tst =================================================================== RCS file: /cvsroot/popfile/engine/tests/TestIMAP.tst,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TestIMAP.tst 10 Apr 2008 11:18:39 -0000 1.12 --- TestIMAP.tst 10 Apr 2008 15:17:35 -0000 1.13 *************** *** 56,60 **** # First, start POPFile. my ( $c, $mq, $l, $b, $h, $im ) = start_popfile(); - my $session = $b->get_session_key( 'admin', '' ); # Configure the IMAP module so it will --- 56,59 ---- *************** *** 82,86 **** my ( $im, $c, $mq, $l, $b, $h ) = @_; ! my $session = $b->get_session_key( 'admin', '' ); test_assert( $im->start() ); --- 81,85 ---- my ( $im, $c, $mq, $l, $b, $h ) = @_; ! my $session = $b->get_administrator_session_key(); test_assert( $im->start() ); *************** *** 144,148 **** # The module should not allow reclassification to the same # bucket. ! my $hash = ( $h->get_slot_fields( 1 ) )[6]; test_assert( ! $im->can_reclassify__( $hash, 'spam' ) ); # If the hash is unknown, it should reclassify either --- 143,147 ---- # The module should not allow reclassification to the same # bucket. ! my $hash = ( $h->get_slot_fields( 1, $session ) )[6]; test_assert( ! $im->can_reclassify__( $hash, 'spam' ) ); # If the hash is unknown, it should reclassify either *************** *** 171,194 **** # check classification stored in history ! test_assert_equal( ($h->get_slot_fields( 1 ))[8], 'personal' ); ! test_assert_equal( ($h->get_slot_fields( 2 ))[8], 'personal' ); ! test_assert_equal( ($h->get_slot_fields( 3 ))[8], 'personal' ); ! test_assert_equal( ($h->get_slot_fields( 4 ))[8], 'other' ); ! test_assert_equal( ($h->get_slot_fields( 5 ))[8], 'other' ); # check that history knows that the msgs were reclassfified ! test_assert_equal( ($h->get_slot_fields( 1 ))[9], 4 ); ! test_assert_equal( ($h->get_slot_fields( 2 ))[9], 4 ); ! test_assert_equal( ($h->get_slot_fields( 3 ))[9], 4 ); ! test_assert_equal( ($h->get_slot_fields( 4 ))[9], 4 ); ! test_assert_equal( ($h->get_slot_fields( 5 ))[9], 4 ); # history should also know about the used manget ! test_assert_equal( ($h->get_slot_fields( 6 ))[11], 'cxc...@ya...' ); # get the msgs hashes and ask the imap module whether those messages # can be reclassified. It should say 'no!' foreach ( 1 .. 6 ) { ! $hash = ($h->get_slot_fields( $_ ))[6]; test_assert_equal( $im->can_reclassify__( $hash, 'spam' ), undef ); test_assert( ! $im->can_classify__( $hash ) ); --- 170,193 ---- # check classification stored in history ! test_assert_equal( ($h->get_slot_fields( 1, $session ))[8], 'personal' ); ! test_assert_equal( ($h->get_slot_fields( 2, $session ))[8], 'personal' ); ! test_assert_equal( ($h->get_slot_fields( 3, $session ))[8], 'personal' ); ! test_assert_equal( ($h->get_slot_fields( 4, $session ))[8], 'other' ); ! test_assert_equal( ($h->get_slot_fields( 5, $session ))[8], 'other' ); # check that history knows that the msgs were reclassfified ! test_assert_equal( ($h->get_slot_fields( 1, $session ))[9], 4 ); ! test_assert_equal( ($h->get_slot_fields( 2, $session ))[9], 4 ); ! test_assert_equal( ($h->get_slot_fields( 3, $session ))[9], 4 ); ! test_assert_equal( ($h->get_slot_fields( 4, $session ))[9], 4 ); ! test_assert_equal( ($h->get_slot_fields( 5, $session ))[9], 4 ); # history should also know about the used manget ! test_assert_equal( ($h->get_slot_fields( 6, $session ))[11], 'cxc...@ya...' ); # get the msgs hashes and ask the imap module whether those messages # can be reclassified. It should say 'no!' foreach ( 1 .. 6 ) { ! $hash = ($h->get_slot_fields( $_, $session ))[6]; test_assert_equal( $im->can_reclassify__( $hash, 'spam' ), undef ); test_assert( ! $im->can_classify__( $hash ) ); *************** *** 431,438 **** # Now let the IMAP module populate the template ! $im->user_config_( 1, hostname => 'some host' ); ! $im->user_config_( 1, port => 1234 ); ! $im->user_config_( 1, password => 'some password' ); ! $im->user_config_( 1, login => 'some login' ); $im->configure_item( 'imap_0_connection_details', $tmpl, $language ); --- 430,437 ---- # Now let the IMAP module populate the template ! $im->user_config_( 1, hostname => 'some host' ); ! $im->user_config_( 1, port => 1234 ); ! $im->user_config_( 1, password => 'some password' ); ! $im->user_config_( 1, login => 'some login' ); $im->configure_item( 'imap_0_connection_details', $tmpl, $language ); *************** *** 457,461 **** # We set both, the mailboxes__ arrayref and the list of watched folders, to be empty $im->{mailboxes__} = []; ! $im->user_config_( 1, 'watched_folders', '' ); $im->configure_item( 'imap_1_watch_folders', $tmpl, $language ); test_assert( ! $tmpl->param( 'IMAP_if_mailboxes' ) ); --- 456,460 ---- # We set both, the mailboxes__ arrayref and the list of watched folders, to be empty $im->{mailboxes__} = []; ! $im->user_config_( 1, 'watched_folders', '' ); $im->configure_item( 'imap_1_watch_folders', $tmpl, $language ); test_assert( ! $tmpl->param( 'IMAP_if_mailboxes' ) ); *************** *** 805,809 **** --- 804,810 ---- my ( $im, $c, $mq, $l, $b, $h ) = @_; + $im->user_id( 1 ); $im->initialize(); + my $s = $b->get_administrator_session_key(); # We should not do anything when we're not enabled: *************** *** 811,820 **** test_assert_equal( $im->start(), 2 ); $im->config_( 'enabled', 1 ); ! $im->user_config_( 1, 'expunge', 1 ); ! $im->user_config_( 1, 'hostname', '127.0.0.1' ); ! $im->user_config_( 1, 'password', 'password' ); ! $im->user_config_( 1, 'port', '1143' ); ! $im->user_config_( 1, 'update_interval', 10 ); ! $im->user_config_( 1, 'watched_folders', '' ); $im->global_config_( 'message_cutoff', 100000 ); --- 812,821 ---- test_assert_equal( $im->start(), 2 ); $im->config_( 'enabled', 1 ); ! $im->user_config_( 1, 'expunge', 1 ); ! $im->user_config_( 1, 'hostname', '127.0.0.1' ); ! $im->user_config_( 1, 'password', 'password' ); ! $im->user_config_( 1, 'port', '1143' ); ! $im->user_config_( 1, 'update_interval', 10 ); ! $im->user_config_( 1, 'watched_folders', '' ); $im->global_config_( 'message_cutoff', 100000 ); *************** *** 872,878 **** $im->config_( enabled => 1 ); ! $l->config_( 'level', 1 ); ! $l->config_( logdir => '/tmp/' ); ! $im->module_config_( 'html', 'port', 8082 ); --- 873,880 ---- $im->config_( enabled => 1 ); ! #$l->config_( 'level', 2 ); ! #$l->config_( logdir => '/tmp' ); ! #$h->global_config_( 'debug', 1 ); ! $h->global_config_( 'single_user', 1 ); $im->module_config_( 'html', 'port', 8082 ); |