diff --git a/google/cloud/gaming_v1/services/game_server_clusters_service/client.py b/google/cloud/gaming_v1/services/game_server_clusters_service/client.py index e6cd858c..f135d4d6 100644 --- a/google/cloud/gaming_v1/services/game_server_clusters_service/client.py +++ b/google/cloud/gaming_v1/services/game_server_clusters_service/client.py @@ -356,6 +356,10 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, + always_use_jwt_access=( + Transport == type(self).get_transport_class("grpc") + or Transport == type(self).get_transport_class("grpc_asyncio") + ), ) def list_game_server_clusters( diff --git a/google/cloud/gaming_v1/services/game_server_configs_service/client.py b/google/cloud/gaming_v1/services/game_server_configs_service/client.py index 85adf339..e72ec4ae 100644 --- a/google/cloud/gaming_v1/services/game_server_configs_service/client.py +++ b/google/cloud/gaming_v1/services/game_server_configs_service/client.py @@ -355,6 +355,10 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, + always_use_jwt_access=( + Transport == type(self).get_transport_class("grpc") + or Transport == type(self).get_transport_class("grpc_asyncio") + ), ) def list_game_server_configs( diff --git a/google/cloud/gaming_v1/services/game_server_deployments_service/client.py b/google/cloud/gaming_v1/services/game_server_deployments_service/client.py index b48b34c5..80788b3f 100644 --- a/google/cloud/gaming_v1/services/game_server_deployments_service/client.py +++ b/google/cloud/gaming_v1/services/game_server_deployments_service/client.py @@ -378,6 +378,10 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, + always_use_jwt_access=( + Transport == type(self).get_transport_class("grpc") + or Transport == type(self).get_transport_class("grpc_asyncio") + ), ) def list_game_server_deployments( diff --git a/google/cloud/gaming_v1/services/realms_service/client.py b/google/cloud/gaming_v1/services/realms_service/client.py index 84aecc08..dc3c333b 100644 --- a/google/cloud/gaming_v1/services/realms_service/client.py +++ b/google/cloud/gaming_v1/services/realms_service/client.py @@ -350,6 +350,10 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, + always_use_jwt_access=( + Transport == type(self).get_transport_class("grpc") + or Transport == type(self).get_transport_class("grpc_asyncio") + ), ) def list_realms( diff --git a/google/cloud/gaming_v1beta/services/game_server_clusters_service/client.py b/google/cloud/gaming_v1beta/services/game_server_clusters_service/client.py index 4ddcc9f4..1ada559a 100644 --- a/google/cloud/gaming_v1beta/services/game_server_clusters_service/client.py +++ b/google/cloud/gaming_v1beta/services/game_server_clusters_service/client.py @@ -356,6 +356,10 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, + always_use_jwt_access=( + Transport == type(self).get_transport_class("grpc") + or Transport == type(self).get_transport_class("grpc_asyncio") + ), ) def list_game_server_clusters( diff --git a/google/cloud/gaming_v1beta/services/game_server_configs_service/client.py b/google/cloud/gaming_v1beta/services/game_server_configs_service/client.py index 9b49b058..58fa7226 100644 --- a/google/cloud/gaming_v1beta/services/game_server_configs_service/client.py +++ b/google/cloud/gaming_v1beta/services/game_server_configs_service/client.py @@ -355,6 +355,10 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, + always_use_jwt_access=( + Transport == type(self).get_transport_class("grpc") + or Transport == type(self).get_transport_class("grpc_asyncio") + ), ) def list_game_server_configs( diff --git a/google/cloud/gaming_v1beta/services/game_server_deployments_service/client.py b/google/cloud/gaming_v1beta/services/game_server_deployments_service/client.py index 940185a0..34ccce0c 100644 --- a/google/cloud/gaming_v1beta/services/game_server_deployments_service/client.py +++ b/google/cloud/gaming_v1beta/services/game_server_deployments_service/client.py @@ -378,6 +378,10 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, + always_use_jwt_access=( + Transport == type(self).get_transport_class("grpc") + or Transport == type(self).get_transport_class("grpc_asyncio") + ), ) def list_game_server_deployments( diff --git a/google/cloud/gaming_v1beta/services/realms_service/client.py b/google/cloud/gaming_v1beta/services/realms_service/client.py index 547ecc10..01f499c1 100644 --- a/google/cloud/gaming_v1beta/services/realms_service/client.py +++ b/google/cloud/gaming_v1beta/services/realms_service/client.py @@ -350,6 +350,10 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, + always_use_jwt_access=( + Transport == type(self).get_transport_class("grpc") + or Transport == type(self).get_transport_class("grpc_asyncio") + ), ) def list_realms( diff --git a/tests/unit/gapic/gaming_v1/test_game_server_clusters_service.py b/tests/unit/gapic/gaming_v1/test_game_server_clusters_service.py index ca9acc60..f3c9d15e 100644 --- a/tests/unit/gapic/gaming_v1/test_game_server_clusters_service.py +++ b/tests/unit/gapic/gaming_v1/test_game_server_clusters_service.py @@ -133,21 +133,6 @@ def test_game_server_clusters_service_client_from_service_account_info(client_cl assert client.transport._host == "gameservices.googleapis.com:443" -@pytest.mark.parametrize( - "client_class", - [GameServerClustersServiceClient, GameServerClustersServiceAsyncClient,], -) -def test_game_server_clusters_service_client_service_account_always_use_jwt( - client_class, -): - with mock.patch.object( - service_account.Credentials, "with_always_use_jwt_access", create=True - ) as use_jwt: - creds = service_account.Credentials(None, None, None) - client = client_class(credentials=creds) - use_jwt.assert_not_called() - - @pytest.mark.parametrize( "transport_class,transport_name", [ @@ -155,7 +140,7 @@ def test_game_server_clusters_service_client_service_account_always_use_jwt( (transports.GameServerClustersServiceGrpcAsyncIOTransport, "grpc_asyncio"), ], ) -def test_game_server_clusters_service_client_service_account_always_use_jwt_true( +def test_game_server_clusters_service_client_service_account_always_use_jwt( transport_class, transport_name ): with mock.patch.object( @@ -165,6 +150,13 @@ def test_game_server_clusters_service_client_service_account_always_use_jwt_true transport = transport_class(credentials=creds, always_use_jwt_access=True) use_jwt.assert_called_once_with(True) + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=False) + use_jwt.assert_not_called() + @pytest.mark.parametrize( "client_class", @@ -254,6 +246,7 @@ def test_game_server_clusters_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -270,6 +263,7 @@ def test_game_server_clusters_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -286,6 +280,7 @@ def test_game_server_clusters_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has @@ -314,6 +309,7 @@ def test_game_server_clusters_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -390,6 +386,7 @@ def test_game_server_clusters_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -423,6 +420,7 @@ def test_game_server_clusters_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -444,6 +442,7 @@ def test_game_server_clusters_service_client_mtls_env_auto( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -478,6 +477,7 @@ def test_game_server_clusters_service_client_client_options_scopes( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -512,6 +512,7 @@ def test_game_server_clusters_service_client_client_options_credentials_file( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -531,6 +532,7 @@ def test_game_server_clusters_service_client_client_options_from_dict(): client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) diff --git a/tests/unit/gapic/gaming_v1/test_game_server_configs_service.py b/tests/unit/gapic/gaming_v1/test_game_server_configs_service.py index b2426213..8e8c888f 100644 --- a/tests/unit/gapic/gaming_v1/test_game_server_configs_service.py +++ b/tests/unit/gapic/gaming_v1/test_game_server_configs_service.py @@ -131,21 +131,6 @@ def test_game_server_configs_service_client_from_service_account_info(client_cla assert client.transport._host == "gameservices.googleapis.com:443" -@pytest.mark.parametrize( - "client_class", - [GameServerConfigsServiceClient, GameServerConfigsServiceAsyncClient,], -) -def test_game_server_configs_service_client_service_account_always_use_jwt( - client_class, -): - with mock.patch.object( - service_account.Credentials, "with_always_use_jwt_access", create=True - ) as use_jwt: - creds = service_account.Credentials(None, None, None) - client = client_class(credentials=creds) - use_jwt.assert_not_called() - - @pytest.mark.parametrize( "transport_class,transport_name", [ @@ -153,7 +138,7 @@ def test_game_server_configs_service_client_service_account_always_use_jwt( (transports.GameServerConfigsServiceGrpcAsyncIOTransport, "grpc_asyncio"), ], ) -def test_game_server_configs_service_client_service_account_always_use_jwt_true( +def test_game_server_configs_service_client_service_account_always_use_jwt( transport_class, transport_name ): with mock.patch.object( @@ -163,6 +148,13 @@ def test_game_server_configs_service_client_service_account_always_use_jwt_true( transport = transport_class(credentials=creds, always_use_jwt_access=True) use_jwt.assert_called_once_with(True) + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=False) + use_jwt.assert_not_called() + @pytest.mark.parametrize( "client_class", @@ -252,6 +244,7 @@ def test_game_server_configs_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -268,6 +261,7 @@ def test_game_server_configs_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -284,6 +278,7 @@ def test_game_server_configs_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has @@ -312,6 +307,7 @@ def test_game_server_configs_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -388,6 +384,7 @@ def test_game_server_configs_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -421,6 +418,7 @@ def test_game_server_configs_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -442,6 +440,7 @@ def test_game_server_configs_service_client_mtls_env_auto( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -476,6 +475,7 @@ def test_game_server_configs_service_client_client_options_scopes( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -510,6 +510,7 @@ def test_game_server_configs_service_client_client_options_credentials_file( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -529,6 +530,7 @@ def test_game_server_configs_service_client_client_options_from_dict(): client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) diff --git a/tests/unit/gapic/gaming_v1/test_game_server_deployments_service.py b/tests/unit/gapic/gaming_v1/test_game_server_deployments_service.py index 31322c85..60890c7b 100644 --- a/tests/unit/gapic/gaming_v1/test_game_server_deployments_service.py +++ b/tests/unit/gapic/gaming_v1/test_game_server_deployments_service.py @@ -133,21 +133,6 @@ def test_game_server_deployments_service_client_from_service_account_info(client assert client.transport._host == "gameservices.googleapis.com:443" -@pytest.mark.parametrize( - "client_class", - [GameServerDeploymentsServiceClient, GameServerDeploymentsServiceAsyncClient,], -) -def test_game_server_deployments_service_client_service_account_always_use_jwt( - client_class, -): - with mock.patch.object( - service_account.Credentials, "with_always_use_jwt_access", create=True - ) as use_jwt: - creds = service_account.Credentials(None, None, None) - client = client_class(credentials=creds) - use_jwt.assert_not_called() - - @pytest.mark.parametrize( "transport_class,transport_name", [ @@ -155,7 +140,7 @@ def test_game_server_deployments_service_client_service_account_always_use_jwt( (transports.GameServerDeploymentsServiceGrpcAsyncIOTransport, "grpc_asyncio"), ], ) -def test_game_server_deployments_service_client_service_account_always_use_jwt_true( +def test_game_server_deployments_service_client_service_account_always_use_jwt( transport_class, transport_name ): with mock.patch.object( @@ -165,6 +150,13 @@ def test_game_server_deployments_service_client_service_account_always_use_jwt_t transport = transport_class(credentials=creds, always_use_jwt_access=True) use_jwt.assert_called_once_with(True) + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=False) + use_jwt.assert_not_called() + @pytest.mark.parametrize( "client_class", @@ -254,6 +246,7 @@ def test_game_server_deployments_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -270,6 +263,7 @@ def test_game_server_deployments_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -286,6 +280,7 @@ def test_game_server_deployments_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has @@ -314,6 +309,7 @@ def test_game_server_deployments_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -390,6 +386,7 @@ def test_game_server_deployments_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -423,6 +420,7 @@ def test_game_server_deployments_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -444,6 +442,7 @@ def test_game_server_deployments_service_client_mtls_env_auto( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -478,6 +477,7 @@ def test_game_server_deployments_service_client_client_options_scopes( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -512,6 +512,7 @@ def test_game_server_deployments_service_client_client_options_credentials_file( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -531,6 +532,7 @@ def test_game_server_deployments_service_client_client_options_from_dict(): client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) diff --git a/tests/unit/gapic/gaming_v1/test_realms_service.py b/tests/unit/gapic/gaming_v1/test_realms_service.py index 08e8e1ff..e1235afb 100644 --- a/tests/unit/gapic/gaming_v1/test_realms_service.py +++ b/tests/unit/gapic/gaming_v1/test_realms_service.py @@ -125,18 +125,6 @@ def test_realms_service_client_from_service_account_info(client_class): assert client.transport._host == "gameservices.googleapis.com:443" -@pytest.mark.parametrize( - "client_class", [RealmsServiceClient, RealmsServiceAsyncClient,] -) -def test_realms_service_client_service_account_always_use_jwt(client_class): - with mock.patch.object( - service_account.Credentials, "with_always_use_jwt_access", create=True - ) as use_jwt: - creds = service_account.Credentials(None, None, None) - client = client_class(credentials=creds) - use_jwt.assert_not_called() - - @pytest.mark.parametrize( "transport_class,transport_name", [ @@ -144,7 +132,7 @@ def test_realms_service_client_service_account_always_use_jwt(client_class): (transports.RealmsServiceGrpcAsyncIOTransport, "grpc_asyncio"), ], ) -def test_realms_service_client_service_account_always_use_jwt_true( +def test_realms_service_client_service_account_always_use_jwt( transport_class, transport_name ): with mock.patch.object( @@ -154,6 +142,13 @@ def test_realms_service_client_service_account_always_use_jwt_true( transport = transport_class(credentials=creds, always_use_jwt_access=True) use_jwt.assert_called_once_with(True) + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=False) + use_jwt.assert_not_called() + @pytest.mark.parametrize( "client_class", [RealmsServiceClient, RealmsServiceAsyncClient,] @@ -234,6 +229,7 @@ def test_realms_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -250,6 +246,7 @@ def test_realms_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -266,6 +263,7 @@ def test_realms_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has @@ -294,6 +292,7 @@ def test_realms_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -360,6 +359,7 @@ def test_realms_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -393,6 +393,7 @@ def test_realms_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -414,6 +415,7 @@ def test_realms_service_client_mtls_env_auto( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -444,6 +446,7 @@ def test_realms_service_client_client_options_scopes( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -474,6 +477,7 @@ def test_realms_service_client_client_options_credentials_file( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -493,6 +497,7 @@ def test_realms_service_client_client_options_from_dict(): client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) diff --git a/tests/unit/gapic/gaming_v1beta/test_game_server_clusters_service.py b/tests/unit/gapic/gaming_v1beta/test_game_server_clusters_service.py index cf68f86c..8816ccfe 100644 --- a/tests/unit/gapic/gaming_v1beta/test_game_server_clusters_service.py +++ b/tests/unit/gapic/gaming_v1beta/test_game_server_clusters_service.py @@ -133,21 +133,6 @@ def test_game_server_clusters_service_client_from_service_account_info(client_cl assert client.transport._host == "gameservices.googleapis.com:443" -@pytest.mark.parametrize( - "client_class", - [GameServerClustersServiceClient, GameServerClustersServiceAsyncClient,], -) -def test_game_server_clusters_service_client_service_account_always_use_jwt( - client_class, -): - with mock.patch.object( - service_account.Credentials, "with_always_use_jwt_access", create=True - ) as use_jwt: - creds = service_account.Credentials(None, None, None) - client = client_class(credentials=creds) - use_jwt.assert_not_called() - - @pytest.mark.parametrize( "transport_class,transport_name", [ @@ -155,7 +140,7 @@ def test_game_server_clusters_service_client_service_account_always_use_jwt( (transports.GameServerClustersServiceGrpcAsyncIOTransport, "grpc_asyncio"), ], ) -def test_game_server_clusters_service_client_service_account_always_use_jwt_true( +def test_game_server_clusters_service_client_service_account_always_use_jwt( transport_class, transport_name ): with mock.patch.object( @@ -165,6 +150,13 @@ def test_game_server_clusters_service_client_service_account_always_use_jwt_true transport = transport_class(credentials=creds, always_use_jwt_access=True) use_jwt.assert_called_once_with(True) + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=False) + use_jwt.assert_not_called() + @pytest.mark.parametrize( "client_class", @@ -254,6 +246,7 @@ def test_game_server_clusters_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -270,6 +263,7 @@ def test_game_server_clusters_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -286,6 +280,7 @@ def test_game_server_clusters_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has @@ -314,6 +309,7 @@ def test_game_server_clusters_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -390,6 +386,7 @@ def test_game_server_clusters_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -423,6 +420,7 @@ def test_game_server_clusters_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -444,6 +442,7 @@ def test_game_server_clusters_service_client_mtls_env_auto( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -478,6 +477,7 @@ def test_game_server_clusters_service_client_client_options_scopes( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -512,6 +512,7 @@ def test_game_server_clusters_service_client_client_options_credentials_file( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -531,6 +532,7 @@ def test_game_server_clusters_service_client_client_options_from_dict(): client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) diff --git a/tests/unit/gapic/gaming_v1beta/test_game_server_configs_service.py b/tests/unit/gapic/gaming_v1beta/test_game_server_configs_service.py index a4bb5b59..00000372 100644 --- a/tests/unit/gapic/gaming_v1beta/test_game_server_configs_service.py +++ b/tests/unit/gapic/gaming_v1beta/test_game_server_configs_service.py @@ -131,21 +131,6 @@ def test_game_server_configs_service_client_from_service_account_info(client_cla assert client.transport._host == "gameservices.googleapis.com:443" -@pytest.mark.parametrize( - "client_class", - [GameServerConfigsServiceClient, GameServerConfigsServiceAsyncClient,], -) -def test_game_server_configs_service_client_service_account_always_use_jwt( - client_class, -): - with mock.patch.object( - service_account.Credentials, "with_always_use_jwt_access", create=True - ) as use_jwt: - creds = service_account.Credentials(None, None, None) - client = client_class(credentials=creds) - use_jwt.assert_not_called() - - @pytest.mark.parametrize( "transport_class,transport_name", [ @@ -153,7 +138,7 @@ def test_game_server_configs_service_client_service_account_always_use_jwt( (transports.GameServerConfigsServiceGrpcAsyncIOTransport, "grpc_asyncio"), ], ) -def test_game_server_configs_service_client_service_account_always_use_jwt_true( +def test_game_server_configs_service_client_service_account_always_use_jwt( transport_class, transport_name ): with mock.patch.object( @@ -163,6 +148,13 @@ def test_game_server_configs_service_client_service_account_always_use_jwt_true( transport = transport_class(credentials=creds, always_use_jwt_access=True) use_jwt.assert_called_once_with(True) + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=False) + use_jwt.assert_not_called() + @pytest.mark.parametrize( "client_class", @@ -252,6 +244,7 @@ def test_game_server_configs_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -268,6 +261,7 @@ def test_game_server_configs_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -284,6 +278,7 @@ def test_game_server_configs_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has @@ -312,6 +307,7 @@ def test_game_server_configs_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -388,6 +384,7 @@ def test_game_server_configs_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -421,6 +418,7 @@ def test_game_server_configs_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -442,6 +440,7 @@ def test_game_server_configs_service_client_mtls_env_auto( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -476,6 +475,7 @@ def test_game_server_configs_service_client_client_options_scopes( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -510,6 +510,7 @@ def test_game_server_configs_service_client_client_options_credentials_file( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -529,6 +530,7 @@ def test_game_server_configs_service_client_client_options_from_dict(): client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) diff --git a/tests/unit/gapic/gaming_v1beta/test_game_server_deployments_service.py b/tests/unit/gapic/gaming_v1beta/test_game_server_deployments_service.py index db4216b6..0a49fb8e 100644 --- a/tests/unit/gapic/gaming_v1beta/test_game_server_deployments_service.py +++ b/tests/unit/gapic/gaming_v1beta/test_game_server_deployments_service.py @@ -135,21 +135,6 @@ def test_game_server_deployments_service_client_from_service_account_info(client assert client.transport._host == "gameservices.googleapis.com:443" -@pytest.mark.parametrize( - "client_class", - [GameServerDeploymentsServiceClient, GameServerDeploymentsServiceAsyncClient,], -) -def test_game_server_deployments_service_client_service_account_always_use_jwt( - client_class, -): - with mock.patch.object( - service_account.Credentials, "with_always_use_jwt_access", create=True - ) as use_jwt: - creds = service_account.Credentials(None, None, None) - client = client_class(credentials=creds) - use_jwt.assert_not_called() - - @pytest.mark.parametrize( "transport_class,transport_name", [ @@ -157,7 +142,7 @@ def test_game_server_deployments_service_client_service_account_always_use_jwt( (transports.GameServerDeploymentsServiceGrpcAsyncIOTransport, "grpc_asyncio"), ], ) -def test_game_server_deployments_service_client_service_account_always_use_jwt_true( +def test_game_server_deployments_service_client_service_account_always_use_jwt( transport_class, transport_name ): with mock.patch.object( @@ -167,6 +152,13 @@ def test_game_server_deployments_service_client_service_account_always_use_jwt_t transport = transport_class(credentials=creds, always_use_jwt_access=True) use_jwt.assert_called_once_with(True) + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=False) + use_jwt.assert_not_called() + @pytest.mark.parametrize( "client_class", @@ -256,6 +248,7 @@ def test_game_server_deployments_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -272,6 +265,7 @@ def test_game_server_deployments_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -288,6 +282,7 @@ def test_game_server_deployments_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has @@ -316,6 +311,7 @@ def test_game_server_deployments_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -392,6 +388,7 @@ def test_game_server_deployments_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -425,6 +422,7 @@ def test_game_server_deployments_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -446,6 +444,7 @@ def test_game_server_deployments_service_client_mtls_env_auto( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -480,6 +479,7 @@ def test_game_server_deployments_service_client_client_options_scopes( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -514,6 +514,7 @@ def test_game_server_deployments_service_client_client_options_credentials_file( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -533,6 +534,7 @@ def test_game_server_deployments_service_client_client_options_from_dict(): client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) diff --git a/tests/unit/gapic/gaming_v1beta/test_realms_service.py b/tests/unit/gapic/gaming_v1beta/test_realms_service.py index aac0defd..9891c959 100644 --- a/tests/unit/gapic/gaming_v1beta/test_realms_service.py +++ b/tests/unit/gapic/gaming_v1beta/test_realms_service.py @@ -125,18 +125,6 @@ def test_realms_service_client_from_service_account_info(client_class): assert client.transport._host == "gameservices.googleapis.com:443" -@pytest.mark.parametrize( - "client_class", [RealmsServiceClient, RealmsServiceAsyncClient,] -) -def test_realms_service_client_service_account_always_use_jwt(client_class): - with mock.patch.object( - service_account.Credentials, "with_always_use_jwt_access", create=True - ) as use_jwt: - creds = service_account.Credentials(None, None, None) - client = client_class(credentials=creds) - use_jwt.assert_not_called() - - @pytest.mark.parametrize( "transport_class,transport_name", [ @@ -144,7 +132,7 @@ def test_realms_service_client_service_account_always_use_jwt(client_class): (transports.RealmsServiceGrpcAsyncIOTransport, "grpc_asyncio"), ], ) -def test_realms_service_client_service_account_always_use_jwt_true( +def test_realms_service_client_service_account_always_use_jwt( transport_class, transport_name ): with mock.patch.object( @@ -154,6 +142,13 @@ def test_realms_service_client_service_account_always_use_jwt_true( transport = transport_class(credentials=creds, always_use_jwt_access=True) use_jwt.assert_called_once_with(True) + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=False) + use_jwt.assert_not_called() + @pytest.mark.parametrize( "client_class", [RealmsServiceClient, RealmsServiceAsyncClient,] @@ -234,6 +229,7 @@ def test_realms_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -250,6 +246,7 @@ def test_realms_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is @@ -266,6 +263,7 @@ def test_realms_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has @@ -294,6 +292,7 @@ def test_realms_service_client_client_options( client_cert_source_for_mtls=None, quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -360,6 +359,7 @@ def test_realms_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case ADC client cert is provided. Whether client cert is used depends on @@ -393,6 +393,7 @@ def test_realms_service_client_mtls_env_auto( client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) # Check the case client_cert_source and ADC client cert are not provided. @@ -414,6 +415,7 @@ def test_realms_service_client_mtls_env_auto( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -444,6 +446,7 @@ def test_realms_service_client_client_options_scopes( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -474,6 +477,7 @@ def test_realms_service_client_client_options_credentials_file( client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, ) @@ -493,6 +497,7 @@ def test_realms_service_client_client_options_from_dict(): client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, )