File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
google/cloud/storage/asyncio Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,10 @@ def __init__(
5555 attempt_direct_path = True ,
5656 ):
5757 if isinstance (credentials , auth_credentials .AnonymousCredentials ):
58+ if client_options is None or client_options .api_endpoint is None :
59+ raise ValueError (
60+ "Either client_options or `client_option.api_endpoint` is None. Please provide api_endpoint when `AnonymousCredentials` is used "
61+ )
5862 self ._grpc_client = self ._create_anonymous_client (
5963 client_options , credentials
6064 )
Original file line number Diff line number Diff line change @@ -184,6 +184,23 @@ def test_grpc_client_with_anon_creds(
184184 transport = kwargs ["transport" ]
185185 assert isinstance (transport ._credentials , AnonymousCredentials )
186186
187+ def test_grpc_client_with_anon_creds_no_client_options (self ):
188+ # Act & Assert
189+ message = "Either client_options or `client_option.api_endpoint` is None. Please provide api_endpoint when `AnonymousCredentials` is used "
190+ with pytest .raises (ValueError , match = message ):
191+ async_grpc_client .AsyncGrpcClient (
192+ credentials = AnonymousCredentials (),
193+ )
194+
195+ def test_grpc_client_with_anon_creds_empty_client_options (self ):
196+ # Act & Assert
197+ message = "Either client_options or `client_option.api_endpoint` is None. Please provide api_endpoint when `AnonymousCredentials` is used "
198+ with pytest .raises (ValueError , match = message ):
199+ async_grpc_client .AsyncGrpcClient (
200+ client_options = client_options .ClientOptions (),
201+ credentials = AnonymousCredentials (),
202+ )
203+
187204 @mock .patch ("google.cloud._storage_v2.StorageAsyncClient" )
188205 def test_user_agent_with_custom_client_info (self , mock_async_storage_client ):
189206 """Test that gcloud-python user agent is appended to existing user agent.
You can’t perform that action at this time.
0 commit comments