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());
}
}
}
Aggregations