Skip to content

Commit

Permalink
Add null check for endpoint testing
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Liang <jiallian@amazon.com>
  • Loading branch information
RyanL1997 committed Oct 11, 2023
1 parent 2a91082 commit 3f542db
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,15 @@ public void testRequestNotAllowed() {
Mockito.when(mockedRequest1.path()).thenReturn(SECURITY_PREFIX + ON_BEHALF_OF_SUFFIX);
Mockito.when(mockedRequest1.method()).thenReturn(POST);
Assert.assertFalse(oboAuth.isRequestAllowed(mockedRequest1));
Assert.assertNull(oboAuth.extractCredentials(mockedRequest1, null));

// Test PUT on password changing endpoint
SecurityRequest mockedRequest2 = mock(SecurityRequest.class);
Mockito.when(mockedRequest2.header(HttpHeaders.AUTHORIZATION)).thenReturn("Bearer someToken");
Mockito.when(mockedRequest2.path()).thenReturn(SECURITY_PREFIX + ACCOUNT_SUFFIX);
Mockito.when(mockedRequest2.method()).thenReturn(PUT);
Assert.assertFalse(oboAuth.isRequestAllowed(mockedRequest2));
Assert.assertNull(oboAuth.extractCredentials(mockedRequest2, null));
}

/** extracts a default user credential from a request header */
Expand Down

0 comments on commit 3f542db

Please sign in to comment.