Ejemplo n.º 1
0
    public async Task ListObjects(S3Provider provider, string _, ISimpleClient client)
    {
        await CreateTempBucketAsync(provider, client, async tempBucket =>
        {
            string tempObjName        = "object-" + Guid.NewGuid();
            PutObjectResponse putResp = await client.PutObjectStringAsync(tempBucket, tempObjName, "hello").ConfigureAwait(false);
            Assert.Equal(200, putResp.StatusCode);

            ListObjectsResponse listResp = await client.ListObjectsAsync(tempBucket).ConfigureAwait(false);
            Assert.Equal(200, listResp.StatusCode);

            Assert.Equal(tempBucket, listResp.BucketName);
            Assert.Equal(1, listResp.KeyCount);

            if (provider == S3Provider.AmazonS3)
            {
                Assert.Equal(1000, listResp.MaxKeys);
            }

            Assert.False(listResp.IsTruncated);

            S3Object obj = listResp.Objects.First();
            Assert.Equal(tempObjName, obj.ObjectKey);
            Assert.Equal("\"5d41402abc4b2a76b9719d911017c592\"", obj.ETag);
            Assert.Equal(5, obj.Size);
            Assert.Equal(DateTime.UtcNow, obj.LastModifiedOn.UtcDateTime, TimeSpan.FromSeconds(5));

            if (provider == S3Provider.AmazonS3)
            {
                Assert.Equal(StorageClass.Standard, obj.StorageClass);
            }
        }).ConfigureAwait(false);
    }
Ejemplo n.º 2
0
    public async Task ListObjectsWithDelimiter(S3Provider provider, string _, ISimpleClient client)
    {
        await CreateTempBucketAsync(provider, client, async tempBucket =>
        {
            string tempObjName  = "object-" + Guid.NewGuid();
            string tempObjName2 = "something-" + Guid.NewGuid();

            await client.PutObjectAsync(tempBucket, tempObjName, null).ConfigureAwait(false);
            await client.PutObjectAsync(tempBucket, tempObjName2, null).ConfigureAwait(false);

            ListObjectsResponse listResp = await client.ListObjectsAsync(tempBucket, r => r.Delimiter = "-").ConfigureAwait(false);
            Assert.Equal(200, listResp.StatusCode);

            Assert.Equal("-", listResp.Delimiter);

            if (provider != S3Provider.GoogleCloudStorage)
            {
                Assert.Equal(2, listResp.KeyCount);
            }

            Assert.Equal(2, listResp.CommonPrefixes.Count);
            Assert.Equal("object-", listResp.CommonPrefixes[0]);
            Assert.Equal("something-", listResp.CommonPrefixes[1]);
        }).ConfigureAwait(false);
    }
Ejemplo n.º 3
0
 public async Task CreateBucketCannedAcl(S3Provider provider, string _, ISimpleClient client)
 {
     await CreateTempBucketAsync(provider, client, async tempBucket =>
     {
         //TODO: Check ACL once we have that functionality
     }, r => r.Acl = BucketCannedAcl.Private);
 }
Ejemplo n.º 4
0
 public CoinsClientTests(CoinGeckoApiFixture apiFixture, ITestOutputHelper output)
     : base(apiFixture, output)
 {
     _coinsClient  = ServiceProvider.GetRequiredService <ICoinsClient>();
     _simpleClient = ServiceProvider.GetRequiredService <ISimpleClient>();
     _output       = output;
 }
