Skip to content

Commit ae1f471

Browse files
fix: disable universe-domain validation (#13244)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 693215877 Source-Link: googleapis/googleapis@bb6b53e Source-Link: googleapis/googleapis-gen@db8b5a9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1vbml0b3JpbmctZGFzaGJvYXJkcy8uT3dsQm90LnlhbWwiLCJoIjoiZGI4YjVhOTM0ODRhZDQ0MDU1YjJiYWNjNGM3Y2Y4N2U5NzBmZTBlZCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1vbml0b3JpbmctbWV0cmljcy1zY29wZXMvLk93bEJvdC55YW1sIiwiaCI6ImRiOGI1YTkzNDg0YWQ0NDA1NWIyYmFjYzRjN2NmODdlOTcwZmUwZWQifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1vbml0b3JpbmcvLk93bEJvdC55YW1sIiwiaCI6ImRiOGI1YTkzNDg0YWQ0NDA1NWIyYmFjYzRjN2NmODdlOTcwZmUwZWQifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW5ldGFwcC8uT3dsQm90LnlhbWwiLCJoIjoiZGI4YjVhOTM0ODRhZDQ0MDU1YjJiYWNjNGM3Y2Y4N2U5NzBmZTBlZCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW5ldHdvcmstY29ubmVjdGl2aXR5Ly5Pd2xCb3QueWFtbCIsImgiOiJkYjhiNWE5MzQ4NGFkNDQwNTViMmJhY2M0YzdjZjg3ZTk3MGZlMGVkIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW5ldHdvcmstbWFuYWdlbWVudC8uT3dsQm90LnlhbWwiLCJoIjoiZGI4YjVhOTM0ODRhZDQ0MDU1YjJiYWNjNGM3Y2Y4N2U5NzBmZTBlZCJ9 Copy-Tag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ZmUwZWQifQ== --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Victor Chudnovsky <vchudnov@google.com>
1 parent b479ff8 commit ae1f471

File tree

149 files changed

+188
-4690
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+188
-4690
lines changed

packages/google-cloud-monitoring-dashboards/google/cloud/monitoring_dashboard/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.16.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-monitoring-dashboards/google/cloud/monitoring_dashboard_v1/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.16.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-monitoring-dashboards/google/cloud/monitoring_dashboard_v1/services/dashboards_service/client.py

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -483,36 +483,6 @@ def _get_universe_domain(
483483
raise ValueError("Universe Domain cannot be an empty string.")
484484
return universe_domain
485485

486-
@staticmethod
487-
def _compare_universes(
488-
client_universe: str, credentials: ga_credentials.Credentials
489-
) -> bool:
490-
"""Returns True iff the universe domains used by the client and credentials match.
491-
492-
Args:
493-
client_universe (str): The universe domain configured via the client options.
494-
credentials (ga_credentials.Credentials): The credentials being used in the client.
495-
496-
Returns:
497-
bool: True iff client_universe matches the universe in credentials.
498-
499-
Raises:
500-
ValueError: when client_universe does not match the universe in credentials.
501-
"""
502-
503-
default_universe = DashboardsServiceClient._DEFAULT_UNIVERSE
504-
credentials_universe = getattr(credentials, "universe_domain", default_universe)
505-
506-
if client_universe != credentials_universe:
507-
raise ValueError(
508-
"The configured universe domain "
509-
f"({client_universe}) does not match the universe domain "
510-
f"found in the credentials ({credentials_universe}). "
511-
"If you haven't configured the universe domain explicitly, "
512-
f"`{default_universe}` is the default."
513-
)
514-
return True
515-
516486
def _validate_universe_domain(self):
517487
"""Validates client's and credentials' universe domains are consistent.
518488
@@ -522,13 +492,9 @@ def _validate_universe_domain(self):
522492
Raises:
523493
ValueError: If the configured universe domain is not valid.
524494
"""
525-
self._is_universe_domain_valid = (
526-
self._is_universe_domain_valid
527-
or DashboardsServiceClient._compare_universes(
528-
self.universe_domain, self.transport._credentials
529-
)
530-
)
531-
return self._is_universe_domain_valid
495+
496+
# NOTE (b/349488459): universe validation is disabled until further notice.
497+
return True
532498

533499
@property
534500
def api_endpoint(self):

packages/google-cloud-monitoring-dashboards/samples/generated_samples/snippet_metadata_google.monitoring.dashboard.v1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-monitoring-dashboards",
11-
"version": "2.16.0"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

packages/google-cloud-monitoring-dashboards/tests/unit/gapic/monitoring_dashboard_v1/test_dashboards_service.py

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -356,86 +356,6 @@ def test__get_universe_domain():
356356
assert str(excinfo.value) == "Universe Domain cannot be an empty string."
357357

358358

359-
@pytest.mark.parametrize(
360-
"client_class,transport_class,transport_name",
361-
[
362-
(DashboardsServiceClient, transports.DashboardsServiceGrpcTransport, "grpc"),
363-
(DashboardsServiceClient, transports.DashboardsServiceRestTransport, "rest"),
364-
],
365-
)
366-
def test__validate_universe_domain(client_class, transport_class, transport_name):
367-
client = client_class(
368-
transport=transport_class(credentials=ga_credentials.AnonymousCredentials())
369-
)
370-
assert client._validate_universe_domain() == True
371-
372-
# Test the case when universe is already validated.
373-
assert client._validate_universe_domain() == True
374-
375-
if transport_name == "grpc":
376-
# Test the case where credentials are provided by the
377-
# `local_channel_credentials`. The default universes in both match.
378-
channel = grpc.secure_channel(
379-
"http://localhost/", grpc.local_channel_credentials()
380-
)
381-
client = client_class(transport=transport_class(channel=channel))
382-
assert client._validate_universe_domain() == True
383-
384-
# Test the case where credentials do not exist: e.g. a transport is provided
385-
# with no credentials. Validation should still succeed because there is no
386-
# mismatch with non-existent credentials.
387-
channel = grpc.secure_channel(
388-
"http://localhost/", grpc.local_channel_credentials()
389-
)
390-
transport = transport_class(channel=channel)
391-
transport._credentials = None
392-
client = client_class(transport=transport)
393-
assert client._validate_universe_domain() == True
394-
395-
# TODO: This is needed to cater for older versions of google-auth
396-
# Make this test unconditional once the minimum supported version of
397-
# google-auth becomes 2.23.0 or higher.
398-
google_auth_major, google_auth_minor = [
399-
int(part) for part in google.auth.__version__.split(".")[0:2]
400-
]
401-
if google_auth_major > 2 or (google_auth_major == 2 and google_auth_minor >= 23):
402-
credentials = ga_credentials.AnonymousCredentials()
403-
credentials._universe_domain = "foo.com"
404-
# Test the case when there is a universe mismatch from the credentials.
405-
client = client_class(transport=transport_class(credentials=credentials))
406-
with pytest.raises(ValueError) as excinfo:
407-
client._validate_universe_domain()
408-
assert (
409-
str(excinfo.value)
410-
== "The configured universe domain (googleapis.com) does not match the universe domain found in the credentials (foo.com). If you haven't configured the universe domain explicitly, `googleapis.com` is the default."
411-
)
412-
413-
# Test the case when there is a universe mismatch from the client.
414-
#
415-
# TODO: Make this test unconditional once the minimum supported version of
416-
# google-api-core becomes 2.15.0 or higher.
417-
api_core_major, api_core_minor = [
418-
int(part) for part in api_core_version.__version__.split(".")[0:2]
419-
]
420-
if api_core_major > 2 or (api_core_major == 2 and api_core_minor >= 15):
421-
client = client_class(
422-
client_options={"universe_domain": "bar.com"},
423-
transport=transport_class(
424-
credentials=ga_credentials.AnonymousCredentials(),
425-
),
426-
)
427-
with pytest.raises(ValueError) as excinfo:
428-
client._validate_universe_domain()
429-
assert (
430-
str(excinfo.value)
431-
== "The configured universe domain (bar.com) does not match the universe domain found in the credentials (googleapis.com). If you haven't configured the universe domain explicitly, `googleapis.com` is the default."
432-
)
433-
434-
# Test that ValueError is raised if universe_domain is provided via client options and credentials is None
435-
with pytest.raises(ValueError):
436-
client._compare_universes("foo.bar", None)
437-
438-
439359
@pytest.mark.parametrize(
440360
"client_class,transport_name",
441361
[

packages/google-cloud-monitoring-metrics-scopes/google/cloud/monitoring_metrics_scope/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "1.7.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-monitoring-metrics-scopes/google/cloud/monitoring_metrics_scope_v1/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "1.7.0" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-monitoring-metrics-scopes/google/cloud/monitoring_metrics_scope_v1/services/metrics_scopes/client.py

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -478,36 +478,6 @@ def _get_universe_domain(
478478
raise ValueError("Universe Domain cannot be an empty string.")
479479
return universe_domain
480480

481-
@staticmethod
482-
def _compare_universes(
483-
client_universe: str, credentials: ga_credentials.Credentials
484-
) -> bool:
485-
"""Returns True iff the universe domains used by the client and credentials match.
486-
487-
Args:
488-
client_universe (str): The universe domain configured via the client options.
489-
credentials (ga_credentials.Credentials): The credentials being used in the client.
490-
491-
Returns:
492-
bool: True iff client_universe matches the universe in credentials.
493-
494-
Raises:
495-
ValueError: when client_universe does not match the universe in credentials.
496-
"""
497-
498-
default_universe = MetricsScopesClient._DEFAULT_UNIVERSE
499-
credentials_universe = getattr(credentials, "universe_domain", default_universe)
500-
501-
if client_universe != credentials_universe:
502-
raise ValueError(
503-
"The configured universe domain "
504-
f"({client_universe}) does not match the universe domain "
505-
f"found in the credentials ({credentials_universe}). "
506-
"If you haven't configured the universe domain explicitly, "
507-
f"`{default_universe}` is the default."
508-
)
509-
return True
510-
511481
def _validate_universe_domain(self):
512482
"""Validates client's and credentials' universe domains are consistent.
513483
@@ -517,13 +487,9 @@ def _validate_universe_domain(self):
517487
Raises:
518488
ValueError: If the configured universe domain is not valid.
519489
"""
520-
self._is_universe_domain_valid = (
521-
self._is_universe_domain_valid
522-
or MetricsScopesClient._compare_universes(
523-
self.universe_domain, self.transport._credentials
524-
)
525-
)
526-
return self._is_universe_domain_valid
490+
491+
# NOTE (b/349488459): universe validation is disabled until further notice.
492+
return True
527493

528494
@property
529495
def api_endpoint(self):

packages/google-cloud-monitoring-metrics-scopes/samples/generated_samples/snippet_metadata_google.monitoring.metricsscope.v1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-monitoring-metrics-scopes",
11-
"version": "1.7.0"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

packages/google-cloud-monitoring-metrics-scopes/tests/unit/gapic/monitoring_metrics_scope_v1/test_metrics_scopes.py

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -320,85 +320,6 @@ def test__get_universe_domain():
320320
assert str(excinfo.value) == "Universe Domain cannot be an empty string."
321321

322322

323-
@pytest.mark.parametrize(
324-
"client_class,transport_class,transport_name",
325-
[
326-
(MetricsScopesClient, transports.MetricsScopesGrpcTransport, "grpc"),
327-
],
328-
)
329-
def test__validate_universe_domain(client_class, transport_class, transport_name):
330-
client = client_class(
331-
transport=transport_class(credentials=ga_credentials.AnonymousCredentials())
332-
)
333-
assert client._validate_universe_domain() == True
334-
335-
# Test the case when universe is already validated.
336-
assert client._validate_universe_domain() == True
337-
338-
if transport_name == "grpc":
339-
# Test the case where credentials are provided by the
340-
# `local_channel_credentials`. The default universes in both match.
341-
channel = grpc.secure_channel(
342-
"http://localhost/", grpc.local_channel_credentials()
343-
)
344-
client = client_class(transport=transport_class(channel=channel))
345-
assert client._validate_universe_domain() == True
346-
347-
# Test the case where credentials do not exist: e.g. a transport is provided
348-
# with no credentials. Validation should still succeed because there is no
349-
# mismatch with non-existent credentials.
350-
channel = grpc.secure_channel(
351-
"http://localhost/", grpc.local_channel_credentials()
352-
)
353-
transport = transport_class(channel=channel)
354-
transport._credentials = None
355-
client = client_class(transport=transport)
356-
assert client._validate_universe_domain() == True
357-
358-
# TODO: This is needed to cater for older versions of google-auth
359-
# Make this test unconditional once the minimum supported version of
360-
# google-auth becomes 2.23.0 or higher.
361-
google_auth_major, google_auth_minor = [
362-
int(part) for part in google.auth.__version__.split(".")[0:2]
363-
]
364-
if google_auth_major > 2 or (google_auth_major == 2 and google_auth_minor >= 23):
365-
credentials = ga_credentials.AnonymousCredentials()
366-
credentials._universe_domain = "foo.com"
367-
# Test the case when there is a universe mismatch from the credentials.
368-
client = client_class(transport=transport_class(credentials=credentials))
369-
with pytest.raises(ValueError) as excinfo:
370-
client._validate_universe_domain()
371-
assert (
372-
str(excinfo.value)
373-
== "The configured universe domain (googleapis.com) does not match the universe domain found in the credentials (foo.com). If you haven't configured the universe domain explicitly, `googleapis.com` is the default."
374-
)
375-
376-
# Test the case when there is a universe mismatch from the client.
377-
#
378-
# TODO: Make this test unconditional once the minimum supported version of
379-
# google-api-core becomes 2.15.0 or higher.
380-
api_core_major, api_core_minor = [
381-
int(part) for part in api_core_version.__version__.split(".")[0:2]
382-
]
383-
if api_core_major > 2 or (api_core_major == 2 and api_core_minor >= 15):
384-
client = client_class(
385-
client_options={"universe_domain": "bar.com"},
386-
transport=transport_class(
387-
credentials=ga_credentials.AnonymousCredentials(),
388-
),
389-
)
390-
with pytest.raises(ValueError) as excinfo:
391-
client._validate_universe_domain()
392-
assert (
393-
str(excinfo.value)
394-
== "The configured universe domain (bar.com) does not match the universe domain found in the credentials (googleapis.com). If you haven't configured the universe domain explicitly, `googleapis.com` is the default."
395-
)
396-
397-
# Test that ValueError is raised if universe_domain is provided via client options and credentials is None
398-
with pytest.raises(ValueError):
399-
client._compare_universes("foo.bar", None)
400-
401-
402323
@pytest.mark.parametrize(
403324
"client_class,transport_name",
404325
[

0 commit comments

Comments
 (0)