mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Add tests for missing qop in digest auth
* testenv/test-auth-both.py: Add qop parameter for digest auth * testenv/test-auth-digest.py: Same * testenv/conf/authentication.py: Support additional parameters for authentication * testenv/servers/http/http_server.py: Same
This commit is contained in:
parent
c387db6451
commit
e51076e683
@ -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"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 = {
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user