From: naoki i. <am...@us...> - 2008-04-25 16:27:07
|
Update of /cvsroot/popfile/engine/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20326/tests Modified Files: TestBayes.tst TestConfiguration.tst TestHTML.script TestPOP3.tst TestProxy.tst Log Message: Change Log 1. UI and POP3 proxy are now able to be connected via SSL 2. New Proxy module 'Proxy::POP3S' (POP3 over SSL) 3. New global options: GLOBAL_cert_file, GLOBAL_key_file, GLOBAL_ca_file 4. New html options: html_https_enabled, html_https_port 5. Secure cookies are used when accessed to the HTTPS server Proxy/POP3S.pm Proxy/POP3.pm Proxy/Proxy.pm UI/HTML.pm UI/HTTP.pm POPFile/Configuration.pm Classifier/Bayes.pm skins/default/pop3s-configuration-panel.thtml skins/default/pop3s-security-panel.thtml tests/Configuration.tst The new Proxy::POP3S module supports connections via SSL. It has following options: pop3s_enabled Enable(=1)/Disable(=0;default) the module pop3s_force_fork Enable(=1)/Disable(=0) forking pop3s_local Allow(=1)/Disallow(=0) connections from remote pop3s_port POP3S proxy port(default:995) pop3s_socks_port SOCKS proxy port pop3s_socks_server SOCKS proxy server pop3s_welcome_string POP3S proxy welcome string The other POP3 options (e.g. pop3_separator) are same as the Proxy::POP3 module. Here's the new options of the UI::HTML module: html_https_enabled Enable(=1)/Disable(=0;default) the HTTPS server html_https_port HTTPS server port(default:8443) The new global options: GLOBAL_cert_file Location of the certification file of the server GLOBAL_key_file Location of the key file of the server GLOBAL_ca_file Location of the CA file NOTE: I've implemented POP3S and the HTTPS in the different way. I've made a new module Proxy::POP3S for POP3S, but I don't make the module for HTTPS. This is because I think making the new module for HTTPS ( UI:HTTPS ? ) is very hard. BUG: Concurrent POP3S connections cause an error in some environment: SSL3 alert write:fatal:bad record mac 7664:error:1408F119:SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac:s3_pkt.c:424: 6. AUTH PLAIN support Proxy/POP3.pm 7. Supress the verbose status messages on the administration tab 8. Add some status messages (administration tab) UI/HTML.pm UI/XMLRPC.pm Proxy/Proxy.pm Proxy/POP3.pm Proxy/NNTP.pm Proxy/SMTP.pm languages/English.msg languages/Nihongo.msg tests/TestPOP3.tst tests/TestHTML.script 9. The message files are no longer cached by the web browser UI/HTTP.pm 10. if html_allow_javascript == 0, don't disable the radio buttons skins/default/administration-page.thtml skins/default/pop3-security-panel.thtml skins/default/nntp-security-local.thtml skins/default/smtp-security-local.thtml skins/default/xmlrpc-local.thtml 11. Minor updates of the skins skins/smtp-chain-server.thtml skins/smtp-chain-server-port.thtml (merged to the above file) skins/pop3-chain-panel.thtml 12. Source code cleanup UI/HTML.pm UI/HTTP.pm UI/XMLRPC.pm Proxy/POP3.pm Proxy/Proxy.pm Proxy/NNTP.pm Proxy/SMTP.pm Classifier/Bayes.pm Classifier/MailParse.pm POPFile/Configuration.pm POPFile/Database.pm POPFile/History.pm POPFile/Loader.pm POPFile/Logger.pm POPFile/Module.pm POPFile/MQ.pm POPFile/Mutex.pm Add some 'PROFILE BLOCK START' and 'PROFILE BLOCK STOP's. These are used by Devel::TestCoverage to get the correct coverage. 13. Add some tests tests/TestBayes.tst Current state of the test suite: TestBayesScript PASS TestBayes PASS TestConfiguration PASS * TestHistory PASS TestHTML PASS * TestHTTP PASS TestIMAP PASS TestInsertScript PASS * TestLogger PASS TestMailParse PASS TestModule PASS TestMQ PASS TestMutex PASS TestPipeScript PASS TestPOP3 PASS TestProxy PASS TestWordMangle PASS TestXMLRPC PASS * : TODO : needs to add tests for multi user support Index: TestHTML.script =================================================================== RCS file: /cvsroot/popfile/engine/tests/TestHTML.script,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** TestHTML.script 18 Apr 2008 12:41:49 -0000 1.38 --- TestHTML.script 25 Apr 2008 16:26:50 -0000 1.39 *************** *** 803,807 **** MATCH Updated POP3 port to 111; this change will not take affect until you restart POPFile SETSUBMIT pop3_port 0 ! MATCH The POP3 listen port must be a number between 1 and 65535 INPUTIS pop3_port 111 --- 803,807 ---- MATCH Updated POP3 port to 111; this change will not take affect until you restart POPFile SETSUBMIT pop3_port 0 ! MATCH The POP3/POP3S listen port must be a number between 1 and 65535 INPUTIS pop3_port 111 Index: TestPOP3.tst =================================================================== RCS file: /cvsroot/popfile/engine/tests/TestPOP3.tst,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** TestPOP3.tst 17 Apr 2008 15:13:05 -0000 1.36 --- TestPOP3.tst 25 Apr 2008 16:26:50 -0000 1.37 *************** *** 182,187 **** test_assert_equal( scalar( keys( %{$params} ) ), 3 ); test_assert_equal( $templ->param( 'POP3_Configuration_If_Force_Fork' ), ( $p->config_( 'force_fork' ) == 1 ) ); ! test_assert_equal( $templ->param( 'POP3_Configuration_Port' ), $p->config_( 'port' ) ); ! test_assert_equal( $templ->param( 'POP3_Configuration_Separator' ), $p->config_( 'separator' ) ); delete $templ->{params__}; --- 182,187 ---- test_assert_equal( scalar( keys( %{$params} ) ), 3 ); test_assert_equal( $templ->param( 'POP3_Configuration_If_Force_Fork' ), ( $p->config_( 'force_fork' ) == 1 ) ); ! test_assert_equal( $templ->param( 'POP3_Configuration_Port' ), $p->config_( 'port' ) ); ! test_assert_equal( $templ->param( 'POP3_Configuration_Separator' ), $p->config_( 'separator' ) ); delete $templ->{params__}; *************** *** 263,267 **** ($status, $error) = $p->validate_item( 'pop3_configuration', $templ, $language, $form ); ! test_assert_equal( $status, "pop3 port update " . ( $port + 1 ) ); test_assert( !defined( $error ) ); test_assert_equal( $p->config_('port'), $port + 1 ); --- 263,267 ---- ($status, $error) = $p->validate_item( 'pop3_configuration', $templ, $language, $form ); ! test_assert_equal( $status, "pop3 port update " . ( $port + 1 ) . "\n" ); test_assert( !defined( $error ) ); test_assert_equal( $p->config_('port'), $port + 1 ); *************** *** 274,278 **** ($status, $error) = $p->validate_item( 'pop3_configuration', $templ, $language, $form ); ! test_assert_equal( $error, "configuration error 3" ); test_assert( !defined( $status ) ); test_assert_equal( $p->config_( 'port' ), $port ); --- 274,278 ---- ($status, $error) = $p->validate_item( 'pop3_configuration', $templ, $language, $form ); ! test_assert_equal( $error, "configuration error 3\n" ); test_assert( !defined( $status ) ); test_assert_equal( $p->config_( 'port' ), $port ); *************** *** 286,290 **** ($status, $error) = $p->validate_item( 'pop3_configuration', $templ, $language, $form ); ! test_assert_equal( $status, "pop3 separator update '" ); test_assert( !defined( $error ) ); test_assert_equal( $p->config_( 'separator' ), "'" ); --- 286,290 ---- ($status, $error) = $p->validate_item( 'pop3_configuration', $templ, $language, $form ); ! test_assert_equal( $status, "pop3 separator update '\n" ); test_assert( !defined( $error ) ); test_assert_equal( $p->config_( 'separator' ), "'" ); *************** *** 297,301 **** ($status, $error) = $p->validate_item( 'pop3_configuration', $templ, $language, $form ); ! test_assert_equal( $error, "configuration error 1" ); test_assert( !defined( $status ) ); test_assert_equal( $p->config_( 'separator' ), ':' ); --- 297,301 ---- ($status, $error) = $p->validate_item( 'pop3_configuration', $templ, $language, $form ); ! test_assert_equal( $error, "configuration error 1\n" ); test_assert( !defined( $status ) ); test_assert_equal( $p->config_( 'separator' ), ':' ); *************** *** 303,312 **** delete $form->{pop3_separator}; ! test_assert_equal( $p->config_( 'force_fork' ), 0 ); $form->{update_pop3_configuration} = 1; $form->{pop3_force_fork} = 1; ($status, $error) = $p->validate_item( 'pop3_configuration', $templ, $language, $form ); ! test_assert( !defined( $status ) ); test_assert( !defined( $error ) ); test_assert_equal( $p->config_( 'force_fork' ), 1 ); --- 303,314 ---- delete $form->{pop3_separator}; ! test_assert_equal( $p->config_( 'force_fork' ), 0); $form->{update_pop3_configuration} = 1; $form->{pop3_force_fork} = 1; + $language->{'Configuration_POPForkEnabled'} = "use pop3 forking"; + $language->{'Configuration_POPForkDisabled'} = "don't use pop3 forking"; ($status, $error) = $p->validate_item( 'pop3_configuration', $templ, $language, $form ); ! test_assert_equal( $status, "use pop3 forking" ); test_assert( !defined( $error ) ); test_assert_equal( $p->config_( 'force_fork' ), 1 ); *************** *** 319,322 **** --- 321,331 ---- test_assert_equal( $p->config_( 'force_fork' ), 1 ); + $form->{pop3_force_fork} = ''; + + ($status, $error) = $p->validate_item( 'pop3_configuration', $templ, $language, $form ); + test_assert_equal( $status, "don't use pop3 forking" ); + test_assert( !defined($error) ); + test_assert_equal( $p->config_( 'force_fork' ), 0 ); + delete $form->{pop3_force_fork}; delete $form->{update_pop3_configuration}; *************** *** 345,349 **** ($status, $error) = $p->validate_item( 'pop3_chain', $templ, $language, $form ); ! test_assert_equal( $status, "secure server update www.example.com" ); test_assert_equal( defined( $error ), defined( undef ) ); test_assert_equal( $p->config_( 'secure_server' ), 'www.example.com' ); --- 354,358 ---- ($status, $error) = $p->validate_item( 'pop3_chain', $templ, $language, $form ); ! test_assert_equal( $status, "secure server update www.example.com\n" ); test_assert_equal( defined( $error ), defined( undef ) ); test_assert_equal( $p->config_( 'secure_server' ), 'www.example.com' ); *************** *** 358,362 **** ($status, $error) = $p->validate_item( 'pop3_chain', $templ, $language, $form ); ! test_assert_equal( $status, "secure port update 10110" ); test_assert_equal( defined( $error ), defined( undef ) ); test_assert_equal( $p->config_( 'secure_port' ), 10110 ); --- 367,371 ---- ($status, $error) = $p->validate_item( 'pop3_chain', $templ, $language, $form ); ! test_assert_equal( $status, "secure port update 10110\n" ); test_assert_equal( defined( $error ), defined( undef ) ); test_assert_equal( $p->config_( 'secure_port' ), 10110 ); *************** *** 375,385 **** $old_config_value = $p->config_( 'secure_ssl' ); - $form->{update_server} = 1; $form->{sssl} = "1"; $language->{Security_SecureServerUseSSLOn} = "use SSL connections"; $language->{Security_SecureServerUseSSLOff} = "not use SSL connections"; ($status, $error) = $p->validate_item( 'pop3_chain', $templ, $language, $form ); ! test_assert_equal( $status, "use SSL connections" ); test_assert( !defined( $error ) ); test_assert_equal( $p->config_( 'secure_ssl' ), 1 ); --- 384,395 ---- $old_config_value = $p->config_( 'secure_ssl' ); $form->{sssl} = "1"; + $form->{update_server} = 1; + $language->{Security_SecureServerUseSSLOn} = "use SSL connections"; $language->{Security_SecureServerUseSSLOff} = "not use SSL connections"; ($status, $error) = $p->validate_item( 'pop3_chain', $templ, $language, $form ); ! test_assert_equal( $status, "use SSL connections\n" ); test_assert( !defined( $error ) ); test_assert_equal( $p->config_( 'secure_ssl' ), 1 ); *************** *** 388,396 **** ($status, $error) = $p->validate_item( 'pop3_chain', $templ, $language, $form ); ! test_assert_equal( $status, "not use SSL connections" ); test_assert( !defined( $error ) ); test_assert_equal( $p->config_( 'secure_ssl' ), 0 ); ! delete $form->{server}; delete $form->{update_server}; $p->config_('secure_ssl', $old_config_value ); --- 398,406 ---- ($status, $error) = $p->validate_item( 'pop3_chain', $templ, $language, $form ); ! test_assert_equal( $status, "not use SSL connections\n" ); test_assert( !defined( $error ) ); test_assert_equal( $p->config_( 'secure_ssl' ), 0 ); ! delete $form->{sssl}; delete $form->{update_server}; $p->config_('secure_ssl', $old_config_value ); Index: TestConfiguration.tst =================================================================== RCS file: /cvsroot/popfile/engine/tests/TestConfiguration.tst,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** TestConfiguration.tst 17 Apr 2008 15:13:05 -0000 1.26 --- TestConfiguration.tst 25 Apr 2008 16:26:50 -0000 1.27 *************** *** 119,122 **** --- 119,126 ---- open FILE, "<popfile.cfg"; my $line = <FILE>; + test_assert_regexp( $line, 'GLOBAL_ca_file ./certs/ca.pem' ); + $line = <FILE>; + test_assert_regexp( $line, 'GLOBAL_cert_file ./certs/server-cert.pem' ); + $line = <FILE>; test_assert_regexp( $line, 'GLOBAL_crypt_device ' ); $line = <FILE>; *************** *** 125,128 **** --- 129,134 ---- test_assert_regexp( $line, 'GLOBAL_debug 0' ); $line = <FILE>; + test_assert_regexp( $line, 'GLOBAL_key_file ./certs/server-key.pem' ); + $line = <FILE>; test_assert_regexp( $line, 'GLOBAL_language English' ); $line = <FILE>; Index: TestBayes.tst =================================================================== RCS file: /cvsroot/popfile/engine/tests/TestBayes.tst,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** TestBayes.tst 16 Apr 2008 13:08:05 -0000 1.64 --- TestBayes.tst 25 Apr 2008 16:26:49 -0000 1.65 *************** *** 57,60 **** --- 57,61 ---- my $l = $POPFile->get_module( 'POPFile/Logger' ); + $l->config_( 'level', 1 ); $b->module_config_( 'pop3', 'port', 9110 ); *************** *** 143,152 **** --- 144,159 ---- my $session2 = $b->get_session_key_from_token( $session, 'smtp', 'token' ); test_assert( $b->is_admin_session( $session2 ) ); + $b->release_session_key( $session2 ); $session2 = $b->get_session_key_from_token( $session, 'nntp', 'token' ); test_assert( $b->is_admin_session( $session2 ) ); + $b->release_session_key( $session2 ); $session2 = $b->get_session_key_from_token( $session, 'pop', 'token' ); test_assert( $b->is_admin_session( $session2 ) ); + $b->release_session_key( $session2 ); $session2 = $b->get_session_key_from_token( $session, 'pop3', 'token' ); test_assert( $b->is_admin_session( $session2 ) ); + $b->release_session_key( $session2 ); + + # Multi user mode $b->global_config_( 'single_user', 0 ); *************** *** 154,161 **** --- 161,171 ---- $session2 = $b->get_session_key_from_token( $session, 'smtp', 'token' ); test_assert( $b->is_admin_session( $session2 ) ); + $b->release_session_key( $session2 ); $session2 = $b->get_session_key_from_token( $session, 'nntp', 'token' ); test_assert( $b->is_admin_session( $session2 ) ); + $b->release_session_key( $session2 ); $session2 = $b->get_session_key_from_token( $session, 'pop', 'token' ); test_assert( $b->is_admin_session( $session2 ) ); + $b->release_session_key( $session2 ); $session2 = $b->get_session_key_from_token( $session, 'pop3', 'token' ); test_assert( !defined( $session2 ) ); *************** *** 185,188 **** --- 195,199 ---- $session1 = $b->get_session_key_from_token( $session, 'pop3', 'example.com:testuser' ); test_assert( defined( $session1 ) ); + $b->release_session_key( $session1 ); $session1 = $b->get_session_key_from_token( $session, 'pop3', 'fooz:bar' ); *************** *** 191,194 **** --- 202,206 ---- $session1 = $b->get_session_key_from_token( $session, 'pop3', 'foo:bar' ); test_assert( defined( $session1 ) ); + $b->release_session_key( $session1 ); $b->module_config_( 'pop3', 'secure_server', '' ); *************** *** 279,282 **** --- 291,327 ---- test_assert( !defined($b->get_user_name_from_session( -1 )) ); + # get_current_sessions + + $POPFile->CORE_service(1); + + my $active_sessions = $b->get_current_sessions( $session ); + test_assert( defined($active_sessions) ); + test_assert_equal( $#{$active_sessions}, 1 ); + + foreach my $active_session ( @{$active_sessions} ) { + if ( $active_session->{userid} eq 1 ) { + test_assert_equal( $active_session->{session}, $session ); + } elsif ( $active_session->{userid} eq $id1 ) { + test_assert_equal( $active_session->{session}, $session1 ); + } else { + test_assert( 0 ); + } + test_assert( defined($active_session->{lastused}) ); + } + + # timeout test + + $session2 = $b->get_session_key_from_token( $session, 'smtp', 'token' ); + + $active_sessions = $b->get_current_sessions( $session ); + test_assert_equal( $#{$active_sessions}, 2 ); + + $b->{api_sessions__}{$session2}{lastused} = 0; # expired + $POPFile->CORE_service(1); + $POPFile->CORE_service(1); + + $active_sessions = $b->get_current_sessions( $session ); + test_assert_equal( $#{$active_sessions}, 1 ); + # create_user with cloning admin *************** *** 902,905 **** --- 947,951 ---- while ( <OUTPUT> ) { my $output_line = $_; + next if ( $output_line =~ /^X-POPFile-TimeoutPrevension:/ ); my $cam_line = <CAM> || ''; $output_line =~ s/[\r\n]//g; Index: TestProxy.tst =================================================================== RCS file: /cvsroot/popfile/engine/tests/TestProxy.tst,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** TestProxy.tst 9 Apr 2008 17:20:48 -0000 1.27 --- TestProxy.tst 25 Apr 2008 16:26:50 -0000 1.28 *************** *** 659,662 **** --- 659,663 ---- #$b->stop(); + $POPFile->CORE_stop(); 1; |