Show More
@@ -39,10 +39,19 b' def test_applies_largefiles_patch_only_i' | |||
|
39 | 39 | |
|
40 | 40 | |
|
41 | 41 | @pytest.mark.parametrize('given, expected', [ |
|
42 | ('bad', 'bad'), | |
|
43 | ('query&foo=bar', 'query&foo=bar'), | |
|
44 | ('equery&auth_token=bar', 'equery&auth_token=*****'), | |
|
45 | ('a;b;c;query&foo=bar&auth_token=secret', | |
|
46 | 'a&b&c&query&foo=bar&auth_token=*****'), | |
|
47 | ('', ''), | |
|
48 | (None, None), | |
|
42 | 49 | ('foo=bar', 'foo=bar'), |
|
43 | 50 | ('auth_token=secret', 'auth_token=*****'), |
|
44 |
('auth_token=secret&api_key=secret2', |
|
|
45 | ('auth_token=secret&api_key=secret2¶m=value', 'auth_token=*****&api_key=*****¶m=value'), | |
|
51 | ('auth_token=secret&api_key=secret2', | |
|
52 | 'auth_token=*****&api_key=*****'), | |
|
53 | ('auth_token=secret&api_key=secret2¶m=value', | |
|
54 | 'auth_token=*****&api_key=*****¶m=value'), | |
|
46 | 55 | ]) |
|
47 | 56 | def test_obfuscate_qs(given, expected): |
|
48 | 57 | assert expected == obfuscate_qs(given) |
@@ -72,10 +72,14 b' class RepoFactory(object):' | |||
|
72 | 72 | |
|
73 | 73 | |
|
74 | 74 | def obfuscate_qs(query_string): |
|
75 | if query_string is None: | |
|
76 | return None | |
|
77 | ||
|
75 | 78 | parsed = [] |
|
76 | for k, v in urlparse.parse_qsl(query_string): | |
|
79 | for k, v in urlparse.parse_qsl(query_string, keep_blank_values=True): | |
|
77 | 80 | if k in ['auth_token', 'api_key']: |
|
78 | 81 | v = "*****" |
|
79 | 82 | parsed.append((k, v)) |
|
80 | 83 | |
|
81 |
return '&'.join('{} |
|
|
84 | return '&'.join('{}{}'.format( | |
|
85 | k, '={}'.format(v) if v else '') for k, v in parsed) |
General Comments 0
You need to be logged in to leave comments.
Login now