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:
parent
65ab102f07
commit
c60c7b9941
@ -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>
|
2008-11-07 Steven Schubiger <stsc@members.fsf.org>
|
||||||
|
|
||||||
* run-px: Use some colors for the summary part of the test
|
* run-px: Use some colors for the summary part of the test
|
||||||
|
@ -144,8 +144,7 @@ sub handle_auth {
|
|||||||
my $authhdr = $req->header('Authorization');
|
my $authhdr = $req->header('Authorization');
|
||||||
|
|
||||||
# Have we sent the challenge yet?
|
# Have we sent the challenge yet?
|
||||||
unless (defined $url_rec->{auth_challenged}
|
unless ($url_rec->{auth_challenged} || $url_rec->{auth_no_challenge}) {
|
||||||
&& $url_rec->{auth_challenged}) {
|
|
||||||
# Since we haven't challenged yet, we'd better not
|
# Since we haven't challenged yet, we'd better not
|
||||||
# have received authentication (for our testing purposes).
|
# have received authentication (for our testing purposes).
|
||||||
if ($authhdr) {
|
if ($authhdr) {
|
||||||
@ -166,6 +165,9 @@ sub handle_auth {
|
|||||||
# failed it.
|
# failed it.
|
||||||
$code = 400;
|
$code = 400;
|
||||||
$msg = "You didn't send auth after I sent challenge";
|
$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 {
|
} else {
|
||||||
my ($sent_method) = ($authhdr =~ /^(\S+)/g);
|
my ($sent_method) = ($authhdr =~ /^(\S+)/g);
|
||||||
unless ($sent_method eq $url_rec->{'auth_method'}) {
|
unless ($sent_method eq $url_rec->{'auth_method'}) {
|
||||||
|
49
tests/Test-auth-no-challenge-url.px
Executable file
49
tests/Test-auth-no-challenge-url.px
Executable 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
50
tests/Test-auth-no-challenge.px
Executable 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
|
||||||
|
|
@ -12,6 +12,8 @@ my $top_srcdir = shift @ARGV;
|
|||||||
|
|
||||||
my @tests = (
|
my @tests = (
|
||||||
'Test-auth-basic.px',
|
'Test-auth-basic.px',
|
||||||
|
'Test-auth-no-challenge.px',
|
||||||
|
'Test-auth-no-challenge-url.px',
|
||||||
'Test-proxy-auth-basic.px',
|
'Test-proxy-auth-basic.px',
|
||||||
'Test-proxied-https-auth.px',
|
'Test-proxied-https-auth.px',
|
||||||
'Test-N-HTTP-Content-Disposition.px',
|
'Test-N-HTTP-Content-Disposition.px',
|
||||||
|
Loading…
Reference in New Issue
Block a user