public async Task Should_receive_message() { var payloadToSend = new byte[PayloadSize]; var context = await Scenario.Define <Context>() .WithEndpoint <Endpoint>(b => b.When(session => session.SendLocal(new MyMessageWithLargePayload { Payload = payloadToSend })) ) .Done(c => c.ReceivedPayload != null) .Run(); Assert.AreEqual(payloadToSend, context.ReceivedPayload, "The large payload should be handled correctly using the kms encrypted S3 bucket"); var s3Client = SqsTransportExtensions.CreateS3Client(); var getObjectResponse = await s3Client.GetObjectAsync(new GetObjectRequest { BucketName = BucketName, Key = $"{SqsTransportExtensions.S3Prefix}/{context.MessageId}", ServerSideEncryptionCustomerMethod = ServerSideEncryptionCustomerMethod.AES256, ServerSideEncryptionCustomerProvidedKey = Base64Key, }); Assert.AreEqual(ServerSideEncryptionCustomerMethod.AES256, getObjectResponse.ServerSideEncryptionCustomerMethod); Assert.IsNull(getObjectResponse.ServerSideEncryptionMethod); }
public async Task OneTimeTearDown() { // Once all tests have completed, delete all queues that were created. // Use the QueueNamePrefix to determine which queues to delete. var transport = new TransportExtensions <SqsTransport>(new SettingsHolder()); transport = transport.ConfigureSqsTransport(SqsQueueNamePrefix); var transportConfiguration = new TransportConfiguration(transport.GetSettings()); using (var sqsClient = SqsTransportExtensions.CreateSQSClient()) { var listQueuesResult = await sqsClient.ListQueuesAsync(transportConfiguration.QueueNamePrefix).ConfigureAwait(false); foreach (var queueUrl in listQueuesResult.QueueUrls) { try { await sqsClient.DeleteQueueAsync(queueUrl).ConfigureAwait(false); } catch (Exception ex) { Console.WriteLine($"Exception when deleting queue: {ex}"); } } } }
public async Task OneTimeTearDown() { var accessKeyId = EnvironmentHelper.GetEnvironmentVariable("CLEANUP_AWS_ACCESS_KEY_ID"); var secretAccessKey = EnvironmentHelper.GetEnvironmentVariable("CLEANUP_AWS_SECRET_ACCESS_KEY"); using (var sqsClient = string.IsNullOrEmpty(accessKeyId) ? SqsTransportExtensions.CreateSQSClient() : new AmazonSQSClient(accessKeyId, secretAccessKey)) using (var snsClient = string.IsNullOrEmpty(accessKeyId) ? SqsTransportExtensions.CreateSnsClient() : new AmazonSimpleNotificationServiceClient(accessKeyId, secretAccessKey)) using (var s3Client = string.IsNullOrEmpty(accessKeyId) ? SqsTransportExtensions.CreateS3Client() : new AmazonS3Client(accessKeyId, secretAccessKey)) { await Cleanup.DeleteAllResourcesWithPrefix(sqsClient, snsClient, s3Client, NamePrefix).ConfigureAwait(false); } }
public async Task Should_receive_message() { var payloadToSend = new byte[PayloadSize]; var context = await Scenario.Define <Context>() .WithEndpoint <Endpoint>(b => b.When(session => session.SendLocal(new MyMessageWithLargePayload { Payload = payloadToSend })) ) .Done(c => c.ReceivedPayload != null) .Run(); Assert.AreEqual(payloadToSend, context.ReceivedPayload, "The large payload should be handled correctly using the unencrypted S3 bucket"); var s3Client = SqsTransportExtensions.CreateS3Client(); Assert.DoesNotThrowAsync(async() => await s3Client.GetObjectAsync(SqsTransportExtensions.S3BucketName, $"{SqsTransportExtensions.S3Prefix}/{context.MessageId}")); }