101
103
# Add some attributes common to all scenarios
102
104
for scenario_id, scenario_dict in scenarios:
103
scenario_dict.update(_username_prompt_prefix='',
105
scenario_dict.update(_auth_header='Authorization',
106
_username_prompt_prefix='',
104
107
_password_prompt_prefix='')
108
111
def vary_by_http_proxy_auth_scheme():
110
('basic', dict(_auth_server=http_utils.ProxyBasicAuthServer)),
111
('digest', dict(_auth_server=http_utils.ProxyDigestAuthServer)),
113
('proxy-basic', dict(_auth_server=http_utils.ProxyBasicAuthServer)),
114
('proxy-digest', dict(_auth_server=http_utils.ProxyDigestAuthServer)),
115
('proxy-basicdigest',
113
116
dict(_auth_server=http_utils.ProxyBasicAndDigestAuthServer)),
115
118
# Add some attributes common to all scenarios
116
119
for scenario_id, scenario_dict in scenarios:
117
scenario_dict.update(_username_prompt_prefix='Proxy ',
120
scenario_dict.update(_auth_header='Proxy-Authorization',
121
_username_prompt_prefix='Proxy ',
118
122
_password_prompt_prefix='Proxy ')
1728
1732
# Only one 'Authentication Required' error should occur
1729
1733
self.assertEqual(1, self.server.auth_required_errors)
1735
def test_no_credential_leaks_in_log(self):
1736
self.overrideAttr(debug, 'debug_flags', set(['http']))
1738
password = 'very-sensitive-password'
1739
self.server.add_user(user, password)
1740
t = self.get_user_transport(user, password)
1741
# Capture the debug calls to mutter
1744
lines = args[0] % args[1:]
1745
# Some calls output multiple lines, just split them now since we
1746
# care about a single one later.
1747
self.mutters.extend(lines.splitlines())
1748
self.overrideAttr(trace, 'mutter', mutter)
1749
# Issue a request to the server to connect
1750
self.assertEqual(True, t.has('a'))
1751
# Only one 'Authentication Required' error should occur
1752
self.assertEqual(1, self.server.auth_required_errors)
1753
# Since the authentification succeeded, there should be a corresponding
1755
sent_auth_headers = [line for line in self.mutters
1756
if line.startswith('> %s' % (self._auth_header,))]
1757
self.assertLength(1, sent_auth_headers)
1758
self.assertStartsWith(sent_auth_headers[0],
1759
'> %s: <masked>' % (self._auth_header,))
1732
1762
class TestProxyAuth(TestAuth):
1733
1763
"""Test proxy authentication schemes.