Ejemplo n.º 5
0
    public async Task ListBuckets(S3Provider _, string bucket, ISimpleClient client)
    {
        ListBucketsResponse listResp = await client.ListBucketsAsync().ConfigureAwait(false);

        Assert.True(listResp.Buckets.Count > 0);
        Assert.Single(listResp.Buckets, x => x.BucketName == bucket);
    }
    public async Task OverwriteExistingLock(S3Provider provider, string _, ISimpleClient client)
    {
        await CreateTempBucketAsync(provider, client, async tempBucket =>
        {
            PutBucketLockConfigurationResponse putResp = await client.PutBucketLockConfigurationAsync(tempBucket, true, r =>
            {
                r.LockMode        = LockMode.Compliance;
                r.LockRetainUntil = DateTimeOffset.UtcNow.AddDays(2);
            }).ConfigureAwait(false);
            Assert.Equal(200, putResp.StatusCode);

            GetBucketLockConfigurationResponse getResp = await client.GetBucketLockConfigurationAsync(tempBucket).ConfigureAwait(false);
            Assert.Equal(200, getResp.StatusCode);
            Assert.Equal(LockMode.Compliance, getResp.LockMode);
            Assert.Equal(DateTimeOffset.UtcNow.AddDays(2 - 1).DateTime, getResp.LockRetainUntil !.Value.DateTime, TimeSpan.FromMinutes(1));

            PutBucketLockConfigurationResponse putResp2 = await client.PutBucketLockConfigurationAsync(tempBucket, true, r =>
            {
                r.LockMode        = LockMode.Governance;
                r.LockRetainUntil = DateTimeOffset.UtcNow.AddDays(5);
            }).ConfigureAwait(false);
            Assert.Equal(200, putResp2.StatusCode);

            GetBucketLockConfigurationResponse getResp2 = await client.GetBucketLockConfigurationAsync(tempBucket).ConfigureAwait(false);
            Assert.Equal(200, getResp2.StatusCode);
            Assert.Equal(LockMode.Governance, getResp2.LockMode);
            Assert.Equal(DateTimeOffset.UtcNow.AddDays(5 - 1).DateTime, getResp2.LockRetainUntil !.Value.DateTime, TimeSpan.FromMinutes(1));
        }).ConfigureAwait(false);
    }
Ejemplo n.º 7
0
    public async Task DeleteObjects(S3Provider _, string bucket, ISimpleClient client)
    {
        S3DeleteInfo[] resources = new S3DeleteInfo[2];
        resources[0] = new S3DeleteInfo(nameof(DeleteObjects) + "1");
        resources[1] = new S3DeleteInfo(nameof(DeleteObjects) + "2", "versionnotfound");

        PutObjectResponse putResp1 = await client.PutObjectAsync(bucket, resources[0].ObjectKey, null).ConfigureAwait(false);

        Assert.Equal(200, putResp1.StatusCode);

        PutObjectResponse putResp2 = await client.PutObjectAsync(bucket, resources[1].ObjectKey, null).ConfigureAwait(false);

        Assert.Equal(200, putResp2.StatusCode);

        DeleteObjectsResponse delResp = await client.DeleteObjectsAsync(bucket, resources, r => r.Quiet = false).ConfigureAwait(false);

        Assert.Equal(200, delResp.StatusCode);

        S3DeletedObject?delObj = Assert.Single(delResp.Deleted);

        Assert.Equal(resources[0].ObjectKey, delObj.ObjectKey);
        Assert.True(delObj.IsDeleteMarker);
        Assert.NotEmpty(delObj.DeleteMarkerVersionId);

        S3DeleteError?errorObj = Assert.Single(delResp.Errors);

        Assert.Equal(resources[1].ObjectKey, errorObj.ObjectKey);
        Assert.Equal(resources[1].VersionId, errorObj.VersionId);
        Assert.Equal(ErrorCode.NoSuchVersion, errorObj.Code);
        Assert.NotEmpty(errorObj.Message);
    }
Ejemplo n.º 8
0
    public async Task MultipartCustomerEncryption(S3Provider _, string bucket, ISimpleClient client)
    {
        string objectKey = nameof(MultipartCustomerEncryption);

        byte[] key    = { 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8 };
        byte[] keyMd5 = CryptoHelper.Md5Hash(key);

        CreateMultipartUploadResponse initResp = await client.CreateMultipartUploadAsync(bucket, objectKey, r =>
        {
            r.SseCustomerAlgorithm = SseCustomerAlgorithm.Aes256;
            r.SseCustomerKey       = key;
            r.SseCustomerKeyMd5    = keyMd5;
        }).ConfigureAwait(false);

        Assert.Equal(200, initResp.StatusCode);

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

        UploadPartResponse uploadResp1 = await client.UploadPartAsync(bucket, objectKey, 1, initResp.UploadId, ms, r =>
        {
            r.SseCustomerAlgorithm = SseCustomerAlgorithm.Aes256;
            r.SseCustomerKey       = key;
            r.SseCustomerKeyMd5    = keyMd5;
        }).ConfigureAwait(false);

        Assert.Equal(200, uploadResp1.StatusCode);
        Assert.Equal(SseCustomerAlgorithm.Aes256, uploadResp1.SseCustomerAlgorithm);
        Assert.Equal(keyMd5, uploadResp1.SseCustomerKeyMd5);

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

        Assert.Equal(200, completeResp.StatusCode);
        Assert.Equal(SseCustomerAlgorithm.Aes256, completeResp.SseCustomerAlgorithm);
    }
