diff --git a/testenv/Test-auth-both.py b/testenv/Test-auth-both.py index 91d72b84..23bdaf57 100755 --- a/testenv/Test-auth-both.py +++ b/testenv/Test-auth-both.py @@ -18,7 +18,10 @@ File1_rules = { "Authentication" : { "Type" : "Both", "User" : "Sauron", - "Pass" : "TheEye" + "Pass" : "TheEye", + "Parm" : { + "qop" : "auth" + } }, "RejectHeader" : { "Authorization" : "Basic U2F1cm9uOlRoZUV5ZQ==" @@ -28,7 +31,10 @@ File2_rules = { "Authentication" : { "Type" : "Both_inline", "User" : "Sauron", - "Pass" : "TheEye" + "Pass" : "TheEye", + "Parm" : { + "qop" : "auth" + } }, "RejectHeader" : { "Authorization" : "Basic U2F1cm9uOlRoZUV5ZQ==" @@ -38,7 +44,11 @@ File3_rules = { "Authentication" : { "Type" : "Digest", "User" : "Sauron", - "Pass" : "TheEye" + "Pass" : "TheEye", + "Parm" : { + "qop" : "auth" + } + } } diff --git a/testenv/Test-auth-digest.py b/testenv/Test-auth-digest.py index 8a73c0d5..6f58daa5 100755 --- a/testenv/Test-auth-digest.py +++ b/testenv/Test-auth-digest.py @@ -9,23 +9,39 @@ from misc.wget_file import WgetFile TEST_NAME = "Digest Authorization" ############# File Definitions ############################################### File1 = "Need a cookie?" +File2 = "Want cookies with milk!" File1_rules = { "Authentication" : { "Type" : "Digest", "User" : "Pacman", - "Pass" : "Omnomnom" + "Pass" : "Omnomnom", + "Parm" : { + "qop" : "auth" + } + } +} + +File2_rules = { + "Authentication" : { + "Type" : "Digest", + "User" : "Pacman", + "Pass" : "Omnomnom", + "Parm" : { + "qop" : None + } } } A_File = WgetFile ("File1", File1, rules=File1_rules) +B_File = WgetFile ("File2", File2, rules=File2_rules) WGET_OPTIONS = "--user=Pacman --password=Omnomnom" -WGET_URLS = [["File1"]] +WGET_URLS = [["File1", "File2"]] -Files = [[A_File]] +Files = [[A_File, B_File]] ExpectedReturnCode = 0 -ExpectedDownloadedFiles = [A_File] +ExpectedDownloadedFiles = [A_File, B_File] ################ Pre and Post Test Hooks ##################################### pre_test = { diff --git a/testenv/conf/authentication.py b/testenv/conf/authentication.py index 9414a812..ca5149c7 100644 --- a/testenv/conf/authentication.py +++ b/testenv/conf/authentication.py @@ -20,3 +20,4 @@ class Authentication: self.auth_type = auth_obj['Type'] self.auth_user = auth_obj['User'] self.auth_pass = auth_obj['Pass'] + self.auth_parm = auth_obj.get('Parm', None) diff --git a/testenv/server/http/http_server.py b/testenv/server/http/http_server.py index 85769c43..78aa605e 100644 --- a/testenv/server/http/http_server.py +++ b/testenv/server/http/http_server.py @@ -231,11 +231,11 @@ class _Handler(BaseHTTPRequestHandler): This method calls self.send_header() directly instead of using the add_header() method because sending multiple WWW-Authenticate headers actually makes sense and we do use that feature in some tests. """ - def send_challenge(self, auth_type): + def send_challenge(self, auth_type, auth_parm): auth_type = auth_type.lower() if auth_type == "both": - self.send_challenge("basic") - self.send_challenge("digest") + self.send_challenge("basic", auth_parm) + self.send_challenge("digest", auth_parm) return if auth_type == "basic": challenge_str = 'BasIc realm="Wget-Test"' @@ -246,7 +246,11 @@ class _Handler(BaseHTTPRequestHandler): challenge_str = 'DIgest realm="Test", nonce="%s", opaque="%s"' % ( self.nonce, self.opaque) - challenge_str += ', qop="auth"' + try: + if auth_parm['qop']: + challenge_str += ', qop="%s"' % auth_parm['qop'] + except KeyError: + pass if auth_type == "both_inline": # 'BasIc' to provoke a Wget failure with turkish locales challenge_str = 'BasIc realm="Wget-Test", ' + challenge_str @@ -324,7 +328,7 @@ class _Handler(BaseHTTPRequestHandler): self.handle_auth(auth_rule) except AuthError as se: self.send_response(401, "Authorization Required") - self.send_challenge(auth_rule.auth_type) + self.send_challenge(auth_rule.auth_type, auth_rule.auth_parm) self.finish_headers() raise se