Skip to content

Commit

Permalink
Fix broken tests (#53)
Browse files Browse the repository at this point in the history
* Change testIamPermission test to not rely on undocumented
  behavior
* Add missing mock configuration for IAP header tests
  • Loading branch information
jpassing authored Mar 14, 2023
1 parent a0c61ed commit 96fca59
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,9 @@ public void whenAuthorized_ThenTestIamPermissionsSucceeds() throws Exception {

var heldPermissions = adapter.testIamPermissions(
IntegrationTestEnvironment.PROJECT_ID,
List.of(
"resourcemanager.projects.get",
"resourcemanager.projects.xxx"));
List.of("resourcemanager.projects.get"));

assertNotNull(heldPermissions);
assertEquals(1, heldPermissions.size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public void whenHeaderMissing_ThenFilterThrowsForbiddenException() {
RuntimeEnvironment environment = Mockito.mock(RuntimeEnvironment.class);
when(environment.getProjectId()).thenReturn("123");
when(environment.getProjectNumber()).thenReturn("123");
when(environment.isRunningOnAppEngine()).thenReturn(true);
when(environment.isDebugModeEnabled()).thenReturn(false);

IapRequestFilter filter = new IapRequestFilter();
Expand All @@ -56,6 +57,7 @@ public void whenHeaderContainsMalformedJwt_ThenFilterThrowsForbiddenException()
RuntimeEnvironment environment = Mockito.mock(RuntimeEnvironment.class);
when(environment.getProjectId()).thenReturn("123");
when(environment.getProjectNumber()).thenReturn("123");
when(environment.isRunningOnAppEngine()).thenReturn(true);
when(environment.isDebugModeEnabled()).thenReturn(false);

IapRequestFilter filter = new IapRequestFilter();
Expand All @@ -73,6 +75,7 @@ public void whenHeaderContainsInvalidJwt_ThenFilterThrowsForbiddenException() {
RuntimeEnvironment environment = Mockito.mock(RuntimeEnvironment.class);
when(environment.getProjectId()).thenReturn("123");
when(environment.getProjectNumber()).thenReturn("123");
when(environment.isRunningOnAppEngine()).thenReturn(true);
when(environment.isDebugModeEnabled()).thenReturn(false);

IapRequestFilter filter = new IapRequestFilter();
Expand Down

0 comments on commit 96fca59

Please sign in to comment.