@@ -52,7 +52,7 @@ def test_get_credentials_parses_correctly(
52
52
(username is None and password is None )
53
53
or
54
54
# Credentials were found and "cached" appropriately
55
- (url , (username , password )) in auth .passwords
55
+ (url , (username , password )) in auth .passwords [ "http://example.com" ]
56
56
)
57
57
58
58
@@ -72,7 +72,7 @@ def test_handle_prompt_for_password_successful() -> None:
72
72
auth ._prompt_for_password .assert_called_with ("example.com" )
73
73
expected = ("http://example.com" , ("user" , "password" ))
74
74
assert len (auth .passwords ) == 1
75
- assert auth .passwords [0 ] == expected
75
+ assert auth .passwords ["http://example.com" ][ 0 ] == expected
76
76
77
77
78
78
def test_handle_prompt_for_password_unsuccessful () -> None :
@@ -94,7 +94,7 @@ def test_handle_prompt_for_password_unsuccessful() -> None:
94
94
95
95
def test_get_credentials_not_to_uses_cached_credentials () -> None :
96
96
auth = MultiDomainBasicAuth ()
97
- auth .passwords . append (( "http://example.com" , ("user" , "pass" ) ))
97
+ auth ._add_auth_info_to_dict ( "http://example.com" , ("user" , "pass" ))
98
98
99
99
got = auth .
_get_url_and_credentials (
"http://foo:[email protected] /path" )
100
100
expected = ("http://example.com/path" , "foo" , "bar" )
@@ -103,7 +103,7 @@ def test_get_credentials_not_to_uses_cached_credentials() -> None:
103
103
104
104
def test_get_credentials_not_to_use_cached_credentials_only_username () -> None :
105
105
auth = MultiDomainBasicAuth ()
106
- auth .passwords . append (( "https://example.com" , ("user" , "pass" ) ))
106
+ auth ._add_auth_info_to_dict ( "https://example.com" , ("user" , "pass" ))
107
107
108
108
got = auth .
_get_url_and_credentials (
"https://[email protected] /path" )
109
109
expected = ("https://example.com/path" , "foo" , "" )
@@ -112,8 +112,8 @@ def test_get_credentials_not_to_use_cached_credentials_only_username() -> None:
112
112
113
113
def test_multi_domain_credentials_match () -> None :
114
114
auth = MultiDomainBasicAuth ()
115
- auth .passwords . append (( "http://example.com" , ("user" , "pass" ) ))
116
- auth .passwords . append (( "http://example.com/path" , ("user" , "pass2" ) ))
115
+ auth ._add_auth_info_to_dict ( "http://example.com" , ("user" , "pass" ))
116
+ auth ._add_auth_info_to_dict ( "http://example.com/path" , ("user" , "pass2" ))
117
117
118
118
got = auth .
_get_url_and_credentials (
"http://[email protected] /path" )
119
119
expected = ("http://example.com/path" , "user" , "pass2" )
@@ -122,9 +122,9 @@ def test_multi_domain_credentials_match() -> None:
122
122
123
123
def test_multi_domain_credentials_longest_match () -> None :
124
124
auth = MultiDomainBasicAuth ()
125
- auth .passwords . append (( "http://example.com" , ("user" , "pass" ) ))
126
- auth .passwords . append (( "http://example.com/path" , ("user" , "pass2" ) ))
127
- auth .passwords . append (( "http://example.com/path/subpath" , ("user" , "pass3" ) ))
125
+ auth ._add_auth_info_to_dict ( "http://example.com" , ("user" , "pass" ))
126
+ auth ._add_auth_info_to_dict ( "http://example.com/path" , ("user" , "pass2" ))
127
+ auth ._add_auth_info_to_dict ( "http://example.com/path/subpath" , ("user" , "pass3" ))
128
128
129
129
got = auth .
_get_url_and_credentials (
"http://[email protected] /path" )
130
130
expected = ("http://example.com/path" , "user" , "pass2" )
@@ -133,7 +133,7 @@ def test_multi_domain_credentials_longest_match() -> None:
133
133
134
134
def test_multi_domain_credentials_partial_match_only () -> None :
135
135
auth = MultiDomainBasicAuth ()
136
- auth .passwords . append (( "http://example.com/path1" , ("user" , "pass" ) ))
136
+ auth ._add_auth_info_to_dict ( "http://example.com/path1" , ("user" , "pass" ))
137
137
138
138
got = auth ._get_url_and_credentials ("http://example.com/path2" )
139
139
expected = ("http://example.com/path2" , None , None )
@@ -142,7 +142,7 @@ def test_multi_domain_credentials_partial_match_only() -> None:
142
142
143
143
def test_get_credentials_uses_cached_credentials () -> None :
144
144
auth = MultiDomainBasicAuth ()
145
- auth .passwords . append (( "https://example.com" , ("user" , "pass" ) ))
145
+ auth ._add_auth_info_to_dict ( "https://example.com" , ("user" , "pass" ))
146
146
147
147
got = auth ._get_url_and_credentials ("https://example.com/path" )
148
148
expected = ("https://example.com/path" , "user" , "pass" )
@@ -151,7 +151,7 @@ def test_get_credentials_uses_cached_credentials() -> None:
151
151
152
152
def test_get_credentials_not_uses_cached_credentials_different_scheme_http () -> None :
153
153
auth = MultiDomainBasicAuth ()
154
- auth .passwords . append (( "http://example.com" , ("user" , "pass" ) ))
154
+ auth ._add_auth_info_to_dict ( "http://example.com" , ("user" , "pass" ))
155
155
156
156
got = auth ._get_url_and_credentials ("https://example.com/path" )
157
157
expected = ("https://example.com/path" , None , None )
@@ -160,7 +160,7 @@ def test_get_credentials_not_uses_cached_credentials_different_scheme_http() ->
160
160
161
161
def test_get_credentials_not_uses_cached_credentials_different_scheme_https () -> None :
162
162
auth = MultiDomainBasicAuth ()
163
- auth .passwords . append (( "https://example.com" , ("user" , "pass" ) ))
163
+ auth ._add_auth_info_to_dict ( "https://example.com" , ("user" , "pass" ))
164
164
165
165
got = auth ._get_url_and_credentials ("http://example.com/path" )
166
166
expected = ("http://example.com/path" , None , None )
@@ -169,7 +169,7 @@ def test_get_credentials_not_uses_cached_credentials_different_scheme_https() ->
169
169
170
170
def test_get_credentials_uses_cached_credentials_only_username () -> None :
171
171
auth = MultiDomainBasicAuth ()
172
- auth .passwords . append (( "http://example.com" , ("user" , "pass" ) ))
172
+ auth ._add_auth_info_to_dict ( "http://example.com" , ("user" , "pass" ))
173
173
174
174
got = auth .
_get_url_and_credentials (
"http://[email protected] /path" )
175
175
expected = ("http://example.com/path" , "user" , "pass" )
@@ -178,7 +178,7 @@ def test_get_credentials_uses_cached_credentials_only_username() -> None:
178
178
179
179
def test_get_credentials_uses_cached_credentials_wrong_username () -> None :
180
180
auth = MultiDomainBasicAuth ()
181
- auth .passwords . append (( "http://example.com" , ("user" , "pass" ) ))
181
+ auth ._add_auth_info_to_dict ( "http://example.com" , ("user" , "pass" ))
182
182
183
183
got = auth .
_get_url_and_credentials (
"http://[email protected] /path" )
184
184
expected = ("http://example.com/path" , "user2" , "" )
@@ -187,8 +187,8 @@ def test_get_credentials_uses_cached_credentials_wrong_username() -> None:
187
187
188
188
def test_get_credentials_added_multiple_times () -> None :
189
189
auth = MultiDomainBasicAuth ()
190
- auth .passwords . append (( "http://example.com" , ("user" , "pass" ) ))
191
- auth .passwords . append (( "http://example.com" , ("user" , "pass2" ) ))
190
+ auth ._add_auth_info_to_dict ( "http://example.com" , ("user" , "pass" ))
191
+ auth ._add_auth_info_to_dict ( "http://example.com" , ("user" , "pass2" ))
192
192
193
193
got = auth .
_get_url_and_credentials (
"http://[email protected] /path" )
194
194
expected = ("http://example.com/path" , "user" , "pass" )
0 commit comments