Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Commit

Permalink
Add unit test to cover it
Browse files Browse the repository at this point in the history
  • Loading branch information
honnix committed Aug 5, 2022
1 parent c1c949f commit 095fe2e
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,18 @@ public void shouldAuthorizeIfPrincipalIsAdminViaGroup(String serviceAccount) thr
assertCachedSuccess(() -> sut.authorizeServiceAccountUsage(WORKFLOW_ID, serviceAccount, idToken));
}

@Parameters({SERVICE_ACCOUNT, MANAGED_SERVICE_ACCOUNT})
@Test
public void shouldAuthorizeIfPrincipalIsAdminViaGroupEvenCheckRoleFails(String serviceAccount) throws IOException {
final Throwable cause = googleJsonResponseException(418);
var errorRequest = mock(Directory.Members.HasMember.class);
doThrow(cause).when(errorRequest).execute();
doReturn(errorRequest).when(members).hasMember(PROJECT_ADMINS_GROUP_EMAIL, PRINCIPAL_EMAIL);
doReturn(isMember).when(members).hasMember(STYX_ADMINS_GROUP_EMAIL, PRINCIPAL_EMAIL);
assertCachedSuccess(() -> sut.authorizeServiceAccountUsage(WORKFLOW_ID, serviceAccount, idToken));
}


@Parameters({SERVICE_ACCOUNT, MANAGED_SERVICE_ACCOUNT})
@Test
public void shouldAuthorizeIfPrincipalHasUserRoleOnProjectViaGroup(String serviceAccount) throws IOException {
Expand Down

0 comments on commit 095fe2e

Please sign in to comment.