hesco has asked for the wisdom of the Perl Monks concerning the following question:
Any clues would be appreciated.
-- Hugh
THIS ISSUE HAS BEEN RESOLVED!
I added the following:
just prior to the ->submit_form() method's invocation. The actual value assigned to Authorization was harvested from the LiveHTTPHeaders view of the request made through a firefox browser.$agent->add_header( Authorization => 'Basic Y2kjsdfgiuj mFzcpnsaXjfguy +siufgybewpV0aA==' );
It now returns a valid webpage that reflects the interaction. Now I can start testing my database interactions. jonsmith1982: thanks for the eye and the hand. Hope this solution might prove useful to others.
UPDATE:
I've given up on the WWW::Mechanize::Shell piece, unless someone offers a clue. I suspect its an issue of me never using one-liners from the command line and not being sure how to properly feed arguments in.
But the real issue for me here is that after establishing credentials and giving me access to the form, it denies me credentials and gives me a 401 Authorization Denied error when I submit the form.
My errors are currently looking like this:
The code below has also been updated to reflect my work over the last hour or so.Submitting NextCustomer Button. Form submission failed: 401 Authorization Required $result is 0.
The code which I'm working on looks like this:
My dead-end on the WWW::Mechanize::Shell piece:#!/usr/bin/perl -w use strict; use Test::More; use WWW::Mechanize; use MIME::Base64; my $agent = WWW::Mechanize->new(); my $url = "http://www.ourdomain.com/path/to/our/script"; my $user = "testy_the_tester"; my $pw = "secret"; my @args = ( Authorization => "Basic " . MIME::Base64::encode( $user . ':' +. $pw ) ); $agent->get( $url , @args ); print "\n\n\n"; print "First invocation of webpage.\n"; print "\n\n\n"; my $response = $agent->content(); # $response = grep /ID #:/, $response; print $response; print "\n\n\n"; print "Submitting NextCustomer Button."; print "\n\n\n"; my %fields = ( 'status' => 'Contacted', 'customer' => 'Customer', 'callback' => 'callback', 'comments' => 'This is a test comment generated by th +e 10data_integrity script.', '_submit_check' => '1', 'NextCustomer' => ' Next ', ); # my $response = '0'; $agent->add_header( Authorization => 'Basic 2kjsdfgiujmFzcpnsaXjfguysi +ufgybewpV0aA==' ); my $response2 = $agent->submit_form( form_name => 'VoterCall', with_fields => \%fields, button => "NextVoter", ); if ($response2->is_success) { if($response2->content =~ /401 Authorization Required/){ print "Form submission failed at authorization stage.\n\n"; } else { print "\nAccess was granted, the results follow: \n\n",$response2- +>content; } } else { print STDERR "Form submission failed: \n", $response2->status_line, +"\n"; } # print "This resulted in the following response:\n\n $response->conte +nt.\n\n\n"; print "\$result is $result.\n\n\n"; 1; sub get_test_cases { return 1; }
line 430 relates to a request uri. When I feed it my url on the command line, like sohesco@rck-ltsp:~$ perl -MWWW::Mechanize::Shell -eshell Module File::Modified not found. Automatic reloading disabled. Can't call method "request" on an undefined value at /usr/local/share/ +perl/5.8.4/WWW/Mechanize.pm line 430.
I get this instead:hesco@rck-ltsp:~$ perl -MWWW::Mechanize::Shell -eshell http://www.ourd +omain.com/path/to/our/script
http://www.ourdomain.com/path/to/our/script Module File::Modified not found. Automatic reloading disabled. Couldn't open 'http://www.ourdomain.com/path/to/our/script' : No such +file or directory
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Losing Credentials, and Stumped by WWW::Mechanize::Shell startup error.
by jonsmith1982 (Beadle) on Nov 14, 2006 at 00:28 UTC | |
by hesco (Deacon) on Nov 14, 2006 at 02:38 UTC | |
by jonsmith1982 (Beadle) on Nov 14, 2006 at 03:18 UTC | |
by hesco (Deacon) on Nov 14, 2006 at 05:33 UTC | |
|
Re: Losing Credentials, Auth Basic and WWW::Mechanize
by Anonymous Monk on Nov 14, 2006 at 11:22 UTC |