Ejemplo n.º 1
0
        public async Task MultipartWithEncryption(SseAlgorithm algorithm)
        {
            string objectKey = nameof(MultipartWithEncryption);

            CreateMultipartUploadResponse createResp = await MultipartClient.CreateMultipartUploadAsync(BucketName, objectKey, req => req.SseAlgorithm = algorithm).ConfigureAwait(false);

            Assert.Equal(algorithm, createResp.SseAlgorithm);

            if (algorithm == SseAlgorithm.AwsKms)
            {
                Assert.NotNull(createResp.SseKmsKeyId);
            }

            byte[] file = new byte[1024 * 1024 * 5];

            UploadPartResponse uploadResp = await MultipartClient.UploadPartAsync(BucketName, objectKey, 1, createResp.UploadId, new MemoryStream(file)).ConfigureAwait(false);

            Assert.Equal(algorithm, uploadResp.SseAlgorithm);

            if (algorithm == SseAlgorithm.AwsKms)
            {
                Assert.NotNull(uploadResp.SseKmsKeyId);
            }

            CompleteMultipartUploadResponse completeResp = await MultipartClient.CompleteMultipartUploadAsync(BucketName, objectKey, createResp.UploadId, new[] { uploadResp }).ConfigureAwait(false);

            Assert.Equal(algorithm, completeResp.SseAlgorithm);

            if (algorithm == SseAlgorithm.AwsKms)
            {
                Assert.NotNull(completeResp.SseKmsKeyId);
            }
        }
Ejemplo n.º 2
0
        public async Task ServerSideEncryption(SseAlgorithm algorithm)
        {
            PutObjectResponse resp = await UploadAsync(nameof(ServerSideEncryption), request => request.SseAlgorithm = algorithm).ConfigureAwait(false);

            Assert.Equal(algorithm, resp.SseAlgorithm);

            await AssertAsync(nameof(ServerSideEncryption)).ConfigureAwait(false);
        }
Ejemplo n.º 3
0
    public async Task MultipartWithEncryption(S3Provider provider, string bucket, ISimpleClient client, SseAlgorithm algorithm)
    {
        string objectKey = nameof(MultipartWithEncryption);

        CreateMultipartUploadResponse createResp = await client.CreateMultipartUploadAsync(bucket, objectKey, req => req.SseAlgorithm = algorithm).ConfigureAwait(false);

        Assert.Equal(200, createResp.StatusCode);

        if (provider == S3Provider.AmazonS3)
        {
            Assert.Equal(algorithm, createResp.SseAlgorithm);
        }

        if (algorithm == SseAlgorithm.AwsKms)
        {
            Assert.NotNull(createResp.SseKmsKeyId);
        }

        await using MemoryStream ms = new MemoryStream(new byte[1024 * 1024 * 5]);

        UploadPartResponse uploadResp = await client.UploadPartAsync(bucket, objectKey, 1, createResp.UploadId, ms).ConfigureAwait(false);

        Assert.Equal(200, uploadResp.StatusCode);

        if (provider == S3Provider.AmazonS3)
        {
            Assert.Equal(algorithm, uploadResp.SseAlgorithm);
        }

        if (algorithm == SseAlgorithm.AwsKms)
        {
            Assert.NotNull(uploadResp.SseKmsKeyId);
        }

        CompleteMultipartUploadResponse completeResp = await client.CompleteMultipartUploadAsync(bucket, objectKey, createResp.UploadId, new[] { uploadResp }).ConfigureAwait(false);

        Assert.Equal(200, completeResp.StatusCode);

        if (provider == S3Provider.AmazonS3)
        {
            Assert.Equal(algorithm, completeResp.SseAlgorithm);
        }

        if (algorithm == SseAlgorithm.AwsKms)
        {
            Assert.NotNull(completeResp.SseKmsKeyId);
        }
    }
Ejemplo n.º 4
0
    public async Task PutObjectServerSideEncryption(S3Provider _, string bucket, ISimpleClient client, SseAlgorithm algorithm)
    {
        PutObjectResponse putResp = await client.PutObjectAsync(bucket, nameof(PutObjectServerSideEncryption), null, r => r.SseAlgorithm = algorithm).ConfigureAwait(false);

        Assert.Equal(200, putResp.StatusCode);
        Assert.Equal(algorithm, putResp.SseAlgorithm);

        GetObjectResponse getResp = await client.GetObjectAsync(bucket, nameof(PutObjectServerSideEncryption)).ConfigureAwait(false);

        Assert.Equal(200, getResp.StatusCode);
    }