Ejemplo n.º 9
0
    public async Task FullPreSignTest(S3Provider _, string bucket, ISimpleClient client)
    {
        int expireIn = 100;

        string url = client.SignPutObject(bucket, "test.zip", null, TimeSpan.FromSeconds(expireIn));

        await using (MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes("hello world")))
        {
            PutObjectResponse putResp = await client.PutObjectAsync(url, ms).ConfigureAwait(false);

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

        url = client.SignGetObject(bucket, "test.zip", TimeSpan.FromSeconds(expireIn));

        GetObjectResponse getResp = await client.GetObjectAsync(url).ConfigureAwait(false);

        Assert.Equal(200, getResp.StatusCode);

        url = client.SignDeleteObject(bucket, "test.zip", TimeSpan.FromSeconds(expireIn));

        DeleteObjectResponse deleteResp = await client.DeleteObjectAsync(url).ConfigureAwait(false);

        Assert.Equal(204, deleteResp.StatusCode);

        url = client.SignHeadObject(bucket, "test.zip", TimeSpan.FromSeconds(expireIn));

        HeadObjectResponse headResp = await client.HeadObjectAsync(url).ConfigureAwait(false);

        Assert.Equal(404, headResp.StatusCode);
    }
Ejemplo n.º 10
0
    public async Task RestoreWithSelect(S3Provider _, string bucket, ISimpleClient client)
    {
        await using (StringWriter sw = new StringWriter())
        {
            sw.WriteLine("name,age,status");
            sw.WriteLine("santa,800,missing");
            sw.WriteLine("\"donald trump\",7,present");
            sw.WriteLine("fantastic fox,31,missing");

            await client.PutObjectStringAsync(bucket, nameof(RestoreWithSelect), sw.ToString(), null, r => r.StorageClass = StorageClass.Glacier).ConfigureAwait(false);
        }

        RestoreObjectResponse restoreResp = await client.RestoreObjectAsync(bucket, nameof(RestoreWithSelect), r =>
        {
            r.RequestType = RestoreRequestType.Select;
            r.Description = "This is a description";
            r.RequestTier = RetrievalTier.Standard;

            S3CsvInputFormat inputFormat = new S3CsvInputFormat();
            inputFormat.HeaderUsage      = HeaderUsage.Use;

            S3CsvOutputFormat outputFormat = new S3CsvOutputFormat();
            r.SelectParameters             = new S3SelectParameters("SELECT * FROM object WHERE age > 7", inputFormat, outputFormat);

            r.OutputLocation = new S3OutputLocation(bucket, "outputJob");
            r.OutputLocation.StorageClass = StorageClass.Standard;
        }).ConfigureAwait(false);

        Assert.Equal(202, restoreResp.StatusCode);

        //TODO: List objects beneath outputJob/* and GET file to determine if format is correct
    }
Ejemplo n.º 11
0
    public async Task MultipartTooSmall(S3Provider provider, string bucket, ISimpleClient client)
    {
        string objectKey = nameof(MultipartTooSmall);

        CreateMultipartUploadResponse initResp = await client.CreateMultipartUploadAsync(bucket, objectKey).ConfigureAwait(false);

        Assert.Equal(200, initResp.StatusCode);
        Assert.Equal(bucket, initResp.BucketName);
        Assert.Equal(objectKey, initResp.ObjectKey);
        Assert.NotNull(initResp.UploadId);

        //4 MB is below the 5 MB limit. See https://docs.aws.amazon.com/AmazonS3/latest/dev/qfacts.html
        //Note that if there only is 1 part, then it is technically the last part, and can be of any size. That's why this test has 2 parts.
        byte[]   file  = new byte[1024 * 1024 * 4];
        byte[][] parts = file.Chunk(file.Length / 2).Select(x => x.ToArray()).ToArray();

        await using MemoryStream ms1 = new MemoryStream(parts[0]);
        UploadPartResponse uploadResp1 = await client.UploadPartAsync(bucket, objectKey, 1, initResp.UploadId, ms1).ConfigureAwait(false);

        Assert.Equal(provider == S3Provider.BackBlazeB2 ? 400 : 200, uploadResp1.StatusCode);

        await using MemoryStream ms2 = new MemoryStream(parts[0]);
        UploadPartResponse uploadResp2 = await client.UploadPartAsync(bucket, objectKey, 2, initResp.UploadId, ms2).ConfigureAwait(false);

        Assert.Equal(provider == S3Provider.BackBlazeB2 ? 400 : 200, uploadResp2.StatusCode);

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

        Assert.Equal(provider == S3Provider.BackBlazeB2 ? 500 : 400, completeResp.StatusCode);
    }
