]> sjero.net Git - wget/commitdiff
Test --auth-no-challenge, for URL- and option-specified user/pass.
authorMicah Cowan <micah@cowan.name>
Tue, 11 Nov 2008 20:53:01 +0000 (12:53 -0800)
committerMicah Cowan <micah@cowan.name>
Tue, 11 Nov 2008 20:53:01 +0000 (12:53 -0800)
tests/ChangeLog
tests/HTTPServer.pm
tests/Test-auth-no-challenge-url.px [new file with mode: 0755]
tests/Test-auth-no-challenge.px [new file with mode: 0755]
tests/run-px

index 751402d053f2a55bf0ee22627401cd81ab1b9d1f..e432c35ccd40a00efd95e033f85ed98876a06e92 100644 (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
index b76f0985742af738c1ddb2ed3514aa1a9afd7a3e..57b0499faa47df2c109210f6c9fb59769a457c65 100644 (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'}) {
diff --git a/tests/Test-auth-no-challenge-url.px b/tests/Test-auth-no-challenge-url.px
new file mode 100755 (executable)
index 0000000..53f6245
--- /dev/null
@@ -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
+
diff --git a/tests/Test-auth-no-challenge.px b/tests/Test-auth-no-challenge.px
new file mode 100755 (executable)
index 0000000..19b2a6d
--- /dev/null
@@ -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
+
index 92e9061e0694645e3e3474dfbe07e80fff19647d..ef38418c510cecb0823b66892df086263fdffd36 100755 (executable)
@@ -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',