Skip to content

Commit 4d0fd4e

Browse files
authored
Merge pull request GoogleCloudPlatform#960 from GoogleCloudPlatform/fix-hmac-sample
[Storage] Fix metadata HMAC list sample
2 parents fccb192 + 851d109 commit 4d0fd4e

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

storage/src/list_hmac_keys.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ function list_hmac_keys($projectId)
3838
// By default hmacKeys will use the projectId used by StorageClient() to list HMAC Keys.
3939
$hmacKeys = $storage->hmacKeys(['projectId' => $projectId]);
4040

41+
printf('HMAC Key\'s:' . PHP_EOL);
4142
foreach ($hmacKeys as $hmacKey) {
42-
printf('HMAC key Metadata: %s' . PHP_EOL, print_r($hmacKey->info(), true));
43+
printf('Service Account Email: %s' . PHP_EOL, $hmacKey->info()['serviceAccountEmail']);
44+
printf('Access Id: %s' . PHP_EOL, $hmacKey->info()['accessId']);
4345
}
4446
}
4547
# [END storage_list_hmac_keys]

storage/test/HmacCommandTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function testHmacKeyList()
7878
'projectId' => self::$projectId
7979
],
8080
['interactive' => false]);
81-
$this->assertContains("HMAC key Metadata:", $this->getActualOutput());
81+
$this->assertContains('HMAC Key\'s:', $this->getActualOutput());
8282
}
8383

8484
public function testHmacKeyCreate()
@@ -89,7 +89,7 @@ public function testHmacKeyCreate()
8989
'serviceAccountEmail' => $this->hmacServiceAccount
9090
],
9191
['interactive' => false]);
92-
$this->assertContains("The base64 encoded secret is:", $this->getActualOutput());
92+
$this->assertContains('The base64 encoded secret is:', $this->getActualOutput());
9393
}
9494

9595
public function testHmacKeyGet()
@@ -101,7 +101,7 @@ public function testHmacKeyGet()
101101
'--get' => true
102102
],
103103
['interactive' => false]);
104-
$this->assertContains("HMAC key Metadata:", $this->getActualOutput());
104+
$this->assertContains('HMAC key Metadata:', $this->getActualOutput());
105105
}
106106

107107
public function testHmacKeyDeactivate()
@@ -113,7 +113,7 @@ public function testHmacKeyDeactivate()
113113
'--deactivate' => true
114114
],
115115
['interactive' => false]);
116-
$this->assertContains("The HMAC key is now inactive", $this->getActualOutput());
116+
$this->assertContains('The HMAC key is now inactive', $this->getActualOutput());
117117
}
118118

119119
public function testHmacKeyActivate()
@@ -132,7 +132,7 @@ public function testHmacKeyActivate()
132132
'--activate' => true
133133
],
134134
['interactive' => false]);
135-
$this->assertContains("The HMAC key is now active", $this->getActualOutput());
135+
$this->assertContains('The HMAC key is now active', $this->getActualOutput());
136136
}
137137

138138
public function testHmacKeyDelete()
@@ -151,6 +151,6 @@ public function testHmacKeyDelete()
151151
'--delete' => true
152152
],
153153
['interactive' => false]);
154-
$this->assertContains("The key is deleted,", $this->getActualOutput());
154+
$this->assertContains('The key is deleted,', $this->getActualOutput());
155155
}
156156
}

0 commit comments

Comments
 (0)