|
18 | 18 |
|
19 | 19 | namespace Google\Cloud\Samples\Storage; |
20 | 20 |
|
| 21 | +use Google\Auth\CredentialsLoader; |
21 | 22 | use Google\Cloud\Storage\StorageClient; |
22 | 23 | use Google\Cloud\TestUtils\TestTrait; |
23 | 24 | use Google\Cloud\TestUtils\ExecuteCommandTrait; |
@@ -64,41 +65,43 @@ public function testBucketAcl() |
64 | 65 |
|
65 | 66 | public function testManageBucketAcl() |
66 | 67 | { |
| 68 | + $jsonKey = CredentialsLoader::fromEnv(); |
67 | 69 | $acl = self::$tempBucket->acl(); |
| 70 | + $entity = sprintf('user-%s', $jsonKey['client_email']); |
68 | 71 | $bucketUrl = sprintf('gs://%s', self::$tempBucket->name()); |
69 | 72 |
|
70 | 73 | $output = $this->runCommand('bucket-acl', [ |
71 | 74 | 'bucket' => self::$tempBucket->name(), |
72 | | - '--entity' => 'allAuthenticatedUsers', |
| 75 | + '--entity' => $entity, |
73 | 76 | '--create' => true, |
74 | 77 | ]); |
75 | 78 |
|
76 | | - $expected = "Added allAuthenticatedUsers (READER) to $bucketUrl ACL\n"; |
| 79 | + $expected = "Added $entity (READER) to $bucketUrl ACL\n"; |
77 | 80 | $this->assertEquals($expected, $output); |
78 | 81 |
|
79 | | - $aclInfo = $acl->get(['entity' => 'allAuthenticatedUsers']); |
| 82 | + $aclInfo = $acl->get(['entity' => $entity]); |
80 | 83 | $this->assertArrayHasKey('role', $aclInfo); |
81 | 84 | $this->assertEquals('READER', $aclInfo['role']); |
82 | 85 |
|
83 | 86 | $output = $this->runCommand('bucket-acl', [ |
84 | 87 | 'bucket' => self::$tempBucket->name(), |
85 | | - '--entity' => 'allAuthenticatedUsers', |
| 88 | + '--entity' => $entity, |
86 | 89 | ]); |
87 | 90 |
|
88 | | - $expected = "allAuthenticatedUsers: READER\n"; |
| 91 | + $expected = "$entity: READER\n"; |
89 | 92 | $this->assertEquals($expected, $output); |
90 | 93 |
|
91 | 94 | $output = $this->runCommand('bucket-acl', [ |
92 | 95 | 'bucket' => self::$tempBucket->name(), |
93 | | - '--entity' => 'allAuthenticatedUsers', |
| 96 | + '--entity' => $entity, |
94 | 97 | '--delete' => true, |
95 | 98 | ]); |
96 | 99 |
|
97 | | - $expected = "Deleted allAuthenticatedUsers from $bucketUrl ACL\n"; |
| 100 | + $expected = "Deleted $entity from $bucketUrl ACL\n"; |
98 | 101 | $this->assertEquals($expected, $output); |
99 | 102 |
|
100 | 103 | try { |
101 | | - $acl->get(['entity' => 'allAuthenticatedUsers']); |
| 104 | + $acl->get(['entity' => $entity]); |
102 | 105 | $this->fail(); |
103 | 106 | } catch (NotFoundException $e) { |
104 | 107 | $this->assertTrue(true); |
|
0 commit comments