Skip to content

Commit 4556d14

Browse files
committed
Add a unit test with invalid audiance
1 parent 2610037 commit 4556d14

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/test_external_account.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,14 @@ def test_build_trust_boundary_lookup_url_invalid_workload_no_project_number(self
929929
with pytest.raises(exceptions.InvalidValue):
930930
credentials._build_trust_boundary_lookup_url()
931931

932+
933+
def test_build_trust_boundary_lookup_url_invalid_workforce_audience(self):
934+
credentials = self.make_workforce_pool_credentials()
935+
credentials._audience = "invalid"
936+
with pytest.raises(exceptions.InvalidValue):
937+
credentials._build_trust_boundary_lookup_url()
938+
939+
932940
def test_refresh_fetches_trust_boundary_workload(self):
933941
request = self.make_mock_request(
934942
status=http_client.OK, data=self.SUCCESS_RESPONSE
@@ -2347,6 +2355,25 @@ def test_get_project_id_cloud_resource_manager_error(self):
23472355
assert len(request.call_args_list) == 2
23482356

23492357

2358+
def test_refresh_with_existing_impersonated_credentials(self):
2359+
credentials = self.make_credentials(
2360+
service_account_impersonation_url=self.SERVICE_ACCOUNT_IMPERSONATION_URL
2361+
)
2362+
credentials._impersonated_credentials = mock.Mock()
2363+
request = self.make_mock_request()
2364+
2365+
credentials.refresh(request)
2366+
2367+
credentials._impersonated_credentials.refresh.assert_called_once_with(request)
2368+
2369+
2370+
def test_get_mtls_cert_and_key_paths(self):
2371+
credentials = self.make_credentials()
2372+
with pytest.raises(NotImplementedError):
2373+
credentials._get_mtls_cert_and_key_paths()
2374+
2375+
2376+
23502377
def test_supplier_context():
23512378
context = external_account.SupplierContext("TestTokenType", "TestAudience")
23522379

0 commit comments

Comments
 (0)