develooper Front page | perl.module-authors | Postings from October 2005

Re: Tests needing user parameters

Thread Previous | Thread Next
From:
psema4
Date:
October 19, 2005 15:13
Subject:
Re: Tests needing user parameters
Message ID:
99a6c38f0510191512w7b160ca9y86ecc87587c291ad@mail.gmail.com
On 10/19/05, Mark Stosberg <mark@summersault.com> wrote:
> On Wed, Oct 19, 2005 at 10:50:04PM +0100, Jess Robinson wrote:
> > > >
> > > > I'm writing a module which will need user account data for it's tests, and
> > > > I'm wondering if there's a standard way (or module) for doing this..
> > >
> > > What do you mean by "user account data"?
> > >
> > > Perhaps UNIX/Linux UIDs and GIDs?
> >
> > Oops, sorry, thought it made sense ;)
> >
> > My module will login to a web service and manipulate data
> > programmatically.. Nothing critical I assure you, just a tool ;) Since
> > theres no dummy/test account that I know of, I'll need the users
> > account/email address and password to login.
>
> Using an OO approach is one way to go:
>
> my $t = Test::Foo->new(\%my_params);
>
> $t->wobble_ok('zoop');

If you have administrative access (or mod_auth_mysql installed, along
with a mysql database), this method might work.  Similar solutions
might also be workable, depending on your setup and installed
packages.

I've been using mod_auth_mysql, Apache, and CGI.pm to handle this
situation (if I'm reading the question right) for a couple years now. 
A scheduled cron job runs every 30 minutes to copy the email users
encrypted passwords into the mysql tables if they've changed, adding
or removing user records as necessary to keep in sync with the email
accounts.  (Might be a hack but it works.)

After that, it's a relatively simple matter of setting up .htaccess
files (or http.conf) and adding to your scripts:

...
use CGI;
my $q = new CGI;
my $remote_user = $q->remote_user();
...

--
- SGE

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About