Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Re: [mp2 Patch] Add simple tests in modules/ for Apache::Session: msg#00124

apache.mod-perl.devel

Subject: Re: [mp2 Patch] Add simple tests in modules/ for Apache::Session

On Tue, 2003-06-10 at 14:16, Stas Bekman wrote:
> Philippe M. Chiasson wrote:
> > Hi, after seeing a question asking about Apache::Session under mod_perl
> > 2.x, I've written this simple test case for it and it seems to be
> > working quite nicely under mp2, AFAICS
>
> Did you plan on attaching something?

Hrm, well, of course I did !

Index: t/modules/session.t
===================================================================
RCS file: t/modules/session.t
diff -N t/modules/session.t
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ t/modules/session.t 10 Jun 2003 06:06:22 -0000
@@ -0,0 +1,48 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestRequest;
+use Apache::TestUtil;
+
+plan tests => 6, have 'Apache::Session';
+
+my $module = 'TestModules::session';
+my $location = '/' . Apache::TestRequest::module2path($module);
+
+my ($input, $session_id, $global_sid);
+my $global_input = $$;
+
+{
+ my $res = GET $location;
+
+ eval $res->content;
+
+ ok t_cmp("", $input, "New Session");
+
+ ok t_cmp(qr{^[0-9a-f]{32}$}, $session_id, "New Session");
+
+ $global_sid = $session_id;
+}
+
+{
+ my $res = GET "$location/$session_id?$global_input";
+
+ eval $res->content;
+
+ ok t_cmp($global_input, $input, "token reception");
+
+ ok t_cmp($global_sid, $session_id, "Session ID");
+}
+
+{
+ my $res = GET "$location/$session_id";
+
+ eval $res->content;
+
+ ok t_cmp($global_input, $input, "token retrievaln");
+
+ ok t_cmp($global_sid, $session_id, "Session ID");
+}
+
+GET "$location/$session_id?cleanup";
Index: t/response/TestModules/session.pm
===================================================================
RCS file: t/response/TestModules/session.pm
diff -N t/response/TestModules/session.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ t/response/TestModules/session.pm 10 Jun 2003 06:06:22 -0000
@@ -0,0 +1,50 @@
+package TestModules::session;
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Const -compile => 'OK';
+
+use Apache::RequestRec ();
+use ModPerl::Util ();
+use Apache::Session::File;
+use File::Spec ();
+
+my $tmpdir = File::Spec->tmpdir();
+
+sub handler
+{
+ my $r = shift;
+
+ $r->status(200);
+ $r->content_type("text/plain");
+
+ my $session_id = $r->path_info();
+ $session_id =~ s/^\///;
+
+ $session_id = $session_id ? $session_id : undef;
+
+ ModPerl::Util::untaint($session_id);
+
+ my %session;
+
+ tie %session, 'Apache::Session::File', $session_id,
+ {Directory => $tmpdir, LockDirectory => $tmpdir, Transaction => 1};
+
+ $session{input} ||= $r->args() || "";
+
+ $r->print(<<"EOF");
+\$session_id="$session{_session_id}";
+\$input="$session{input}";
+EOF
+
+ if ($session{input} eq "cleanup")
+ {
+ tied(%session)->delete;
+ }
+
+ Apache::OK;
+}
+
+1;
+__END__



> > In parallel to mp1, that has quite a few tests for 3rd party Apache::*
> > modules, should we try and move some of those tests over to mp2's test
> > suite as well ?
>
> I think we should move them only if they aren't 3rd party tests. If they are
> it's the best that those modules will include a test suite.

Yes, it does make sense, especially once Apache::Test has reached a
wider audience. I agree.

So guess this particular test should be ditched and Apache::Session
should use Apache::Test for it's test suite. I might have time to give
it a shot later on. Keep reading ;-)

Gozer out.

> __________________________________________________________________
> Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/ mod_perl Guide ---> http://perl.apache.org
> mailto:stas@xxxxxxxxxx http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org http://ticketmaster.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@xxxxxxxxxxxxxxx
> For additional commands, e-mail: dev-help@xxxxxxxxxxxxxxx
--
-- -----------------------------------------------------------------------------
Philippe M. Chiasson /gozer\@(cpan|ectoplasm)\.org/ 88C3A5A5 (122FF51B/C634E37B)
http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3 A5A5
Q: It is impossible to make anything foolproof because fools are so ingenious.
perl -e'$$=\${gozer};{$_=unpack(P7,pack(L,$$));/^JAm_pH\n$/&&print||$$++&&redo}'

Attachment: signature.asc
Description: This is a digitally signed message part

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
hardware.arm.at...    cms.citadel.dev...    video.gstreamer...    java.facelets.u...    misc.basics.qna...    web.wiki.instik...    network.uip.use...    xdg.devel/2003-...    tex.bibtex.bibd...    finance.quotesp...    ietf.zeroconf/2...    redhat.blinux.g...    suse.db2/2003-0...    php.phpesp/2004...    uml.devel/2003-...    gnome.labyrinth...    qnx.openqnx.dev...    boot-loaders.gr...    db.dataperfect....    audio.audacity....    linux.uclinux.m...    editors.j.devel...    os.openbsd.tech...    kde.users.multi...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation