Skip to content

Commit 875f712

Browse files
fix: disable universe-domain validation (#13245)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 693215877 Source-Link: googleapis/googleapis@bb6b53e Source-Link: googleapis/googleapis-gen@db8b5a9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXByaXZhdGUtY2F0YWxvZy8uT3dsQm90LnlhbWwiLCJoIjoiZGI4YjVhOTM0ODRhZDQ0MDU1YjJiYWNjNGM3Y2Y4N2U5NzBmZTBlZCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXByaXZpbGVnZWRhY2Nlc3NtYW5hZ2VyLy5Pd2xCb3QueWFtbCIsImgiOiJkYjhiNWE5MzQ4NGFkNDQwNTViMmJhY2M0YzdjZjg3ZTk3MGZlMGVkIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXB1YmxpYy1jYS8uT3dsQm90LnlhbWwiLCJoIjoiZGI4YjVhOTM0ODRhZDQ0MDU1YjJiYWNjNGM3Y2Y4N2U5NzBmZTBlZCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJhcGlkbWlncmF0aW9uYXNzZXNzbWVudC8uT3dsQm90LnlhbWwiLCJoIjoiZGI4YjVhOTM0ODRhZDQ0MDU1YjJiYWNjNGM3Y2Y4N2U5NzBmZTBlZCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlY2FwdGNoYS1lbnRlcnByaXNlLy5Pd2xCb3QueWFtbCIsImgiOiJkYjhiNWE5MzQ4NGFkNDQwNTViMmJhY2M0YzdjZjg3ZTk3MGZlMGVkIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlY29tbWVuZGF0aW9ucy1haS8uT3dsQm90LnlhbWwiLCJoIjoiZGI4YjVhOTM0ODRhZDQ0MDU1YjJiYWNjNGM3Y2Y4N2U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== --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Victor Chudnovsky <vchudnov@google.com>
1 parent d794dec commit 875f712

254 files changed

Lines changed: 382 additions & 9975 deletions

File tree

Some content is hidden

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

β€Žpackages/google-cloud-private-catalog/google/cloud/privatecatalog/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__ = "0.9.12" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

β€Žpackages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/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__ = "0.9.12" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

β€Žpackages/google-cloud-private-catalog/google/cloud/privatecatalog_v1beta1/services/private_catalog/client.pyβ€Ž

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

516-
@staticmethod
517-
def _compare_universes(
518-
client_universe: str, credentials: ga_credentials.Credentials
519-
) -> bool:
520-
"""Returns True iff the universe domains used by the client and credentials match.
521-
522-
Args:
523-
client_universe (str): The universe domain configured via the client options.
524-
credentials (ga_credentials.Credentials): The credentials being used in the client.
525-
526-
Returns:
527-
bool: True iff client_universe matches the universe in credentials.
528-
529-
Raises:
530-
ValueError: when client_universe does not match the universe in credentials.
531-
"""
532-
533-
default_universe = PrivateCatalogClient._DEFAULT_UNIVERSE
534-
credentials_universe = getattr(credentials, "universe_domain", default_universe)
535-
536-
if client_universe != credentials_universe:
537-
raise ValueError(
538-
"The configured universe domain "
539-
f"({client_universe}) does not match the universe domain "
540-
f"found in the credentials ({credentials_universe}). "
541-
"If you haven't configured the universe domain explicitly, "
542-
f"`{default_universe}` is the default."
543-
)
544-
return True
545-
546516
def _validate_universe_domain(self):
547517
"""Validates client's and credentials' universe domains are consistent.
548518
@@ -552,13 +522,9 @@ def _validate_universe_domain(self):
552522
Raises:
553523
ValueError: If the configured universe domain is not valid.
554524
"""
555-
self._is_universe_domain_valid = (
556-
self._is_universe_domain_valid
557-
or PrivateCatalogClient._compare_universes(
558-
self.universe_domain, self.transport._credentials
559-
)
560-
)
561-
return self._is_universe_domain_valid
525+
526+
# NOTE (b/349488459): universe validation is disabled until further notice.
527+
return True
562528

563529
@property
564530
def api_endpoint(self):

β€Žpackages/google-cloud-private-catalog/samples/generated_samples/snippet_metadata_google.cloud.privatecatalog.v1beta1.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-private-catalog",
11-
"version": "0.9.12"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

β€Žpackages/google-cloud-private-catalog/tests/unit/gapic/privatecatalog_v1beta1/test_private_catalog.pyβ€Ž

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

320320

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

β€Žpackages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager/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__ = "0.1.2" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

β€Žpackages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_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__ = "0.1.2" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

β€Žpackages/google-cloud-privilegedaccessmanager/google/cloud/privilegedaccessmanager_v1/services/privileged_access_manager/client.pyβ€Ž

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

525-
@staticmethod
526-
def _compare_universes(
527-
client_universe: str, credentials: ga_credentials.Credentials
528-
) -> bool:
529-
"""Returns True iff the universe domains used by the client and credentials match.
530-
531-
Args:
532-
client_universe (str): The universe domain configured via the client options.
533-
credentials (ga_credentials.Credentials): The credentials being used in the client.
534-
535-
Returns:
536-
bool: True iff client_universe matches the universe in credentials.
537-
538-
Raises:
539-
ValueError: when client_universe does not match the universe in credentials.
540-
"""
541-
542-
default_universe = PrivilegedAccessManagerClient._DEFAULT_UNIVERSE
543-
credentials_universe = getattr(credentials, "universe_domain", default_universe)
544-
545-
if client_universe != credentials_universe:
546-
raise ValueError(
547-
"The configured universe domain "
548-
f"({client_universe}) does not match the universe domain "
549-
f"found in the credentials ({credentials_universe}). "
550-
"If you haven't configured the universe domain explicitly, "
551-
f"`{default_universe}` is the default."
552-
)
553-
return True
554-
555525
def _validate_universe_domain(self):
556526
"""Validates client's and credentials' universe domains are consistent.
557527
@@ -561,13 +531,9 @@ def _validate_universe_domain(self):
561531
Raises:
562532
ValueError: If the configured universe domain is not valid.
563533
"""
564-
self._is_universe_domain_valid = (
565-
self._is_universe_domain_valid
566-
or PrivilegedAccessManagerClient._compare_universes(
567-
self.universe_domain, self.transport._credentials
568-
)
569-
)
570-
return self._is_universe_domain_valid
534+
535+
# NOTE (b/349488459): universe validation is disabled until further notice.
536+
return True
571537

572538
@property
573539
def api_endpoint(self):

β€Žpackages/google-cloud-privilegedaccessmanager/samples/generated_samples/snippet_metadata_google.cloud.privilegedaccessmanager.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-privilegedaccessmanager",
11-
"version": "0.1.2"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

β€Žpackages/google-cloud-privilegedaccessmanager/tests/unit/gapic/privilegedaccessmanager_v1/test_privileged_access_manager.pyβ€Ž

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -351,94 +351,6 @@ def test__get_universe_domain():
351351
assert str(excinfo.value) == "Universe Domain cannot be an empty string."
352352

353353

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

0 commit comments

Comments
 (0)