On Sun, Oct 07, 2001 at 03:30:58PM -0400, Kirrily 'Skud' Robert ([EMAIL PROTECTED]) wrote: > OK, I've been putting off figuring this out for ages, but here it is:
<snip of a good, elegant example> Another way to accomplish the same thing, that I hacked up to test an internal password-protected web gadget: ------------------------------------------------------------ use strict; use Test::More qw(no_plan); use LWP::Simple; my $WEB_SYSTEM = 'foo.bar.com'; my $USERNAME = 'foo'; my $PASSWORD = 'bar'; use LWP::UserAgent; # We make our own specialization of LWP::UserAgent that asks for # user/password if document is protected. { package RequestAgent; use base qw(LWP::UserAgent); sub new { my $self = LWP::UserAgent::new(@_); $self->agent("lwp-request/$VERSION"); $self; } sub get_basic_credentials { my($self, $realm, $uri) = @_; return ($USERNAME, $PASSWORD); } } my $url = "http://" . $STORY_EDITOR . "/"; my $ua = RequestAgent->new; my $request = HTTP::Request->new('GET', $url); my $response = $ua->request($request); ok($response->is_success, "System is up and running at $WEB_SYSTEM" ); ----------------------------------------------------------------- Far less elegant, but there it is. Suggestions welcome. > I'm updating the Test::FAQ on the Wiki to show this. Where's that Wiki again? srl -- Shane Landrum (srl AT boston DOT com) Software Engineer, boston.com