File tree Expand file tree Collapse file tree 5 files changed +17
-0
lines changed
%namespace/%name/%version/%sub/services/%service/transports
tests/unit/gapic/%name_%version/%sub
%namespace/%name_%version/%sub/services/%service/transports
tests/unit/gapic/%name_%version/%sub Expand file tree Collapse file tree 5 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -88,13 +88,16 @@ class {{ service.name }}GrpcTransport({{ service.name }}Transport):
88
88
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
89
89
creation failed for any reason.
90
90
"""
91
+ self._ssl_channel_credentials = ssl_channel_credentials
92
+
91
93
if channel:
92
94
# Sanity check: Ensure that channel and credentials are not both
93
95
# provided.
94
96
credentials = False
95
97
96
98
# If a channel was explicitly provided, set it.
97
99
self._grpc_channel = channel
100
+ self._ssl_channel_credentials = None
98
101
elif api_mtls_endpoint:
99
102
warnings.warn("api_mtls_endpoint and client_cert_source are deprecated", DeprecationWarning)
100
103
@@ -122,6 +125,7 @@ class {{ service.name }}GrpcTransport({{ service.name }}Transport):
122
125
scopes=scopes or self.AUTH_SCOPES,
123
126
quota_project_id=quota_project_id,
124
127
)
128
+ self._ssl_channel_credentials = ssl_credentials
125
129
else:
126
130
host = host if ":" in host else host + ":443"
127
131
Original file line number Diff line number Diff line change @@ -708,6 +708,7 @@ def test_{{ service.name|snake_case }}_grpc_transport_channel():
708
708
)
709
709
assert transport.grpc_channel == channel
710
710
assert transport._host == "squid.clam.whelk:443"
711
+ assert transport._ssl_channel_credentials == None
711
712
712
713
713
714
@pytest.mark.parametrize("transport_class", [transports.{{ service.grpc_transport_name }}])
@@ -749,6 +750,7 @@ def test_{{ service.name|snake_case }}_transport_channel_mtls_with_client_cert_s
749
750
quota_project_id=None,
750
751
)
751
752
assert transport.grpc_channel == mock_grpc_channel
753
+ assert transport._ssl_channel_credentials == mock_ssl_cred
752
754
753
755
754
756
@pytest.mark.parametrize("transport_class", [transports.{{ service.grpc_transport_name }},])
Original file line number Diff line number Diff line change @@ -96,13 +96,16 @@ class {{ service.name }}GrpcTransport({{ service.name }}Transport):
96
96
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
97
97
and ``credentials_file`` are passed.
98
98
"""
99
+ self._ssl_channel_credentials = ssl_channel_credentials
100
+
99
101
if channel:
100
102
# Sanity check: Ensure that channel and credentials are not both
101
103
# provided.
102
104
credentials = False
103
105
104
106
# If a channel was explicitly provided, set it.
105
107
self._grpc_channel = channel
108
+ self._ssl_channel_credentials = None
106
109
elif api_mtls_endpoint:
107
110
warnings.warn("api_mtls_endpoint and client_cert_source are deprecated", DeprecationWarning)
108
111
@@ -130,6 +133,7 @@ class {{ service.name }}GrpcTransport({{ service.name }}Transport):
130
133
scopes=scopes or self.AUTH_SCOPES,
131
134
quota_project_id=quota_project_id,
132
135
)
136
+ self._ssl_channel_credentials = ssl_credentials
133
137
else:
134
138
host = host if ":" in host else host + ":443"
135
139
Original file line number Diff line number Diff line change @@ -140,13 +140,16 @@ class {{ service.grpc_asyncio_transport_name }}({{ service.name }}Transport):
140
140
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
141
141
and ``credentials_file`` are passed.
142
142
"""
143
+ self._ssl_channel_credentials = ssl_channel_credentials
144
+
143
145
if channel:
144
146
# Sanity check: Ensure that channel and credentials are not both
145
147
# provided.
146
148
credentials = False
147
149
148
150
# If a channel was explicitly provided, set it.
149
151
self._grpc_channel = channel
152
+ self._ssl_channel_credentials = None
150
153
elif api_mtls_endpoint:
151
154
warnings.warn("api_mtls_endpoint and client_cert_source are deprecated", DeprecationWarning)
152
155
@@ -174,6 +177,7 @@ class {{ service.grpc_asyncio_transport_name }}({{ service.name }}Transport):
174
177
scopes=scopes or self.AUTH_SCOPES,
175
178
quota_project_id=quota_project_id,
176
179
)
180
+ self._ssl_channel_credentials = ssl_credentials
177
181
else:
178
182
host = host if ":" in host else host + ":443"
179
183
Original file line number Diff line number Diff line change @@ -1184,6 +1184,7 @@ def test_{{ service.name|snake_case }}_grpc_transport_channel():
1184
1184
)
1185
1185
assert transport.grpc_channel == channel
1186
1186
assert transport._host == "squid.clam.whelk:443"
1187
+ assert transport._ssl_channel_credentials == None
1187
1188
1188
1189
1189
1190
def test_{{ service.name|snake_case }}_grpc_asyncio_transport_channel():
@@ -1196,6 +1197,7 @@ def test_{{ service.name|snake_case }}_grpc_asyncio_transport_channel():
1196
1197
)
1197
1198
assert transport.grpc_channel == channel
1198
1199
assert transport._host == "squid.clam.whelk:443"
1200
+ assert transport._ssl_channel_credentials == None
1199
1201
1200
1202
1201
1203
@pytest.mark.parametrize("transport_class", [transports.{{ service.grpc_transport_name }}, transports.{{ service.grpc_asyncio_transport_name }}])
@@ -1237,6 +1239,7 @@ def test_{{ service.name|snake_case }}_transport_channel_mtls_with_client_cert_s
1237
1239
quota_project_id=None,
1238
1240
)
1239
1241
assert transport.grpc_channel == mock_grpc_channel
1242
+ assert transport._ssl_channel_credentials == mock_ssl_cred
1240
1243
1241
1244
1242
1245
@pytest.mark.parametrize("transport_class", [transports.{{ service.grpc_transport_name }}, transports.{{ service.grpc_asyncio_transport_name }}])
You can’t perform that action at this time.
0 commit comments