Skip to content

Commit

Permalink
feat: support uniform bucket-level access
Browse files Browse the repository at this point in the history
  • Loading branch information
frankyn authored and JesseLovelace committed Oct 25, 2019
1 parent da6f263 commit 441df9c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
10 changes: 6 additions & 4 deletions Storage/src/Bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -851,14 +851,16 @@ public function delete(array $options = [])
* that objects need to be retained, in seconds. Retention
* duration must be greater than zero and less than 100 years.
* @type array $iamConfiguration The bucket's IAM configuration.
* @type bool $iamConfiguration.bucketPolicyOnly.enabled If set and
* @type bool $iamConfiguration.bucketPolicyOnly.enabled this is an alias
* for $iamConfiguration.uniformBucketLevelAccess.
* @type bool $iamConfiguration.uniformBucketLevelAccess.enabled If set and
* true, access checks only use bucket-level IAM policies or
* above. When enabled, requests attempting to view or manipulate
* ACLs will fail with error code 400. **NOTE**: Before using
* Bucket Policy Only, please review the
* [feature documentation](https://cloud.google.com/storage/docs/bucket-policy-only),
* Uniform bucket-level access, please review the
* [feature documentation](https://cloud.google.com/storage/docs/uniform-bucket-level-access),
* as well as
* [Should You Use Bucket Policy Only](https://cloud.google.com/storage/docs/bucket-policy-only#should-you-use)
* [Should You Use uniform bucket-level access](https://cloud.google.com/storage/docs/uniform-bucket-level-access#should-you-use)
* }
* @codingStandardsIgnoreEnd
* @return array
Expand Down
10 changes: 6 additions & 4 deletions Storage/src/StorageClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,16 @@ function (array $bucket) use ($userProject) {
* object cannot be overwritten or deleted. Retention period must
* be greater than zero and less than 100 years.
* @type array $iamConfiguration The bucket's IAM configuration.
* @type bool $iamConfiguration.bucketPolicyOnly.enabled If set and
* @type bool $iamConfiguration.bucketPolicyOnly.enabled this is an alias
* for $iamConfiguration.uniformBucketLevelAccess.
* @type bool $iamConfiguration.uniformBucketLevelAccess.enabled If set and
* true, access checks only use bucket-level IAM policies or
* above. When enabled, requests attempting to view or manipulate
* ACLs will fail with error code 400. **NOTE**: Before using
* Bucket Policy Only, please review the
* [feature documentation](https://cloud.google.com/storage/docs/bucket-policy-only),
* Uniform bucket-level access, please review the
* [feature documentation](https://cloud.google.com/storage/docs/uniform-bucket-level-access),
* as well as
* [Should You Use Bucket Policy Only](https://cloud.google.com/storage/docs/bucket-policy-only#should-you-use)
* [Should You Use uniform bucket-level access](https://cloud.google.com/storage/docs/uniform-bucket-level-access#should-you-use)
* }
* @codingStandardsIgnoreEnd
* @return Bucket
Expand Down
12 changes: 6 additions & 6 deletions Storage/tests/System/IamConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ public function setUp()
$this->guzzle = new Client;
}

public function testBucketPolicyOnly()
public function testUniformBucketLevelAccess()
{
$bucket = self::createBucket(self::$client, uniqid(self::TESTING_PREFIX));
$bucket->update($this->bucketConfig());

$this->assertTrue($bucket->info()['iamConfiguration']['bucketPolicyOnly']['enabled']);
$this->assertTrue($bucket->info()['iamConfiguration']['uniformBucketLevelAccess']['enabled']);

$bucket->update($this->bucketConfig(false));

$this->assertFalse($bucket->info()['iamConfiguration']['bucketPolicyOnly']['enabled']);
$this->assertFalse($bucket->info()['iamConfiguration']['uniformBucketLevelAccess']['enabled']);
}

/**
* @expectedException Google\Cloud\Core\Exception\BadRequestException
*/
public function testBucketPolicyOnlyAclFails()
public function testUniformBucketLevelAccessAclFails()
{
$bucket = self::createBucket(self::$client, uniqid(self::TESTING_PREFIX));
$bucket->update($this->bucketConfig());
Expand Down Expand Up @@ -100,7 +100,7 @@ public function testObjectPolicyOnlyAclFails()
$object->acl()->get();
}

public function testCreateBucketWithBucketPolicyOnlyAndInsertObject()
public function testCreateBucketWithUniformBucketLevelAccessAndInsertObject()
{
$bucket = self::createBucket(self::$client, uniqid(self::TESTING_PREFIX), $this->bucketConfig());

Expand All @@ -116,7 +116,7 @@ private function bucketConfig($enabled = true)
{
return [
'iamConfiguration' => [
'bucketPolicyOnly' => [
'uniformBucketLevelAccess' => [
'enabled' => $enabled
]
]
Expand Down

0 comments on commit 441df9c

Please sign in to comment.