Ejemplo n.º 12
0
 public async Task CreateBucketObjectLocking(S3Provider provider, string _, ISimpleClient client)
 {
     await CreateTempBucketAsync(provider, client, async tempBucket =>
     {
         //TODO: Check locking is enabled once we have that functionality
     }, r => r.EnableObjectLocking = true);
 }
Ejemplo n.º 13
0
    public async Task ListObjectsMoreThanMaxKeys(S3Provider provider, string _, ISimpleClient client)
    {
        await CreateTempBucketAsync(provider, client, async tempBucket =>
        {
            int concurrent = 10;
            int count      = 11;

            await ParallelHelper.ExecuteAsync(Enumerable.Range(0, count), (val, token) => client.PutObjectAsync(tempBucket, val.ToString(), null, null, token), concurrent);

            ListObjectVersionsResponse listResp = await client.ListObjectVersionsAsync(tempBucket, r => r.MaxKeys = count - 1).ConfigureAwait(false);
            Assert.True(listResp.IsSuccess);
            Assert.True(listResp.IsTruncated);
            Assert.Equal(10, listResp.MaxKeys);
            Assert.Equal(10, listResp.Versions.Count);

            ListObjectVersionsResponse listResp2 = await client.ListObjectVersionsAsync(tempBucket, r => r.KeyMarker = listResp.NextKeyMarker).ConfigureAwait(false);
            Assert.True(listResp2.IsSuccess);
            Assert.False(listResp2.IsTruncated);

            if (provider != S3Provider.GoogleCloudStorage)
            {
                Assert.Equal(1, listResp2.Versions.Count);
            }
        }).ConfigureAwait(false);
    }
Ejemplo n.º 14
0
    [MultipleProviders(S3Provider.AmazonS3 | S3Provider.GoogleCloudStorage)] //BackBlaze does not support suspending versioning
    public async Task PutBucketVersioningRequest(S3Provider provider, string _, ISimpleClient client)
    {
        await CreateTempBucketAsync(provider, client, async tempBucket =>
        {
            //Check if versioning is enabled (it shouldn't be)
            GetBucketVersioningResponse getResp = await client.GetBucketVersioningAsync(tempBucket);
            Assert.Equal(200, getResp.StatusCode);
            Assert.False(getResp.MfaDelete);

            if (provider != S3Provider.BackBlazeB2) //backblaze always return true for versioning
            {
                Assert.False(getResp.Status);
            }

            //Enable versioning
            PutBucketVersioningResponse putResp = await client.PutBucketVersioningAsync(tempBucket, true);
            Assert.Equal(200, putResp.StatusCode);

            //Check if versioning is enabled (it should be)
            GetBucketVersioningResponse getResp2 = await client.GetBucketVersioningAsync(tempBucket);
            Assert.Equal(200, getResp2.StatusCode);
            Assert.True(getResp2.Status);

            //Disable versioning
            PutBucketVersioningResponse putResp2 = await client.PutBucketVersioningAsync(tempBucket, false);
            Assert.Equal(200, putResp2.StatusCode);

            //Check if versioning is enabled (it shouldn't be)
            GetBucketVersioningResponse getResp3 = await client.GetBucketVersioningAsync(tempBucket);
            Assert.Equal(200, putResp2.StatusCode);
            Assert.False(getResp3.Status);
        }).ConfigureAwait(false);
    }
Ejemplo n.º 15
0
 public async Task GetWhenBucketLockIsDisabled(S3Provider provider, string _, ISimpleClient client)
 {
     await CreateTempBucketAsync(provider, client, async tempBucket =>
     {
         GetBucketLockConfigurationResponse getResp = await client.GetBucketLockConfigurationAsync(tempBucket).ConfigureAwait(false);
         Assert.Equal(404, getResp.StatusCode);
     }).ConfigureAwait(false);
 }
