From: naoki i. <am...@us...> - 2008-04-30 14:41:46
|
Update of /cvsroot/popfile/engine/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30027/tests Modified Files: TestHTML.script TestHTML.tst Log Message: Change Log 1. Message count, False positive count and False negative count are not copied when cloning user Classifier/Bayes.pm 2. Users page cannot be accessed in the single user mode UI/HTML.pm 3. Fixed a bug that malformed cookies would crash POPFile UI/HTTP.pm 4. Tests for multiuser mode 5. Tests for cookies 6. Tests for redirection 7. Tests for status messages tests/TestHTML.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.tst =================================================================== RCS file: /cvsroot/popfile/engine/tests/TestHTML.tst,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** TestHTML.tst 28 Apr 2008 11:48:59 -0000 1.41 --- TestHTML.tst 30 Apr 2008 14:41:49 -0000 1.42 *************** *** 296,301 **** $dwriter->autoflush(1); - use LWP::Simple; use LWP::UserAgent; use URI::URL; use String::Interpolate; --- 296,301 ---- $dwriter->autoflush(1); use LWP::UserAgent; + use HTTP::Cookies; use URI::URL; use String::Interpolate; *************** *** 305,308 **** --- 305,314 ---- my %h = ( port => \$port ); + # Cookies + + my $cookie_jar = HTTP::Cookies->new(file => 'TestHTML_cookie', autosave => 1); + $cookie_jar->clear; + $ua->cookie_jar($cookie_jar); + my $in = new String::Interpolate %h; *************** *** 357,367 **** if ( defined( $request ) ) { my $response = $ua->request( $request ); - @forms = HTML::Form->parse( $response ); if ( $response->code == 302 ) { ! $content = get(url("http://127.0.0.1:$port" . $response->headers->header('Location'))); ! @forms = HTML::Form->parse( $content, "http://127.0.0.1:$port" ); } else { test_assert_equal( $response->code, 200, "From script line $line_number" ); $content = $response->content; } $content =~ s/^[\t ]+//gm; --- 363,377 ---- if ( defined( $request ) ) { my $response = $ua->request( $request ); if ( $response->code == 302 ) { ! # print " REDIRECTED to ", $response->headers->header('Location'), " at line $line_number\n"; ! $request = HTTP::Request->new( 'GET', "http://127.0.0.1:$port" . $response->headers->header('Location') ); ! $response = $ua->request( $request ); ! $content = $response->content; ! @forms = HTML::Form->parse( $response ); ! # print $content; } else { test_assert_equal( $response->code, 200, "From script line $line_number" ); $content = $response->content; + @forms = HTML::Form->parse( $response ); } $content =~ s/^[\t ]+//gm; *************** *** 486,495 **** if ( defined( $request ) ) { my $response = $ua->request( $request ); ! $content = $response->content; $content =~ s/^[\t ]+//gm; $content =~ s/[\t ]+$//gm; while ( ( $content =~ s/\n\n/\n/gs ) > 0 ) { } - @forms = HTML::Form->parse( $response ); } next; --- 496,515 ---- if ( defined( $request ) ) { my $response = $ua->request( $request ); ! if ( $response->code == 302 ) { ! # print " REDIRECTED to ", $response->headers->header('Location'), " at line $line_number\n"; ! $request = HTTP::Request->new( 'GET', "http://127.0.0.1:$port" . $response->headers->header('Location') ); ! $response = $ua->request( $request ); ! $content = $response->content; ! @forms = HTML::Form->parse( $response ); ! # print $content; ! } else { ! test_assert_equal( $response->code, 200, "From script line $line_number" ); ! $content = $response->content; ! @forms = HTML::Form->parse( $response ); ! } $content =~ s/^[\t ]+//gm; $content =~ s/[\t ]+$//gm; while ( ( $content =~ s/\n\n/\n/gs ) > 0 ) { } } next; *************** *** 600,603 **** --- 620,631 ---- } + if ( $line =~ /^SETCOOKIE +(.*)$/ ) { + # print " Current cookie : ", $ua->cookie_jar->as_string, "\n"; + $cookie_jar->set_cookie( 0, 'popfile', $1, '/', '127.0.0.1', undef, undef, undef, undef, 1 ); + # $ua->cookie_jar->set_cookie( 1, 'popfile', $1, '/', 'http://127.0.0.1' ); + # print " Changed cookie : ", $ua->cookie_jar->as_string, "\n"; + next; + } + if ( $line =~ /[^ \t\r\n]/ ) { test_assert( 0, "Don't understand line $line_number" ); Index: TestHTML.script =================================================================== RCS file: /cvsroot/popfile/engine/tests/TestHTML.script,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** TestHTML.script 28 Apr 2008 11:17:43 -0000 1.40 --- TestHTML.script 30 Apr 2008 14:41:49 -0000 1.41 *************** *** 72,75 **** --- 72,77 ---- MATCH <link rel="icon" href="favicon.ico"> + MATCH <a class="shutdownLink" href="/shutdown">Shutdown POPFile</a> + # Common MIDDLE parts (i.e. the tabs) *************** *** 85,88 **** --- 87,93 ---- [...1103 lines suppressed...] ! MATCH Recent Messages ! ! SETINPUT old_password secret ! SETINPUT new_password ! SETINPUT confirm_password ! CLICK change_password ! MATCH New password has been set ! ! SETINPUT old_password wrongpassword ! CLICK change_password ! MATCH The old password entered is incorrect ! SETINPUT old_password ! SETINPUT new_password secret ! SETINPUT confirm_password wrongconfirmpassword ! CLICK change_password ! MATCH The new password must by identical in the New and Confirm New boxes ! # Check shutdown operation |