use of com.nike.cerberus.security.CerberusPrincipal in project cerberus by Nike-Inc.
the class SecureFileControllerTest method testWriteSecureFile.
@Test
public void testWriteSecureFile() throws IOException {
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");
MultipartFile multipartFile = Mockito.mock(MultipartFile.class);
byte[] data = "data".getBytes(StandardCharsets.UTF_8);
Mockito.when(multipartFile.getBytes()).thenReturn(data);
secureFileController.writeSecureFile(multipartFile);
Mockito.verify(secureDataService).writeSecureFile("sdbId", "path", data, data.length, "name");
}
use of com.nike.cerberus.security.CerberusPrincipal in project cerberus by Nike-Inc.
the class SecureFileControllerTest method testDeleteSecureFile.
@Test
public void testDeleteSecureFile() {
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");
secureFileController.deleteSecureFile();
Mockito.verify(secureDataService).deleteSecret("sdbId", "path", SecureDataType.FILE, "name");
}
use of com.nike.cerberus.security.CerberusPrincipal in project cerberus by Nike-Inc.
the class SafeDepositBoxControllerV2Test method testUpdateSafeDepositBoxV2.
@Test
public void testUpdateSafeDepositBoxV2() {
SafeDepositBoxV2 safeDepositBoxV2 = Mockito.mock(SafeDepositBoxV2.class);
CerberusPrincipal cerberusPrincipal = Mockito.mock(CerberusPrincipal.class);
Mockito.when(safeDepositBoxService.updateSafeDepositBoxV2(safeDepositBoxV2, cerberusPrincipal, "sdbId")).thenReturn(safeDepositBoxV2);
SafeDepositBoxV2 actualSafeDepositBoxV2 = safeDepositBoxControllerV2.updateSafeDepositBox("sdbId", safeDepositBoxV2, cerberusPrincipal);
Assert.assertSame(safeDepositBoxV2, actualSafeDepositBoxV2);
}
Aggregations