1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

Test --auth-no-challenge, for URL- and option-specified user/pass.

This commit is contained in:
Micah Cowan 2008-11-11 12:53:01 -08:00
parent 65ab102f07
commit c60c7b9941
5 changed files with 116 additions and 2 deletions

View File

@ -1,3 +1,14 @@
2008-11-11 Micah Cowan <micah@cowan.name>
* HTTPServer.pm (handle_auth): Allow testing of
--auth-no-challenge.
* Test-auth-no-challenge.px, Test-auth-no-challenge-url.px:
Added.
* run-px: Add Test-auth-no-challenge.px,
Test-auth-no-challenge-url.px.
2008-11-07 Steven Schubiger <stsc@members.fsf.org>
* run-px: Use some colors for the summary part of the test

View File

@ -144,8 +144,7 @@ sub handle_auth {
my $authhdr = $req->header('Authorization');
# Have we sent the challenge yet?
unless (defined $url_rec->{auth_challenged}
&& $url_rec->{auth_challenged}) {
unless ($url_rec->{auth_challenged} || $url_rec->{auth_no_challenge}) {
# Since we haven't challenged yet, we'd better not
# have received authentication (for our testing purposes).
if ($authhdr) {
@ -166,6 +165,9 @@ sub handle_auth {
# failed it.
$code = 400;
$msg = "You didn't send auth after I sent challenge";
if ($url_rec->{auth_no_challenge}) {
$msg = "--auth-no-challenge but no auth sent."
}
} else {
my ($sent_method) = ($authhdr =~ /^(\S+)/g);
unless ($sent_method eq $url_rec->{'auth_method'}) {

View File

@ -0,0 +1,49 @@
#!/usr/bin/perl -w
use strict;
use HTTPTest;
###############################################################################
my $wholefile = "You're all authenticated.\n";
# code, msg, headers, content
my %urls = (
'/needs-auth.txt' => {
auth_no_challenge => 1,
auth_method => 'Basic',
user => 'fiddle-dee-dee',
passwd => 'Dodgson',
code => "200",
msg => "You want fries with that?",
headers => {
"Content-type" => "text/plain",
},
content => $wholefile,
},
);
my $cmdline = $WgetTest::WGETPATH . " --auth-no-challenge "
. "http://fiddle-dee-dee:Dodgson\@localhost:{{port}}/needs-auth.txt";
my $expected_error_code = 0;
my %expected_downloaded_files = (
'needs-auth.txt' => {
content => $wholefile,
},
);
###############################################################################
my $the_test = HTTPTest->new (name => "Test-auth-no-challenge-url",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,
output => \%expected_downloaded_files);
exit $the_test->run();
# vim: et ts=4 sw=4

50
tests/Test-auth-no-challenge.px Executable file
View File

@ -0,0 +1,50 @@
#!/usr/bin/perl -w
use strict;
use HTTPTest;
###############################################################################
my $wholefile = "You're all authenticated.\n";
# code, msg, headers, content
my %urls = (
'/needs-auth.txt' => {
auth_no_challenge => 1,
auth_method => 'Basic',
user => 'fiddle-dee-dee',
passwd => 'Dodgson',
code => "200",
msg => "You want fries with that?",
headers => {
"Content-type" => "text/plain",
},
content => $wholefile,
},
);
my $cmdline = $WgetTest::WGETPATH . " --auth-no-challenge"
. " --user=fiddle-dee-dee --password=Dodgson"
. " http://localhost:{{port}}/needs-auth.txt";
my $expected_error_code = 0;
my %expected_downloaded_files = (
'needs-auth.txt' => {
content => $wholefile,
},
);
###############################################################################
my $the_test = HTTPTest->new (name => "Test-auth-no-challenge",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,
output => \%expected_downloaded_files);
exit $the_test->run();
# vim: et ts=4 sw=4

View File

@ -12,6 +12,8 @@ my $top_srcdir = shift @ARGV;
my @tests = (
'Test-auth-basic.px',
'Test-auth-no-challenge.px',
'Test-auth-no-challenge-url.px',
'Test-proxy-auth-basic.px',
'Test-proxied-https-auth.px',
'Test-N-HTTP-Content-Disposition.px',