Search in sources :

Example 1 with ChecksumSHA256Service

use of com.mercedesbenz.sechub.sharedkernel.util.ChecksumSHA256Service in project sechub by mercedes-benz.

the class FileUploadSizeScenario2IntTest method handleBigUpload.

private void handleBigUpload(boolean tooBig) throws FileNotFoundException, IOException {
    /* prepare */
    checksumSHA256Service = new ChecksumSHA256Service();
    as(SUPER_ADMIN).assignUserToProject(USER_1, PROJECT_1);
    UUID jobUUID = assertUser(USER_1).doesExist().isAssignedToProject(PROJECT_1).canCreateWebScan(PROJECT_1);
    File largeFile = createZipFileContainingMegabytes(tooBig);
    /* test */
    if (tooBig) {
        expected.expect(NotAcceptable.class);
        expected.expectMessage("File upload maximum reached. Please reduce your upload file size.");
    } else {
    /* nothing - means expected no exception at all!*/
    }
    /* execute */
    try (InputStream inputStream = new FileInputStream(largeFile)) {
        as(USER_1).upload(PROJECT_1, jobUUID, largeFile, checksumSHA256Service.createChecksum(inputStream));
    }
/* @formatter:on */
}
Also used : ChecksumSHA256Service(com.mercedesbenz.sechub.sharedkernel.util.ChecksumSHA256Service) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) UUID(java.util.UUID) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

ChecksumSHA256Service (com.mercedesbenz.sechub.sharedkernel.util.ChecksumSHA256Service)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 UUID (java.util.UUID)1