use of com.nike.cerberus.security.CerberusPrincipal in project cerberus by Nike-Inc.
the class SecureDataControllerTest method testWriteSecureData.
@Test
public void testWriteSecureData() {
Mockito.when(sdbAccessRequest.getSdbId()).thenReturn("sdbId");
Mockito.when(sdbAccessRequest.getPath()).thenReturn("path");
CerberusPrincipal cerberusPrincipal = Mockito.mock(CerberusPrincipal.class);
Mockito.when(sdbAccessRequest.getPrincipal()).thenReturn(cerberusPrincipal);
Mockito.when(cerberusPrincipal.getName()).thenReturn("name");
HttpEntity<String> httpEntity = new HttpEntity<>("body");
secureDataController.writeSecureData(httpEntity);
Mockito.verify(secureDataService).writeSecret("sdbId", "path", "body", "name");
}
use of com.nike.cerberus.security.CerberusPrincipal in project cerberus by Nike-Inc.
the class SafeDepositBoxControllerV2Test method testGetSafeDepositBoxes.
@Test
public void testGetSafeDepositBoxes() {
CerberusPrincipal cerberusPrincipal = Mockito.mock(CerberusPrincipal.class);
SafeDepositBoxSummary safeDepositBoxSummary = Mockito.mock(SafeDepositBoxSummary.class);
List<SafeDepositBoxSummary> safeDepositBoxSummaries = new ArrayList<>();
safeDepositBoxSummaries.add(safeDepositBoxSummary);
Mockito.when(safeDepositBoxService.getAssociatedSafeDepositBoxes(cerberusPrincipal)).thenReturn(safeDepositBoxSummaries);
List<SafeDepositBoxSummary> actualSafeDepositBoSummaries = safeDepositBoxControllerV2.getSafeDepositBoxes(cerberusPrincipal);
Assert.assertSame(safeDepositBoxSummaries, actualSafeDepositBoSummaries);
Assert.assertEquals(safeDepositBoxSummaries, actualSafeDepositBoSummaries);
}
use of com.nike.cerberus.security.CerberusPrincipal in project cerberus by Nike-Inc.
the class RevokeAuthenticationControllerTest method testRevokeAuthentication.
@Test
public void testRevokeAuthentication() {
OffsetDateTime now = OffsetDateTime.now();
CerberusPrincipal cerberusPrincipal = Mockito.mock(CerberusPrincipal.class);
Mockito.when(cerberusPrincipal.getTokenExpires()).thenReturn(now);
revokeAuthenticationController.revokeAuthentication(cerberusPrincipal);
Mockito.verify(authenticationService).revoke(cerberusPrincipal, now);
}
use of com.nike.cerberus.security.CerberusPrincipal in project cerberus by Nike-Inc.
the class UserAuthenticationControllerTest method testRefreshToken.
@Test
public void testRefreshToken() {
CerberusPrincipal cerberusPrincipal = Mockito.mock(CerberusPrincipal.class);
userAuthenticationController.refreshToken(cerberusPrincipal);
Mockito.verify(authenticationService).refreshUserToken(cerberusPrincipal);
}
use of com.nike.cerberus.security.CerberusPrincipal in project cerberus by Nike-Inc.
the class SecureDataController method writeSecureData.
@PrincipalHasWritePermsForPath
@RequestMapping(value = "/**", method = { POST, PUT }, consumes = ALL_VALUE)
public void writeSecureData(HttpEntity<String> httpEntity) {
CerberusPrincipal principal = sdbAccessRequest.getPrincipal();
secureDataService.writeSecret(sdbAccessRequest.getSdbId(), sdbAccessRequest.getPath(), Optional.ofNullable(httpEntity.getBody()).orElseThrow(() -> new RuntimeException("The body must not be null")), principal.getName());
}
Aggregations