public void GetBucketMetadata()
    {
        var getBucketMetadataSample = new GetBucketMetadataSample();
        var bucket = getBucketMetadataSample.GetBucketMetadata(_bucketFixture.BucketNameGeneric);

        Assert.NotNull(bucket);
    }
    public void CreateBucket()
    {
        CreateBucketSample      createBucketSample      = new CreateBucketSample();
        GetBucketMetadataSample getBucketMetadataSample = new GetBucketMetadataSample();
        var bucketName = Guid.NewGuid().ToString();

        createBucketSample.CreateBucket(_bucketFixture.ProjectId, bucketName);
        _bucketFixture.SleepAfterBucketCreateUpdateDelete();
        _bucketFixture.TempBucketNames.Add(bucketName);

        var metadata = getBucketMetadataSample.GetBucketMetadata(bucketName);

        Assert.NotNull(metadata);
    }
示例#3
0
    public void DeleteBucket()
    {
        DeleteBucketSample      deleteBucketSample      = new DeleteBucketSample();
        CreateBucketSample      createBucketSample      = new CreateBucketSample();
        GetBucketMetadataSample getBucketMetadataSample = new GetBucketMetadataSample();
        var bucketName = Guid.NewGuid().ToString();

        createBucketSample.CreateBucket(_fixture.ProjectId, bucketName);
        _fixture.SleepAfterBucketCreateUpdateDelete();

        deleteBucketSample.DeleteBucket(bucketName);
        _fixture.SleepAfterBucketCreateUpdateDelete();

        var exception = Assert.Throws <GoogleApiException>(() => getBucketMetadataSample.GetBucketMetadata(bucketName));

        Assert.Equal(System.Net.HttpStatusCode.NotFound, exception.HttpStatusCode);
    }
    public void TestRemoveBucketOwner()
    {
        AddBucketOwnerSample    addBucketOwnerSample    = new AddBucketOwnerSample();
        RemoveBucketOwnerSample removeBucketOwnerSample = new RemoveBucketOwnerSample();
        GetBucketMetadataSample getBucketMetadataSample = new GetBucketMetadataSample();

        // Add bucket owner.
        addBucketOwnerSample.AddBucketOwner(_bucketFixture.BucketNameGeneric, _bucketFixture.ServiceAccountEmail);
        _bucketFixture.SleepAfterBucketCreateUpdateDelete();

        // Remove bucket owner.
        removeBucketOwnerSample.RemoveBucketOwner(_bucketFixture.BucketNameGeneric, _bucketFixture.ServiceAccountEmail);
        _bucketFixture.SleepAfterBucketCreateUpdateDelete();

        // Get bucket metadata.
        var bucketMetadata = getBucketMetadataSample.GetBucketMetadata(_bucketFixture.BucketNameGeneric);

        Assert.DoesNotContain(bucketMetadata.Acl, acl => acl.Role == "OWNER" && acl.Email == _bucketFixture.ServiceAccountEmail);
    }
    public void BucketDeleteDefaultKmsKey()
    {
        EnableDefaultKMSKeySample       enableDefaultKMSKeySample       = new EnableDefaultKMSKeySample();
        GetBucketMetadataSample         getBucketMetadataSample         = new GetBucketMetadataSample();
        BucketDeleteDefaultKmsKeySample bucketDeleteDefaultKmsKeySample = new BucketDeleteDefaultKmsKeySample();

        // Set default key
        enableDefaultKMSKeySample.EnableDefaultKMSKey(_fixture.ProjectId, _fixture.BucketNameRegional,
                                                      _fixture.KmsKeyLocation, _fixture.KmsKeyRing, _fixture.KmsKeyName);
        _fixture.SleepAfterBucketCreateUpdateDelete();

        // Remove default key
        bucketDeleteDefaultKmsKeySample.BucketDeleteDefaultKmsKey(_fixture.BucketNameRegional);
        _fixture.SleepAfterBucketCreateUpdateDelete();

        // Verify removal
        var bucketMetadata = getBucketMetadataSample.GetBucketMetadata(_fixture.BucketNameRegional);

        Assert.Null(bucketMetadata.Encryption?.DefaultKmsKeyName);
    }