Skip to content

Commit 07fa8ba

Browse files
1 parent 4ee9bbb commit 07fa8ba

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

googleapiclient/discovery.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,9 @@ def build_from_document(
555555
universe_domain = None
556556
if HAS_UNIVERSE:
557557
universe_domain_env = os.getenv(GOOGLE_CLOUD_UNIVERSE_DOMAIN, None)
558-
universe_domain = universe.determine_domain(client_options.universe_domain, universe_domain_env)
558+
universe_domain = universe.determine_domain(
559+
client_options.universe_domain, universe_domain_env
560+
)
559561
base = base.replace(universe.DEFAULT_UNIVERSE, universe_domain)
560562

561563
audience_for_self_signed_jwt = base
@@ -683,7 +685,7 @@ def build_from_document(
683685
if HAS_UNIVERSE and universe_domain != universe.DEFAULT_UNIVERSE:
684686
raise MutualTLSChannelError(
685687
f"mTLS is not supported in any universe other than {universe.DEFAULT_UNIVERSE}."
686-
)
688+
)
687689
base = mtls_endpoint
688690

689691
if model is None:
@@ -699,7 +701,7 @@ def build_from_document(
699701
resourceDesc=service,
700702
rootDesc=service,
701703
schema=schema,
702-
universe_domain=universe_domain
704+
universe_domain=universe_domain,
703705
)
704706

705707

tests/test_discovery.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2619,26 +2619,29 @@ def test_universe_env_var_configured_with_mtls(self):
26192619

26202620
with self.assertRaises(MutualTLSChannelError):
26212621
with mock.patch.dict(
2622-
"os.environ", {"GOOGLE_API_USE_MTLS_ENDPOINT": "always",
2623-
"GOOGLE_CLOUD_UNIVERSE_DOMAIN": fake_universe}
2622+
"os.environ",
2623+
{
2624+
"GOOGLE_API_USE_MTLS_ENDPOINT": "always",
2625+
"GOOGLE_CLOUD_UNIVERSE_DOMAIN": fake_universe,
2626+
},
26242627
):
26252628
tasks = build_from_document(discovery)
2626-
2629+
26272630
def test_universe_env_var_configured_with_api_override(self):
26282631
fake_universe = "foo.com"
26292632
fake_api_endpoint = "https://www.bar.com/"
26302633
credentials = mock.Mock(universe_domain=fake_universe)
26312634
discovery = read_datafile("tasks.json")
26322635

26332636
with mock.patch.dict(
2634-
"os.environ", {"GOOGLE_CLOUD_UNIVERSE_DOMAIN": fake_universe}
2635-
):
2637+
"os.environ", {"GOOGLE_CLOUD_UNIVERSE_DOMAIN": fake_universe}
2638+
):
26362639
tasks = build_from_document(
26372640
discovery,
26382641
credentials=credentials,
26392642
client_options=google.api_core.client_options.ClientOptions(
2640-
api_endpoint=fake_api_endpoint
2641-
),
2643+
api_endpoint=fake_api_endpoint
2644+
),
26422645
)
26432646

26442647
assert tasks._baseUrl == fake_api_endpoint
@@ -2650,8 +2653,8 @@ def test_universe_env_var_configured_with_client_options_universe(self):
26502653
discovery = read_datafile("tasks.json")
26512654

26522655
with mock.patch.dict(
2653-
"os.environ", {"GOOGLE_CLOUD_UNIVERSE_DOMAIN": another_fake_universe}
2654-
):
2656+
"os.environ", {"GOOGLE_CLOUD_UNIVERSE_DOMAIN": another_fake_universe}
2657+
):
26552658
tasks = build_from_document(
26562659
discovery,
26572660
credentials=credentials,
@@ -2662,5 +2665,6 @@ def test_universe_env_var_configured_with_client_options_universe(self):
26622665

26632666
assert tasks._universe_domain == fake_universe
26642667

2668+
26652669
if __name__ == "__main__":
26662670
unittest.main()

0 commit comments

Comments
 (0)