Ejemplo n.º 16
0
 public async Task GetEmptyBucketTagging(S3Provider provider, string _, ISimpleClient client)
 {
     await CreateTempBucketAsync(provider, client, async tempBucket =>
     {
         GetBucketTaggingResponse getResp = await client.GetBucketTaggingAsync(tempBucket).ConfigureAwait(false);
         Assert.Equal(404, getResp.StatusCode);
     }).ConfigureAwait(false);
 }
Ejemplo n.º 17
0
    [MultipleProviders(S3Provider.Wasabi, ".")] //Wasabi seems to allow null bytes
    public async Task PutObjectInvalidCharacters(S3Provider _, string bucket, ISimpleClient client, string name)
    {
        //These 2 test cases came after an exhaustive search in the whole UTF-16 character space.
        PutObjectResponse putResp = await client.PutObjectAsync(bucket, name, null).ConfigureAwait(false);

        //We use IsSuccess here since different providers return different error codes
        Assert.False(putResp.IsSuccess);
    }
Ejemplo n.º 18
0
    private static async Task Main(string[] args)
    {
        S3Provider s3Provider = UtilityHelper.SelectProvider();

        Console.WriteLine();

        string profileName = UtilityHelper.GetProfileName(s3Provider);

        Console.WriteLine("This program will delete all buckets beginning with 'testbucket-'. Are you sure? Y/N");

        ConsoleKeyInfo key = Console.ReadKey(true);

        if (key.KeyChar != 'y')
        {
            return;
        }

        using ServiceProvider provider = UtilityHelper.CreateSimpleS3(s3Provider, profileName, true);

        IProfile profile = UtilityHelper.GetOrSetupProfile(provider, s3Provider, profileName);

        ISimpleClient client = provider.GetRequiredService <ISimpleClient>();

        await foreach (S3Bucket bucket in ListAllBucketsAsync(client))
        {
            if (!UtilityHelper.IsTestBucket(bucket.BucketName, profile) && !UtilityHelper.IsTemporaryBucket(bucket.BucketName))
            {
                continue;
            }

            Console.Write(bucket.BucketName);

            int errors = await UtilityHelper.ForceDeleteBucketAsync(s3Provider, client, bucket.BucketName);

            if (errors == 0)
            {
                Console.Write(" [x] emptied ");

                DeleteBucketResponse delBucketResp = await client.DeleteBucketAsync(bucket.BucketName).ConfigureAwait(false);

                if (delBucketResp.IsSuccess)
                {
                    Console.Write("[x] deleted");
                }
                else
                {
                    Console.Write("[ ] deleted");
                }
            }
            else
            {
                Console.Write(" [ ] emptied [ ] deleted");
            }

            Console.WriteLine();
        }
    }
Ejemplo n.º 19
0
    public CoinGeckoClientTests(ITestOutputHelper output)
    {
        _simpleClient = Substitute.For <ISimpleClient>();
        _coinsClient  = Substitute.For <ICoinsClient>();
        _memoryCache  = Substitute.For <IMemoryCache>();
        _mockCreator  = new MockCreator(output);

        _coinGeckoClient = new CoinGeckoClient(_memoryCache, _coinsClient, _simpleClient);
    }
Ejemplo n.º 20
0
    public async Task HeadObjectContentRange(S3Provider _, string bucket, ISimpleClient client)
    {
        await client.PutObjectStringAsync(bucket, nameof(HeadObjectContentRange), "test").ConfigureAwait(false);

        HeadObjectResponse headResp = await client.HeadObjectAsync(bucket, nameof(HeadObjectContentRange), r => r.Range.Add(0, 2)).ConfigureAwait(false);

        Assert.Equal("bytes", headResp.AcceptRanges);
        Assert.Equal("bytes 0-2/4", headResp.ContentRange);
    }
Ejemplo n.º 21
0
    public async Task HeadObject(S3Provider _, string bucket, ISimpleClient client)
    {
        PutObjectResponse putResp = await client.PutObjectAsync(bucket, nameof(HeadObject), null).ConfigureAwait(false);

        Assert.Equal(200, putResp.StatusCode);

        HeadObjectResponse headResp = await client.HeadObjectAsync(bucket, nameof(HeadObject)).ConfigureAwait(false);

        Assert.Equal(200, headResp.StatusCode);
    }
