22
33import io
44import json
5+ import secrets
56import uuid
67import zipfile
78from http import HTTPStatus
4445# The mock accepts one hard-coded pair of Model Target Web API OAuth2
4546# credentials, which it does not expose.
4647_CLIENT_ID = "client-id"
47- _CLIENT_SECRET = "client-secret" # noqa: S105
48+ _CLIENT_CREDENTIALS = ( "client-id" , "client-secret" )
4849
4950_DATASET_TYPES = [
5051 ModelTargetDatasetType .STANDARD ,
@@ -144,7 +145,7 @@ def test_token_is_a_bearer_token() -> None:
144145 """An access token is given for valid credentials."""
145146 client = ModelTargetService (
146147 client_id = _CLIENT_ID ,
147- client_secret = _CLIENT_SECRET ,
148+ client_secret = _CLIENT_CREDENTIALS [ 1 ] ,
148149 )
149150
150151 assert bool (client .get_access_token ())
@@ -159,7 +160,7 @@ def test_token_is_reused(
159160 transport = _CountingTransport (transport = RequestsTransport ())
160161 client = ModelTargetService (
161162 client_id = _CLIENT_ID ,
162- client_secret = _CLIENT_SECRET ,
163+ client_secret = _CLIENT_CREDENTIALS [ 1 ] ,
163164 transport = transport ,
164165 )
165166
@@ -185,7 +186,7 @@ def test_expired_token_is_replaced(
185186 transport = _CountingTransport (transport = RequestsTransport ())
186187 client = ModelTargetService (
187188 client_id = _CLIENT_ID ,
188- client_secret = _CLIENT_SECRET ,
189+ client_secret = _CLIENT_CREDENTIALS [ 1 ] ,
189190 transport = transport ,
190191 )
191192
@@ -215,7 +216,7 @@ def test_invalid_credentials() -> None:
215216 """An exception is raised when the credentials are not known."""
216217 client = ModelTargetService (
217218 client_id = "not-a-client-id" ,
218- client_secret = "not-a-client-secret" , # noqa: S106
219+ client_secret = secrets . token_hex (),
219220 )
220221
221222 with pytest .raises (
@@ -279,7 +280,7 @@ def test_dataset_error_response(
279280 )
280281 client = ModelTargetService (
281282 client_id = _CLIENT_ID ,
282- client_secret = _CLIENT_SECRET ,
283+ client_secret = _CLIENT_CREDENTIALS [ 1 ] ,
283284 )
284285
285286 with (
@@ -606,7 +607,7 @@ def test_generation_failure(
606607 ):
607608 client = ModelTargetService (
608609 client_id = _CLIENT_ID ,
609- client_secret = _CLIENT_SECRET ,
610+ client_secret = _CLIENT_CREDENTIALS [ 1 ] ,
610611 )
611612 dataset_uuid = client .create_dataset (
612613 name = "dataset" ,
@@ -648,7 +649,7 @@ def test_generation_warning(
648649 ):
649650 client = ModelTargetService (
650651 client_id = _CLIENT_ID ,
651- client_secret = _CLIENT_SECRET ,
652+ client_secret = _CLIENT_CREDENTIALS [ 1 ] ,
652653 )
653654 dataset_uuid = client .create_dataset (
654655 name = "dataset" ,
@@ -687,7 +688,7 @@ def test_timeout(*, model_target_model: ModelTargetModel) -> None:
687688 with MockVWS (processing_time_seconds = 60 ):
688689 client = ModelTargetService (
689690 client_id = _CLIENT_ID ,
690- client_secret = _CLIENT_SECRET ,
691+ client_secret = _CLIENT_CREDENTIALS [ 1 ] ,
691692 )
692693 dataset_uuid = client .create_dataset (
693694 name = "dataset" ,
@@ -812,7 +813,7 @@ def test_custom_base_url(
812813 ):
813814 client = ModelTargetService (
814815 client_id = _CLIENT_ID ,
815- client_secret = _CLIENT_SECRET ,
816+ client_secret = _CLIENT_CREDENTIALS [ 1 ] ,
816817 base_vws_url = base_vws_url ,
817818 )
818819 dataset_uuid = client .create_dataset (
0 commit comments