Re: FW: Re: Apache::TestRequest + Cookies
Ok, here's my first crack at a quick n dirty cookies test. The new test is t/cookies.t, and it's supporting server file is t/htdocs/cgi-bin/cookies.pl. I figured the extra cgi-bin directory was good for sanity sake. I've also included the necessary patches to MANIFEST and extra.conf.in against A-T 1.16. -=Chris a-t-cookie-test.tar.gz Description: GNU Zip compressed data
Re: FW: Re: Apache::TestRequest + Cookies
Christopher H. Laco wrote: Thanks, Chris, committed with a few small adjustements. You can see the commits here: http://svn.apache.org/viewcvs?view=revrev=109277 http://svn.apache.org/viewcvs?view=revrev=109279 Thanks. Glad to contribute. It looks like the only change was naming the cookies.pl to cookies.pl.PL. That was needed to get the path to #!perl right What cnvention did I miss so I don't make that mistake again? The only missing thing was to check that CGI and CGI::Cookie were available in plan(). I moved htdocs/cgi-bin/ = cgi-bin/ and did a few minor syntax changes. You can see what was applied at the URLs quoted at the top of this email. Now looking forward for docs updates. Thanks again. -- __ 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: FW: Re: Apache::TestRequest + Cookies
Stas Bekman wrote: Christopher H. Laco wrote: Thanks, Chris, committed with a few small adjustements. You can see the commits here: http://svn.apache.org/viewcvs?view=revrev=109277 http://svn.apache.org/viewcvs?view=revrev=109279 Thanks. Glad to contribute. It looks like the only change was naming the cookies.pl to cookies.pl.PL. That was needed to get the path to #!perl right What cnvention did I miss so I don't make that mistake again? The only missing thing was to check that CGI and CGI::Cookie were available in plan(). Duh. Silly me. I moved htdocs/cgi-bin/ = cgi-bin/ and did a few minor syntax changes. You can see what was applied at the URLs quoted at the top of this email. Now looking forward for docs updates. Thanks again.
Re: FW: Re: Apache::TestRequest + Cookies
Stas Bekman wrote: Christopher H. Laco wrote: Ok, here's my first crack at a quick n dirty cookies test. The new test is t/cookies.t, and it's supporting server file is t/htdocs/cgi-bin/cookies.pl. I figured the extra cgi-bin directory was good for sanity sake. I've also included the necessary patches to MANIFEST and extra.conf.in against A-T 1.16. Thanks, Chris, committed with a few small adjustements. You can see the commits here: http://svn.apache.org/viewcvs?view=revrev=109277 http://svn.apache.org/viewcvs?view=revrev=109279 You probably want to get the svn checkout to continue working with the latest version: svn checkout http://svn.apache.org/repos/asf/httpd/test/trunk/perl-framework/Apache-Test Apache-Test For docs (where you can find the latest testing.pod) it's: svn co http://svn.apache.org/repos/asf/perl/modperl/docs/trunk modperl-docs Thanks. Glad to contribute. It looks like the only change was naming the cookies.pl to cookies.pl.PL. What cnvention did I miss so I don't make that mistake again? -=Chris
Re: Apache::TestRequest + Cookies
just a very simple test that verifies that the documented technique works. later on it may evolve to include a special A-T API if we ever add one. Is it enought to do IfModule mod_usertrack.c and also need_module(mod_usertrack.c) to determine if the usertrack mnodule is installed, or is there someplace deeper within the setup where we can actually add LoadModule mod_usertrack.c? Thanks, -=Chris
Re: Apache::TestRequest + Cookies
Christopher H. Laco wrote: just a very simple test that verifies that the documented technique works. later on it may evolve to include a special A-T API if we ever add one. Is it enought to do IfModule mod_usertrack.c and also need_module(mod_usertrack.c) to determine if the usertrack mnodule is installed, or is there someplace deeper within the setup where we can actually add LoadModule mod_usertrack.c? for config it's enough for the code it's: plan tests = 5, need_module('usertrack'); but most people won't have this module installed... -- __ 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: Apache::TestRequest + Cookies
but most people won't have this module installed... Installed, or loaded? I know the httpd.conf defaults to having that module commented out, but the module itself should be around. Maybe relying on Apache::Session would cover more install scnerios instead. I was trying to avoid writing a custom handler just to accept and toss some cookies in the test environment, but maybe that's better. At least then everyone install should be able to run the A-T cookie test.
Re: Apache::TestRequest + Cookies
Christopher H. Laco wrote: but most people won't have this module installed... Installed, or loaded? I know the httpd.conf defaults to having that module commented out, but the module itself should be around. Loaded or even available... Maybe relying on Apache::Session would cover more install scnerios instead. I was trying to avoid writing a custom handler just to accept and toss some cookies in the test environment, but maybe that's better. At least then everyone install should be able to run the A-T cookie test. I think the same_interp setup will do what you want. e.g. see in modperl-2.0 repository this test couple: t/response/TestModperl/sameinterp.pm t/modperl/sameinterp.t -- __ 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: FW: Re: Apache::TestRequest + Cookies
CChristopher H. Laco wrote: Maybe relying on Apache::Session would cover more install scnerios instead. I was trying to avoid writing a custom handler just to accept and toss some cookies in the test environment, but maybe that's better. At least then everyone install should be able to run the A-T cookie test. I think the same_interp setup will do what you want. e.g. see in modperl-2.0 repository this test couple: t/response/TestModperl/sameinterp.pm t/modperl/sameinterp.t Yeah, I'll have to check that out. Thanks. (Yes, I just played the email switch-a-roo)
Re: FW: Re: Apache::TestRequest + Cookies
Christopher H. Laco wrote: Christopher H. Laco wrote: CChristopher H. Laco wrote: Maybe relying on Apache::Session would cover more install scnerios instead. I was trying to avoid writing a custom handler just to accept and toss some cookies in the test environment, but maybe that's better. At least then everyone install should be able to run the A-T cookie test. I think the same_interp setup will do what you want. e.g. see in modperl-2.0 repository this test couple: t/response/TestModperl/sameinterp.pm t/modperl/sameinterp.t Holy crap. That made my brain hurt. Would we use that directly, or just borrow the idea? Why don't you first post what you had on your mind. May be your idea doesn't need that at all. -- __ 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: FW: Re: Apache::TestRequest + Cookies
Stas Bekman wrote: [snip] Why don't you first post what you had on your mind. May be your idea doesn't need that at all. Well, here's what I was thinking. First, write a quick and dirty mod_perl handler that looked for a specific cookie; let's say 'ApacheTest'. If it wasn't supplied by the client, send a new copy out. If it was sent by the client, simply return the supplied cookie/value. Shouldn't take more than a few lines of code, and it removes the dependency of usertrack and Apache::Session. Then, simply write a test that makes a series of requests to that handler. The first response should return a new ApacheTest cookie/value, and the second test should pass back the same ApacheTest cookie/value if Apache::TestRequest::user_agent( cookie_jar = {}); and it's surroundings are woroking fine. -=Chris
Re: FW: Re: Apache::TestRequest + Cookies
Christopher H. Laco wrote: Stas Bekman wrote: [snip] Why don't you first post what you had on your mind. May be your idea doesn't need that at all. Well, here's what I was thinking. First, write a quick and dirty mod_perl handler that looked for a specific cookie; let's say 'ApacheTest'. If it wasn't supplied by the client, send a new copy out. If it was sent by the client, simply return the supplied cookie/value. Shouldn't take more than a few lines of code, and it removes the dependency of usertrack and Apache::Session. Then, simply write a test that makes a series of requests to that handler. The first response should return a new ApacheTest cookie/value, and the second test should pass back the same ApacheTest cookie/value if Apache::TestRequest::user_agent( cookie_jar = {}); and it's surroundings are woroking fine. Sounds good. Though it'll probably need to leave in the modperl2's test suite and not Apache-Test's one. but let's see the code first and then see where it's the best to apply it. You can use the http://perl.apache.org/~geoff/Apache-Test-skeleton-mp2.tar.gz to make it easy to write the test. -- __ 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: FW: Re: Apache::TestRequest + Cookies
Stas Bekman wrote: Sounds good. Though it'll probably need to leave in the modperl2's test suite and not Apache-Test's one. but let's see the code first and then see where it's the best to apply it. You can use the http://perl.apache.org/~geoff/Apache-Test-skeleton-mp2.tar.gz to make it easy to write the test. I guess that's where I'm getting confused. Why would this be in mp2 rather than in A-T, since I'm really trying to confirm a scenerio under A-T. Obviously there's something I'm missing. -=Chris
Re: FW: Re: Apache::TestRequest + Cookies
Christopher H. Laco wrote: Stas Bekman wrote: Sounds good. Though it'll probably need to leave in the modperl2's test suite and not Apache-Test's one. but let's see the code first and then see where it's the best to apply it. You can use the http://perl.apache.org/~geoff/Apache-Test-skeleton-mp2.tar.gz to make it easy to write the test. I guess that's where I'm getting confused. Why would this be in mp2 rather than in A-T, since I'm really trying to confirm a scenerio under A-T. Obviously there's something I'm missing. It should be in A-T, but since your test requires modperl it'd be better be in modperl, since chances are that A-T won't have modperl available and then it'll be skipped. So may be your original mod_usertrack idea was better, as it doesn't depend on mod_perl's availability (but at the same time depends on mod_usertrack). The reason I'm OK with adding A-T tests to modperl is that we run modperl2 tests all the time, much more often than A-T tests, so it's probably a second best place to put those cookie tests. In fact you can already find some cookie tests in the modperl2 test suite (against CGI.pm). -- __ 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: FW: Re: Apache::TestRequest + Cookies
Stas Bekman wrote: Christopher H. Laco wrote: Stas Bekman wrote: Sounds good. Though it'll probably need to leave in the modperl2's test suite and not Apache-Test's one. but let's see the code first and then see where it's the best to apply it. You can use the http://perl.apache.org/~geoff/Apache-Test-skeleton-mp2.tar.gz to make it easy to write the test. I guess that's where I'm getting confused. Why would this be in mp2 rather than in A-T, since I'm really trying to confirm a scenerio under A-T. Obviously there's something I'm missing. It should be in A-T, but since your test requires modperl it'd be better be in modperl, since chances are that A-T won't have modperl available and then it'll be skipped. So may be your original mod_usertrack idea was better, as it doesn't depend on mod_perl's availability (but at the same time depends on mod_usertrack). Can't the test be done with mod_cgi and not mod_perl? This should be available more often than mod_usertrack I would think. -- Michael Peters Developer Plus Three, LP
Re: FW: Re: Apache::TestRequest + Cookies
Stas Bekman wrote: Michael Peters wrote: Stas Bekman wrote: Christopher H. Laco wrote: Stas Bekman wrote: Sounds good. Though it'll probably need to leave in the modperl2's test suite and not Apache-Test's one. but let's see the code first and then see where it's the best to apply it. You can use the http://perl.apache.org/~geoff/Apache-Test-skeleton-mp2.tar.gz to make it easy to write the test. I guess that's where I'm getting confused. Why would this be in mp2 rather than in A-T, since I'm really trying to confirm a scenerio under A-T. Obviously there's something I'm missing. It should be in A-T, but since your test requires modperl it'd be better be in modperl, since chances are that A-T won't have modperl available and then it'll be skipped. So may be your original mod_usertrack idea was better, as it doesn't depend on mod_perl's availability (but at the same time depends on mod_usertrack). Can't the test be done with mod_cgi and not mod_perl? This should be available more often than mod_usertrack I would think. Yes, I was thinking the same. Good idea Michael. And it's enabled in the default shipping httpd.conf too! Great idea. I'll pursue it that method for now. -=Chris
Re: Apache::TestRequest + Cookies
Christopher H. Laco wrote: Now that I've gotten a few other module updates out of the way, I want to get back to the thought of cookies within A-T. Two things were mentioned that would help the A-T project in some way. First, possibly add pod doc on how to use cookies within A-T using Michaels solution of Apache::TestRequest::user_agent( cookie_jar = {}); +1 and possibly others. I would also probably take a stab at getting some of the other things in http://perl.apache.org/docs/general/testing/testing.html into the pod; specifically the use of the secondary param in the GET request to add outgoing headers and the like. +1 Second, add some sort of cookie tests to the A-T test suit. I'm not quite sure what a test would be for other than to verify that A-T using LWP actually receives and sends cookies and verifies they get remembered between requests. But that seems more like testing LWP and A-T to me. just a very simple test that verifies that the documented technique works. later on it may evolve to include a special A-T API if we ever add one. My first thoughts are to keep it as simple as possible and check for mod_usertrack. It it's there, ensure the first tracking cookie value is maintained across multiple requests. Whatever you find the best is fine with us. You may want to use the same_interp framework in case you need to make sure that you hit the same perl interpreter (in case you store some data on the server side). See the tests in modperl-2.0/t for examples. -- __ 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: Apache::TestRequest + Cookies
Christopher H. Laco wrote: Has anyone used ApacheTestRequest to test pages using cookiessessions? I'm writing some quick and dirty tests for an AxKit session module I've adopted. I've got everything up and running config wise and the pages are getting run through AxKit just fine. The first two tests simply consist of a set-value page which uses Apache::Session::File to store a value, and a get-value page that confirms the value is returned. Of course the get-value test, test 2, fails because Apache::TestRequest is ignore the sessionid cookie [or all cookies really]. I have LWP installed and I've tried a few different encantations using -cookie_jar and HTTPCookie without any luck. Is there a Tutorial or examples somwhere that cover dealing with sessions within Apache::TestRequest? I guess the silence means that no one has used it with cookies. I suppose that you could fix it to work with cookies though. But I could be wrong and it already works but not documented. there is a lot of such code in there. -- __ 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: Apache::TestRequest + Cookies
Stas Bekman wrote: Christopher H. Laco wrote: Has anyone used ApacheTestRequest to test pages using cookiessessions? I'm writing some quick and dirty tests for an AxKit session module I've adopted. I've got everything up and running config wise and the pages are getting run through AxKit just fine. The first two tests simply consist of a set-value page which uses Apache::Session::File to store a value, and a get-value page that confirms the value is returned. Of course the get-value test, test 2, fails because Apache::TestRequest is ignore the sessionid cookie [or all cookies really]. I have LWP installed and I've tried a few different encantations using -cookie_jar and HTTPCookie without any luck. Is there a Tutorial or examples somwhere that cover dealing with sessions within Apache::TestRequest? I guess the silence means that no one has used it with cookies. I suppose that you could fix it to work with cookies though. But I could be wrong and it already works but not documented. there is a lot of such code in there. LWP::UserAgent doesn't by default keep a cookie_jar. All I had to do was add this near the top of my test script before any GET/POST calls. Apache::TestRequest::user_agent( cookie_jar = {}); HTH -- Michael Peters Developer Plus Three, LP
Re: Apache::TestRequest + Cookies
Thanks. I'll give that a whirl tonight. I finally got the hack approach working by calling $apacheRequestResponse-headers(Set-Cookie) and passing that result right back into the [scantily mentioned] second param of Apache::TestRequest::GET 'url', headername = headervalue Since I only had on cookie, it works. All hell would break loose the minute I had more I assume. -=Chris From: Michael Peters [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: Apache::TestRequest + Cookies Date: Wed, 24 Nov 2004 14:29:02 -0500 MIME-Version: 1.0 Received: from mail.apache.org ([209.237.227.199]) by mc7-f8.hotmail.com with Microsoft SMTPSVC(5.0.2195.6824); Wed, 24 Nov 2004 11:28:56 -0800 Received: (qmail 99929 invoked by uid 500); 24 Nov 2004 19:28:40 - Received: (qmail 99899 invoked by uid 99); 24 Nov 2004 19:28:39 - Received: pass (hermes.apache.org: local policy) Received: from Unknown (HELO plusthree.com) (65.61.157.8) by apache.org (qpsmtpd/0.28) with SMTP; Wed, 24 Nov 2004 11:28:37 -0800 Received: (qmail 18178 invoked from network); 24 Nov 2004 19:28:21 - Received: from h-66-167-36-5.mclnva23.covad.net (HELO ?192.168.1.164?) ([EMAIL PROTECTED]) by 0 with SMTP; 24 Nov 2004 19:28:21 - X-Message-Info: JGTYoYF78jFk/IwND13SP4Tqx2eQ6P3t Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm Precedence: bulk list-help: mailto:[EMAIL PROTECTED] list-unsubscribe: mailto:[EMAIL PROTECTED] list-post: mailto:[EMAIL PROTECTED] Delivered-To: mailing list [EMAIL PROTECTED] X-ASF-Spam-Status: No, hits=0.0 required=10.0tests= X-Spam-Check-By: apache.org User-Agent: Mozilla Thunderbird 0.8 (X11/20041020) X-Accept-Language: en-us, en References: [EMAIL PROTECTED] [EMAIL PROTECTED] X-Enigmail-Version: 0.86.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime X-Virus-Checked: Checked Return-Path: [EMAIL PROTECTED] X-OriginalArrivalTime: 24 Nov 2004 19:28:57.0468 (UTC) FILETIME=[D7A04BC0:01C4D25B] Stas Bekman wrote: Christopher H. Laco wrote: Has anyone used ApacheTestRequest to test pages using cookiessessions? I'm writing some quick and dirty tests for an AxKit session module I've adopted. I've got everything up and running config wise and the pages are getting run through AxKit just fine. The first two tests simply consist of a set-value page which uses Apache::Session::File to store a value, and a get-value page that confirms the value is returned. Of course the get-value test, test 2, fails because Apache::TestRequest is ignore the sessionid cookie [or all cookies really]. I have LWP installed and I've tried a few different encantations using -cookie_jar and HTTPCookie without any luck. Is there a Tutorial or examples somwhere that cover dealing with sessions within Apache::TestRequest? I guess the silence means that no one has used it with cookies. I suppose that you could fix it to work with cookies though. But I could be wrong and it already works but not documented. there is a lot of such code in there. LWP::UserAgent doesn't by default keep a cookie_jar. All I had to do was add this near the top of my test script before any GET/POST calls. Apache::TestRequest::user_agent( cookie_jar = {}); HTH -- Michael Peters Developer Plus Three, LP
Re: Apache::TestRequest + Cookies
[snip] Or more to the point: my $r = GET 'url', Cookie = $apacheRequestResponse-headers(Set-Cookie);
Re: Apache::TestRequest + Cookies
Christopher H. Laco wrote: Thanks. I'll give that a whirl tonight. I finally got the hack approach working by calling $apacheRequestResponse-headers(Set-Cookie) and passing that result right back into the [scantily mentioned] second param of Apache::TestRequest::GET 'url', headername = headervalue if you could also contribute the cookie test that would be handy too. -- __ 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: Apache::TestRequest + Cookies
if you could also contribute the cookie test that would be handy too. I'm feeling a bit dense at the moment. To the list, or to the forthcoming [self] test suite? I'm not sure I understand the request. P.S. Sorry about my list replies full of headers. I need to unsubscribe from Hotmail and use a real email client from my home account. -=Chris
Re: Apache::TestRequest + Cookies
Christopher H. Laco wrote: if you could also contribute the cookie test that would be handy too. I'm feeling a bit dense at the moment. To the list, or to the forthcoming [self] test suite? I'm not sure I understand the request. Either way if you find how to use A-T to handle cookies or fix it to do so, it's be handy to add a new A-T tests (in addition to existing ones in Apache-Test/t/) so we don't break this feature in the future, which is easily possible sans having a test. Plus it'll be great to have this documented... if you don't have the time to send a proper patch, feel free to send some blurb+example(s) here and I'll adopt it for the docs. -- __ 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: Apache::TestRequest + Cookies
Either way if you find how to use A-T to handle cookies or fix it to do so, it's be handy to add a new A-T tests (in addition to existing ones in Apache-Test/t/) so we don't break this feature in the future, which is easily possible sans having a test. Plus it'll be great to have this documented... if you don't have the time to send a proper patch, feel free to send some blurb+example(s) here and I'll adopt it for the docs. Assuming Michaels solution works: Apache::TestRequest::user_agent( cookie_jar = {}); Are we looking for something more official to the actual Test::Request API; a new method, better parameters, etc; or is the above just good enough for a little mention?