Ejemplo n.º 22
0
    public async Task PutObjectValidCharacters(S3Provider _, string bucket, ISimpleClient client, string name)
    {
        PutObjectResponse putResp = await client.PutObjectAsync(bucket, name, null).ConfigureAwait(false);

        Assert.Equal(200, putResp.StatusCode);

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

        Assert.Equal(200, getResp.StatusCode);
    }
Ejemplo n.º 23
0
    public async Task HeadBucket(S3Provider _, string bucket, ISimpleClient client)
    {
        HeadBucketResponse headResp = await client.HeadBucketAsync(bucket).ConfigureAwait(false);

        Assert.Equal(200, headResp.StatusCode);

        headResp = await client.HeadBucketAsync(GetTemporaryBucket()).ConfigureAwait(false);

        Assert.False(headResp.IsSuccess);
    }
Ejemplo n.º 24
0
 public async Task GetEmptyBucketLock(S3Provider provider, string _, ISimpleClient client)
 {
     await CreateTempBucketAsync(provider, client, async tempBucket =>
     {
         GetBucketLockConfigurationResponse getResp = await client.GetBucketLockConfigurationAsync(tempBucket).ConfigureAwait(false);
         Assert.Equal(200, getResp.StatusCode);
         Assert.Equal(LockMode.Unknown, getResp.LockMode);
         Assert.Null(getResp.LockRetainUntil);
     }, r => r.EnableObjectLocking = true).ConfigureAwait(false);
 }
Ejemplo n.º 25
0
    public async Task HeadObjectWebsiteRedirect(S3Provider _, string bucket, ISimpleClient client)
    {
        PutObjectResponse putResp = await client.PutObjectAsync(bucket, nameof(HeadObjectWebsiteRedirect), null, r => r.WebsiteRedirectLocation = "https://google.com").ConfigureAwait(false);

        Assert.Equal(200, putResp.StatusCode);

        HeadObjectResponse headResp = await client.HeadObjectAsync(bucket, nameof(HeadObjectWebsiteRedirect)).ConfigureAwait(false);

        Assert.Equal(200, headResp.StatusCode);
        Assert.Equal("https://google.com", headResp.WebsiteRedirectLocation);
    }
Ejemplo n.º 26
0
    public async Task PutObjectCacheControl(S3Provider _, string bucket, ISimpleClient client)
    {
        PutObjectResponse putResp = await client.PutObjectAsync(bucket, nameof(PutObjectCacheControl), null, r => r.CacheControl.Set(CacheControlType.MaxAge, 100)).ConfigureAwait(false);

        Assert.Equal(200, putResp.StatusCode);

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

        Assert.Equal(200, getResp.StatusCode);
        Assert.Equal("max-age=100", getResp.CacheControl);
    }
Ejemplo n.º 27
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);
    }
Ejemplo n.º 28
0
    public async Task CreateBucket(S3Provider _, string __, ISimpleClient client)
    {
        string tempBucketName = GetTemporaryBucket();

        CreateBucketResponse resp = await client.CreateBucketAsync(tempBucketName).ConfigureAwait(false);

        Assert.True(resp.IsSuccess);

        //Delete again to cleanup
        await client.DeleteBucketAsync(tempBucketName).ConfigureAwait(false);
    }
Ejemplo n.º 29
0
    public async Task Restore(S3Provider _, string bucket, ISimpleClient client)
    {
        //Upload an object to glacier
        PutObjectResponse putResp = await client.PutObjectAsync(bucket, nameof(Restore), null, r => r.StorageClass = StorageClass.Glacier).ConfigureAwait(false);

        Assert.Equal(StorageClass.Glacier, putResp.StorageClass);

        RestoreObjectResponse restoreResp = await client.RestoreObjectAsync(bucket, nameof(Restore), r => r.Days = 2).ConfigureAwait(false);

        Assert.Equal(202, restoreResp.StatusCode);
    }
Ejemplo n.º 30
0
    public async Task HeadObjectMultipleTags(S3Provider _, string bucket, ISimpleClient client)
    {
        await client.PutObjectAsync(bucket, nameof(HeadObjectMultipleTags), null, r =>
        {
            r.Tags.Add("mykey1", "myvalue1");
            r.Tags.Add("mykey2", "myvalue2");
        }).ConfigureAwait(false);

        HeadObjectResponse resp = await client.HeadObjectAsync(bucket, nameof(HeadObjectMultipleTags)).ConfigureAwait(false);

        Assert.Equal(2, resp.TagCount);
    }