Re: cookie_jar ignored with requests_redirectable = 1

2004-07-28 Thread Stas Bekman
David?
Boris Zentner wrote:
Hi,
recently I try to use Apache::Test with HTTP::Cookies. But it did not work as 
expected. I suppose the way to add a cookie_jar to A::T was with 
'Apache::TestRequest::user_agent'. I read the docs from 
Apache::TestRequest::user_agent. Here is the relevant part of it.

   And finally, the semantics of the requests_redirectable
   parameter is different than for LWP::UserAgent: It
   either follows redirects for a request, or it doesn't.
   Thus requests_redirectable is a boolean value instead of
   the array reference that LWP::UserAgent expects. To
This implies to me that I have the choice to enable or disable redirects for 
this useragent with a bool value.

Apache::TestRequest::user_agent(
  reset = 1, 
  cookie_jar = $cookie_jar, 
  requests_redirectable = 1 
);

But this way the cookies are ignored. I expected that 
HTTP::Cookies-extract_cookies is called after every request. Therefor I 
create the cookie_jar from

package My::Cookies;
use base 'HTTP::Cookies';
sub extract_cookies {
  warn extract_cookies!!!;
  shift-SUPER::extract_cookies(@_);
}
To get it work, I need to parse the cookie headers myself or 

Apache::TestRequest::user_agent(
  reset = 1, 
  cookie_jar = $cookie_jar, 
  requests_redirectable = 0 
);

But here I need to redirect myself or do it with the undocumented 

Apache::TestRequest::user_agent(
  reset = 1, 
  cookie_jar = $cookie_jar, 
  requests_redirectable = [qw~x y~]
);

that does anything I want but is undocumented!
Here is a part from Apache::TestRequest::user_agent that looks wrong to me.
my $redir = $args-{requests_redirectable};
if (ref $redir and (@$redir  1 or $redir-[0] ne 'POST')) {
$RedirectOK = 1;
} else {
$RedirectOK = 0;
}
##
And a test script.
use strict;
use warnings FATAL = 'all';
use Apache::Test;
use Apache::TestUtil;
use Apache::TestRequest qw'GET POST';
plan tests = 3, have 'LWP';
require HTTP::Cookies;
require HTML::Form;
use Data::Dumper;
package My::Cookies;
use base 'HTTP::Cookies';
sub extract_cookies {
  warn extract_cookies!!!;
  shift-SUPER::extract_cookies(@_);
}
package main;
my $cookie_jar = My::Cookies-new;
Apache::TestRequest::user_agent(
  reset  = 1, 
  cookie_jar = $cookie_jar, 
  requests_redirectable = [qw/c d/]
); 

# check if we can request a page
my $r = GET '/x';
ok t_cmp( $r-code, 200, '$r-code == HTTP_OK?');
ok t_cmp( qr:\Qnew account:, $r-content, new account page );
$r = POST '/y', [ 
  email = '[EMAIL PROTECTED]', 
  login = 'boris16', 
];
ok t_cmp( $r-code, 200, '$r-code == HTTP_OK?');


--
__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: [Patch] add TEST_EXTRA_ARGS to allow passing arguments to t/TEST thru make invocation

2004-07-28 Thread Philippe M. Chiasson
Geoffrey Young wrote:
ping
:)
 

Must have fell off my radar. How is the following patch ?
--Geoff
Stas Bekman wrote:
 

Geoffrey Young wrote:
   

I'm not sure about the name choice. $(TEST_VERBOSE) and $(TEST_FILES)
are the same as other Test packages use. Do they have $TEST_EXTRA_ARGS
too? Otherwise we may better use some name specific to Apache-Test?
   

MakeMaker looks to support only three: TEST_VERBOSE, TEST_FILE(S), and
TESTDB_SW.
so how about APACHE_TEST_EXTRA_ARGS?  it's verbose but it shouldn't be
too
bad and it beats making tons of extra targets.
 

+1
   

 


Index: Apache-Test/lib/Apache/TestMM.pm
===
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestMM.pm,v
retrieving revision 1.34
diff -u -I$Id -r1.34 TestMM.pm
--- Apache-Test/lib/Apache/TestMM.pm16 Apr 2004 19:47:42 -  1.34
+++ Apache-Test/lib/Apache/TestMM.pm28 Jun 2004 20:11:47 -
@@ -63,12 +63,12 @@
 
 test_clean :
$(FULLPERL) -I$(INST_ARCHLIB) -I$(INST_LIB) \
-   t/TEST -clean
+   t/TEST $(APACHE_TEST_EXTRA_ARGS) -clean
 
 run_tests : test_clean
$(PASSENV) \
$(FULLPERL) -I$(INST_ARCHLIB) -I$(INST_LIB) \
-   t/TEST -bugreport -verbose=$(TEST_VERBOSE) $(TEST_FILES)
+   t/TEST $(APACHE_TEST_EXTRA_ARGS) -bugreport -verbose=$(TEST_VERBOSE) 
$(TEST_FILES)
 
 test :: pure_all run_tests test_clean
 


signature.asc
Description: OpenPGP digital signature


Re: [Patch] add TEST_EXTRA_ARGS to allow passing arguments to t/TEST thru make invocation

2004-07-28 Thread Geoffrey Young


Philippe M. Chiasson wrote:
 Geoffrey Young wrote:
 
 ping

 :)
  

 Must have fell off my radar. How is the following patch ?

+1

--Geoff