Search in sources :

Example 31 with S3ObjectMetadata

use of com.formkiq.aws.s3.S3ObjectMetadata in project formkiq-core by formkiq.

the class ApiPublicWebhooksRequestTest method testPostWebhooks13.

/**
 * Post /public/webhooks with Idempotency-Key.
 *
 * @throws Exception an error has occurred
 */
@SuppressWarnings("unchecked")
@Test
public void testPostWebhooks13() throws Exception {
    // given
    createApiRequestHandler(getMap());
    for (String siteId : Arrays.asList(null, UUID.randomUUID().toString())) {
        String idempotencyKey = UUID.randomUUID().toString();
        String name = UUID.randomUUID().toString();
        String id = getAwsServices().webhookService().saveWebhook(siteId, name, "joe", null, "true");
        ApiGatewayRequestEvent event = toRequestEvent("/request-post-public-webhooks01.json", siteId, id);
        event.addHeader("Idempotency-Key", idempotencyKey);
        // when
        String response = handleRequest(event);
        // then
        Map<String, String> m = fromJson(response, Map.class);
        verifyHeaders(m, "200.0");
        String documentId = verifyDocumentId(m);
        verifyS3File(id, siteId, documentId, name, null, false);
        String key = SiteIdKeyGenerator.createDatabaseKey(siteId, "idkey#" + idempotencyKey);
        assertEquals(documentId, getAwsServices().documentCacheService().read(key));
        // given
        // when
        response = handleRequest(event);
        // then
        m = fromJson(response, Map.class);
        verifyHeaders(m, "200.0");
        try (S3Client s3 = getS3().buildClient()) {
            String s3key = createDatabaseKey(siteId, documentId + FORMKIQ_DOC_EXT);
            S3ObjectMetadata om = getS3().getObjectMetadata(s3, STAGE_BUCKET_NAME, s3key);
            assertFalse(om.isObjectExists());
        }
    }
}
Also used : ApiGatewayRequestEvent(com.formkiq.lambda.apigateway.ApiGatewayRequestEvent) S3ObjectMetadata(com.formkiq.aws.s3.S3ObjectMetadata) S3Client(software.amazon.awssdk.services.s3.S3Client) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Aggregations

S3ObjectMetadata (com.emc.object.s3.S3ObjectMetadata)16 S3Exception (com.emc.object.s3.S3Exception)7 S3ObjectMetadata (com.formkiq.aws.s3.S3ObjectMetadata)7 S3ObjectMetadata (uk.nhs.digital.externalstorage.s3.S3ObjectMetadata)7 S3Client (software.amazon.awssdk.services.s3.S3Client)5 AccessControlList (com.emc.object.s3.bean.AccessControlList)4 PutObjectRequest (com.emc.object.s3.request.PutObjectRequest)4 Test (org.junit.Test)4 CopyPartResult (com.emc.object.s3.bean.CopyPartResult)3 MultipartPartETag (com.emc.object.s3.bean.MultipartPartETag)3 PutObjectResult (com.emc.object.s3.bean.PutObjectResult)3 CompleteMultipartUploadRequest (com.emc.object.s3.request.CompleteMultipartUploadRequest)3 CopyPartRequest (com.emc.object.s3.request.CopyPartRequest)3 ChunkAlreadyExistsException (io.pravega.segmentstore.storage.chunklayer.ChunkAlreadyExistsException)3 ChunkNotFoundException (io.pravega.segmentstore.storage.chunklayer.ChunkNotFoundException)3 ChunkStorageException (io.pravega.segmentstore.storage.chunklayer.ChunkStorageException)3 InvalidOffsetException (io.pravega.segmentstore.storage.chunklayer.InvalidOffsetException)3 Date (java.util.Date)3 TreeSet (java.util.TreeSet)3 CanonicalUser (com.emc.object.s3.bean.CanonicalUser)2