public void ListBuckets() { CreateBucketSample createBucketSample = new CreateBucketSample(); ListBucketsSample listBucketsSample = new ListBucketsSample(); var bucketName = Guid.NewGuid().ToString(); _bucketFixture.CreateBucket(bucketName); var buckets = listBucketsSample.ListBuckets(_bucketFixture.ProjectId); Assert.Contains(buckets, c => c.Name == bucketName); }
public void LockRetentionPolicy() { SetRetentionPolicySample setRetentionPolicySample = new SetRetentionPolicySample(); LockRetentionPolicySample lockRetentionPolicySample = new LockRetentionPolicySample(); var bucketName = Guid.NewGuid().ToString(); _bucketFixture.CreateBucket(bucketName); setRetentionPolicySample.SetRetentionPolicy(bucketName, 10); var result = lockRetentionPolicySample.LockRetentionPolicy(bucketName); Assert.True(result); }
public void TestSetPublicAccessPreventionUnspecified() { SetPublicAccessPreventionUnspecifiedSample setPublicAccessPreventionUnspecifiedSample = new SetPublicAccessPreventionUnspecifiedSample(); var bucketName = Guid.NewGuid().ToString(); // Create bucket _bucketFixture.CreateBucket(bucketName); // Set public access prevention to unspecified. var updatedBucket = setPublicAccessPreventionUnspecifiedSample.SetPublicAccessPreventionUnspecified(bucketName); _bucketFixture.SleepAfterBucketCreateUpdateDelete(); Assert.Equal("unspecified", updatedBucket.IamConfiguration.PublicAccessPrevention); }
public void TestEnableUniformBucketLevelAccess() { EnableUniformBucketLevelAccessSample enableUniformBucketLevelAccessSample = new EnableUniformBucketLevelAccessSample(); var bucketName = Guid.NewGuid().ToString(); // Create bucket _bucketFixture.CreateBucket(bucketName); // Enable Uniform bucket level access. var updatedBucket = enableUniformBucketLevelAccessSample.EnableUniformBucketLevelAccess(bucketName); _bucketFixture.SleepAfterBucketCreateUpdateDelete(); Assert.True(updatedBucket.IamConfiguration.UniformBucketLevelAccess.Enabled); }
public void TestGetUniformBucketLevelAccess() { EnableUniformBucketLevelAccessSample enableUniformBucketLevelAccessSample = new EnableUniformBucketLevelAccessSample(); GetUniformBucketLevelAccessSample getUniformBucketLevelAccessSample = new GetUniformBucketLevelAccessSample(); var bucketName = Guid.NewGuid().ToString(); // Create bucket _bucketFixture.CreateBucket(bucketName); // Enable Uniform bucket level access. enableUniformBucketLevelAccessSample.EnableUniformBucketLevelAccess(bucketName); _bucketFixture.SleepAfterBucketCreateUpdateDelete(); var uniformBucketLevelAccess = getUniformBucketLevelAccessSample.GetUniformBucketLevelAccess(bucketName); Assert.True(uniformBucketLevelAccess.Enabled); }
public void TestGetPublicAccessPrevention() { GetPublicAccessPreventionSample getPublicAccessPreventionSample = new GetPublicAccessPreventionSample(); var bucketName = Guid.NewGuid().ToString(); // Create bucket _bucketFixture.CreateBucket(bucketName); // Set public access prevention to enforced. SetPublicAccessPreventionEnforcedSample setPublicAccessPreventionEnforcedSample = new SetPublicAccessPreventionEnforcedSample(); setPublicAccessPreventionEnforcedSample.SetPublicAccessPreventionEnforced(bucketName); _bucketFixture.SleepAfterBucketCreateUpdateDelete(); var publicAccessPrevention = getPublicAccessPreventionSample.GetPublicAccessPrevention(bucketName); Assert.Equal("enforced", publicAccessPrevention); }
public void TestEnableRequesterPays() { EnableRequesterPaysSample enableRequesterPaysSample = new EnableRequesterPaysSample(); DisableRequesterPaysSample disableRequesterPaysSample = new DisableRequesterPaysSample(); var bucketName = Guid.NewGuid().ToString(); // Create bucket _bucketFixture.CreateBucket(bucketName); // Enable request pay. var bucket = enableRequesterPaysSample.EnableRequesterPays(bucketName); _bucketFixture.SleepAfterBucketCreateUpdateDelete(); Assert.True(bucket.Billing?.RequesterPays); // Disable request pay. disableRequesterPaysSample.DisableRequesterPays(_bucketFixture.ProjectId, bucketName); _bucketFixture.SleepAfterBucketCreateUpdateDelete(); }
public void TestAddBucketConditionalIamBinding() { AddBucketConditionalIamBindingSample addBucketConditionalIamBindingSample = new AddBucketConditionalIamBindingSample(); EnableUniformBucketLevelAccessSample enableUniformBucketLevelAccessSample = new EnableUniformBucketLevelAccessSample(); var bucketName = Guid.NewGuid().ToString(); string memberType = "serviceAccount"; string role = "roles/storage.objectViewer"; // Create bucket _bucketFixture.CreateBucket(bucketName); // Enable Uniform bucket level access. enableUniformBucketLevelAccessSample.EnableUniformBucketLevelAccess(bucketName); _bucketFixture.SleepAfterBucketCreateUpdateDelete(); // Add Conditional Binding. var policy = addBucketConditionalIamBindingSample.AddBucketConditionalIamBinding(bucketName, role, $"{memberType}:{_bucketFixture.ServiceAccountEmail}", "title", "description", "resource.name.startsWith(\"projects/_/buckets/bucket-name/objects/prefix-a-\")"); _bucketFixture.SleepAfterBucketCreateUpdateDelete(); Assert.Contains(policy.Bindings, c => c.Members.Contains($"{memberType}:{_bucketFixture.ServiceAccountEmail}")); }