@@ -37,7 +37,7 @@ def create_retriever(self, url) -> HTTPSPublicKeyRetriever:
3737 return HTTPSPublicKeyRetriever (url )
3838
3939 def setUp (self ) -> None :
40- self ._private_key_pem = self .get_new_private_key_in_pem_format ()
40+ self ._private_key_pem = self .get_new_private_key_in_pem_format () # type: ignore[attr-defined]
4141 self ._public_key_pem = utils .get_public_key_pem_for_private_key_pem (
4242 self ._private_key_pem )
4343 self .base_url = 'https://example.com'
@@ -47,15 +47,15 @@ def test_https_public_key_retriever_does_not_support_http_url(
4747 """ tests that HTTPSPublicKeyRetriever does not support http://
4848 base urls.
4949 """
50- with self .assertRaises (ValueError ):
50+ with self .assertRaises (ValueError ): # type: ignore[attr-defined]
5151 self .create_retriever ('http://example.com' )
5252
5353 def test_https_public_key_retriever_does_not_support_none_url (
5454 self ) -> None :
5555 """ tests that HTTPSPublicKeyRetriever does not support None
5656 base urls.
5757 """
58- with self .assertRaises (ValueError ):
58+ with self .assertRaises (ValueError ): # type: ignore[attr-defined]
5959 self .create_retriever (None )
6060
6161 def test_https_public_key_retriever_session_uses_env_proxy (self ) -> None :
@@ -69,9 +69,9 @@ def test_https_public_key_retriever_session_uses_env_proxy(self) -> None:
6969 retriever = self .create_retriever (self .base_url )
7070 key_retrievers = [retriever ]
7171 if isinstance (retriever , HTTPSMultiRepositoryPublicKeyRetriever ):
72- key_retrievers = retriever ._retrievers
72+ key_retrievers = retriever ._retrievers # type: ignore[assignment]
7373 for key_retriever in key_retrievers :
74- self .assertEqual (key_retriever ._proxies , expected_proxies )
74+ self .assertEqual (key_retriever ._proxies , expected_proxies ) # type: ignore[attr-defined]
7575
7676 def test_https_public_key_retriever_supports_https_url (self ) -> None :
7777 """ tests that HTTPSPublicKeyRetriever supports https://
@@ -83,9 +83,9 @@ def test_https_public_key_retriever_supports_https_url(self) -> None:
8383 def test_retrieve (self , mock_get_method : Mock ) -> None :
8484 """ tests that the retrieve method works expected. """
8585 _setup_mock_response_for_retriever (
86- mock_get_method , self ._public_key_pem )
86+ mock_get_method , self ._public_key_pem ) # type: ignore[arg-type]
8787 retriever = self .create_retriever (self .base_url )
88- self .assertEqual (
88+ self .assertEqual ( # type: ignore[attr-defined]
8989 retriever .retrieve ('example/eg' ),
9090 self ._public_key_pem )
9191
@@ -99,7 +99,7 @@ def test_retrieve_with_proxy(self, mock_get_method: Mock) -> None:
9999 expected_proxies , proxy_dict = get_expected_and_os_proxies_dict (
100100 proxy_location )
101101 _setup_mock_response_for_retriever (
102- mock_get_method , self ._public_key_pem )
102+ mock_get_method , self ._public_key_pem ) # type: ignore[arg-type]
103103 with mock .patch .dict (os .environ , proxy_dict , clear = True ):
104104 retriever = self .create_retriever (self .base_url )
105105 retriever .retrieve (key_id )
@@ -122,7 +122,7 @@ def test_retrieve_with_proxy_explicitly_set(
122122 expected_proxies , _ = get_expected_and_os_proxies_dict (
123123 explicit_proxy_location )
124124 _setup_mock_response_for_retriever (
125- mock_get_method , self ._public_key_pem )
125+ mock_get_method , self ._public_key_pem ) # type: ignore[arg-type]
126126 with mock .patch .dict (os .environ , proxy_dict , clear = True ):
127127 retriever = self .create_retriever (self .base_url )
128128 retriever .retrieve (key_id , proxies = expected_proxies )
@@ -140,9 +140,9 @@ def test_retrieve_with_charset_in_content_type_h(
140140 """
141141 headers = {'content-type' : 'application/x-pem-file;charset=UTF-8' }
142142 _setup_mock_response_for_retriever (
143- mock_get_method , self ._public_key_pem , headers )
143+ mock_get_method , self ._public_key_pem , headers ) # type: ignore[arg-type]
144144 retriever = self .create_retriever (self .base_url )
145- self .assertEqual (
145+ self .assertEqual ( # type: ignore[attr-defined]
146146 retriever .retrieve ('example/eg' ),
147147 self ._public_key_pem )
148148
@@ -154,9 +154,9 @@ def test_retrieve_fails_with_different_content_type(
154154 """
155155 headers = {'content-type' : 'different/not-supported' }
156156 _setup_mock_response_for_retriever (
157- mock_get_method , self ._public_key_pem , headers )
157+ mock_get_method , self ._public_key_pem , headers ) # type: ignore[arg-type]
158158 retriever = self .create_retriever (self .base_url )
159- with self .assertRaises (ValueError ):
159+ with self .assertRaises (ValueError ): # type: ignore[attr-defined]
160160 retriever .retrieve ('example/eg' )
161161
162162 @mock .patch .object (requests .Session , 'get' ,
@@ -169,9 +169,9 @@ def test_retrieve_fails_with_forbidden_error(
169169 403 forbidden error.
170170 """
171171 _setup_mock_response_for_retriever (
172- mock_get_method , self ._public_key_pem )
172+ mock_get_method , self ._public_key_pem ) # type: ignore[arg-type]
173173 retriever = self .create_retriever (self .base_url )
174- with self .assertRaises (ValueError ):
174+ with self .assertRaises (ValueError ): # type: ignore[attr-defined]
175175 retriever .retrieve ('example/eg' )
176176
177177
@@ -225,13 +225,13 @@ class BaseHTTPSMultiRepositoryPublicKeyRetrieverTest(
225225 BaseHTTPSPublicKeyRetrieverTest ):
226226 """ tests for the HTTPSMultiRepositoryPublicKeyRetriever class. """
227227
228- def create_retriever (
228+ def create_retriever ( # type: ignore[override]
229229 self , url : str ) -> HTTPSMultiRepositoryPublicKeyRetriever :
230230 """ returns a public key retriever created using the given url. """
231231 return HTTPSMultiRepositoryPublicKeyRetriever ([url ])
232232
233233 def setUp (self ) -> None :
234- self ._private_key_pem = self .get_new_private_key_in_pem_format ()
234+ self ._private_key_pem = self .get_new_private_key_in_pem_format () # type: ignore[attr-defined]
235235 self ._public_key_pem = utils .get_public_key_pem_for_private_key_pem (
236236 self ._private_key_pem )
237237 self .keystore_urls = ['https://example.com' , 'https://example.ly' ]
@@ -242,16 +242,16 @@ def test_https_multi_public_key_retriever_does_not_support_strings(
242242 """ tests that HTTPSMultiRepositoryPublicKeyRetriever does not
243243 support a string key repository url.
244244 """
245- with self .assertRaises (TypeError ):
245+ with self .assertRaises (TypeError ): # type: ignore[attr-defined]
246246 HTTPSMultiRepositoryPublicKeyRetriever ('https://example.com' )
247247
248248 @mock .patch .object (requests .Session , 'get' )
249249 def test_retrieve (self , mock_get_method : Mock ) -> None :
250250 """ tests that the retrieve method works expected. """
251251 _setup_mock_response_for_retriever (
252- mock_get_method , self ._public_key_pem )
252+ mock_get_method , self ._public_key_pem ) # type: ignore[arg-type]
253253 retriever = HTTPSMultiRepositoryPublicKeyRetriever (self .keystore_urls )
254- self .assertEqual (
254+ self .assertEqual ( # type: ignore[attr-defined]
255255 retriever .retrieve ('example/eg' ),
256256 self ._public_key_pem )
257257
@@ -262,13 +262,13 @@ def test_retrieve_with_500_error(self, mock_get_method: Mock) -> None:
262262 """
263263 retriever = HTTPSMultiRepositoryPublicKeyRetriever (self .keystore_urls )
264264 _setup_mock_response_for_retriever (
265- mock_get_method , self ._public_key_pem )
265+ mock_get_method , self ._public_key_pem ) # type: ignore[arg-type]
266266 valid_response = mock_get_method .return_value
267267 del mock_get_method .return_value
268268 server_exception = requests .exceptions .HTTPError (
269269 response = mock .Mock (status_code = 500 ))
270270 mock_get_method .side_effect = [server_exception , valid_response ]
271- self .assertEqual (
271+ self .assertEqual ( # type: ignore[attr-defined]
272272 retriever .retrieve ('example/eg' ),
273273 self ._public_key_pem )
274274
@@ -280,13 +280,13 @@ def test_retrieve_with_connection_error(
280280 """
281281 retriever = HTTPSMultiRepositoryPublicKeyRetriever (self .keystore_urls )
282282 _setup_mock_response_for_retriever (
283- mock_get_method , self ._public_key_pem )
283+ mock_get_method , self ._public_key_pem ) # type: ignore[arg-type]
284284 valid_response = mock_get_method .return_value
285285 del mock_get_method .return_value
286286 connection_exception = requests .exceptions .ConnectionError (
287287 response = mock .Mock (status_code = None ))
288288 mock_get_method .side_effect = [connection_exception , valid_response ]
289- self .assertEqual (
289+ self .assertEqual ( # type: ignore[attr-defined]
290290 retriever .retrieve ('example/eg' ),
291291 self ._public_key_pem )
292292
0 commit comments