$agent->add_header( Authorization => 'Basic Y2kjsdfgiuj mFzcpnsaXjfguysiufgybewpV0aA==' );
####
Submitting NextCustomer Button.
Form submission failed:
401 Authorization Required
$result is 0.
####
#!/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 the 10data_integrity script.',
'_submit_check' => '1',
'NextCustomer' => ' Next ',
);
# my $response = '0';
$agent->add_header( Authorization => 'Basic 2kjsdfgiujmFzcpnsaXjfguysiufgybewpV0aA==' );
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->content.\n\n\n";
print "\$result is $result.\n\n\n";
1;
sub get_test_cases {
return 1;
}
####
hesco@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.
####
hesco@rck-ltsp:~$ perl -MWWW::Mechanize::Shell -eshell http://www.ourdomain.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