Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 94c0a99

Browse files
committed
Mock SSL credentials for MTLS test cases
1 parent 9bba848 commit 94c0a99

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

tests/system/conftest.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,22 @@ def identity():
127127

128128
@pytest.fixture
129129
def async_identity():
130-
transport = IdentityAsyncClient.get_transport_class('grpc_asyncio')(
131-
channel=aio.insecure_channel('localhost:7469'),
132-
)
133-
return IdentityAsyncClient(transport=transport)
130+
if use_mtls:
131+
with mock.patch("grpc.ssl_channel_credentials", autospec=True) as mock_ssl_cred:
132+
mock_ssl_cred.return_value = ssl_credentials
133+
client = IdentityAsyncClient(
134+
credentials=credentials.AnonymousCredentials(),
135+
client_options=client_options,
136+
)
137+
mock_ssl_cred.assert_called_once_with(
138+
certificate_chain=cert, private_key=key
139+
)
140+
return client
141+
else:
142+
transport = IdentityAsyncClient.get_transport_class('grpc_asyncio')(
143+
channel=aio.insecure_channel('localhost:7469'),
144+
)
145+
return IdentityAsyncClient(transport=transport)
134146

135147

136148
@pytest.fixture

0 commit comments

Comments
 (0)