Exemplo n.º 1
0
    public void TestAddBucketDefaultOwner()
    {
        AddBucketDefaultOwnerSample    addBucketDefaultOwnerSample    = new AddBucketDefaultOwnerSample();
        RemoveBucketDefaultOwnerSample removeBucketDefaultOwnerSample = new RemoveBucketDefaultOwnerSample();

        // Add bucket default owner.
        var updatedBucket = addBucketDefaultOwnerSample.AddBucketDefaultOwner(_bucketFixture.BucketNameGeneric, _bucketFixture.ServiceAccountEmail);

        Assert.Contains(updatedBucket.DefaultObjectAcl, acl => acl.Role == "OWNER" && acl.Email == _bucketFixture.ServiceAccountEmail);
        _bucketFixture.SleepAfterBucketCreateUpdateDelete();

        // Remove bucket default owner.
        removeBucketDefaultOwnerSample.RemoveBucketDefaultOwner(_bucketFixture.BucketNameGeneric, _bucketFixture.ServiceAccountEmail);
        _bucketFixture.SleepAfterBucketCreateUpdateDelete();
    }
    public void TestRemoveBucketDefaultOwner()
    {
        AddBucketDefaultOwnerSample    addBucketDefaultOwnerSample    = new AddBucketDefaultOwnerSample();
        RemoveBucketDefaultOwnerSample removeBucketDefaultOwnerSample = new RemoveBucketDefaultOwnerSample();
        GetBucketMetadataSample        getBucketMetadataSample        = new GetBucketMetadataSample();

        // Add bucket default owner.
        addBucketDefaultOwnerSample.AddBucketDefaultOwner(_fixture.BucketNameGeneric, _fixture.ServiceAccountEmail);
        _fixture.SleepAfterBucketCreateUpdateDelete();

        // Remove bucket default owner.
        removeBucketDefaultOwnerSample.RemoveBucketDefaultOwner(_fixture.BucketNameGeneric, _fixture.ServiceAccountEmail);
        _fixture.SleepAfterBucketCreateUpdateDelete();

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

        Assert.DoesNotContain(metadata.DefaultObjectAcl, acl => acl.Email == _fixture.ServiceAccountEmail && acl.Role == "OWNER");
    }
    public void TestPrintBucketDefaultAcl()
    {
        PrintBucketDefaultAclSample    printBucketDefaultAclSample    = new PrintBucketDefaultAclSample();
        AddBucketDefaultOwnerSample    addBucketDefaultOwnerSample    = new AddBucketDefaultOwnerSample();
        RemoveBucketDefaultOwnerSample removeBucketDefaultOwnerSample = new RemoveBucketDefaultOwnerSample();
        string userEmail = _bucketFixture.ServiceAccountEmail;

        // add default owner
        addBucketDefaultOwnerSample.AddBucketDefaultOwner(_bucketFixture.BucketNameGeneric, userEmail);
        _bucketFixture.SleepAfterBucketCreateUpdateDelete();

        // print default owner
        var defaultBucketAcl = printBucketDefaultAclSample.PrintBucketDefaultAcl(_bucketFixture.BucketNameGeneric);

        Assert.Contains(defaultBucketAcl, c => c.Role == "OWNER" && c.Email == userEmail);

        // remove default owner
        removeBucketDefaultOwnerSample.RemoveBucketDefaultOwner(_bucketFixture.BucketNameGeneric, userEmail);
        _bucketFixture.SleepAfterBucketCreateUpdateDelete();
    }