Skip to content

Commit 36203bb

Browse files
Improved readme and created new secret specific for deleting annotations
1 parent e337c21 commit 36203bb

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

secretmanager/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ the Secret Manager API using the Google Java API Client Libraries.
1212

1313
### Enable the API
1414

15-
You must [enable the Secret Manager API](https://console.cloud.google.com/flows/enableapi?apiid=secretmanager.googleapis.com) for your project in order to use these samples
15+
You must enable the [Secret Manager API](https://console.cloud.google.com/flows/enableapi?apiid=secretmanager.googleapis.com) and [Cloud KMS API](https://console.cloud.google.com/flows/enableapi?apiid=cloudkms.googleapis.com) for your project in order to use these samples
1616

1717
### Set Environment Variables
1818

@@ -30,5 +30,6 @@ You must ensure that the [user account or service account](https://cloud.google.
3030

3131
* Secret Manager Admin (`roles/secretmanager.admin`)
3232
* Secret Manager Secret Accessor (`roles/secretmanager.secretAccessor`)
33+
* Cloud KMS Encrypter / Decrypter (`roles/cloudkms.cryptoKeyEncrypterDecrypter`) on the regional and global KMS key used for testing
3334

3435
More information can be found in the [Secret Manager Docs](https://cloud.google.com/secret-manager/docs/access-control)

secretmanager/src/test/java/secretmanager/SnippetsIT.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public class SnippetsIT {
9292
private static Secret TEST_SECRET;
9393
private static Secret TEST_SECRET_TO_DELETE;
9494
private static Secret TEST_SECRET_TO_DELETE_WITH_ETAG;
95+
private static Secret TEST_SECRET_TO_DELETE_ANNOTATIONS;
9596
private static Secret TEST_SECRET_TO_DELAYED_DESTROY;
9697
private static Secret TEST_SECRET_WITH_VERSIONS;
9798
private static SecretName TEST_SECRET_WITH_DELAYED_DESTROY;
@@ -121,6 +122,7 @@ public static void beforeAll() throws Exception {
121122
TEST_SECRET = createSecret(true);
122123
TEST_SECRET_TO_DELETE = createSecret(false);
123124
TEST_SECRET_TO_DELETE_WITH_ETAG = createSecret(false);
125+
TEST_SECRET_TO_DELETE_ANNOTATIONS = createSecret(true);
124126
TEST_SECRET_WITH_VERSIONS = createSecret(false);
125127
TEST_SECRET_TO_DELAYED_DESTROY = createSecret(false);
126128
TEST_SECRET_WITH_DELAYED_DESTROY = SecretName.of(PROJECT_ID, randomSecretId());
@@ -170,6 +172,7 @@ public static void afterAll() throws Exception {
170172
deleteSecret(TEST_UMMR_SECRET_TO_CREATE_NAME.toString());
171173
deleteSecret(TEST_SECRET_TO_DELETE.getName());
172174
deleteSecret(TEST_SECRET_TO_DELETE_WITH_ETAG.getName());
175+
deleteSecret(TEST_SECRET_TO_DELETE_ANNOTATIONS.getName());
173176
deleteSecret(TEST_SECRET_WITH_VERSIONS.getName());
174177
deleteSecret(TEST_SECRET_WITH_DELAYED_DESTROY.toString());
175178
deleteSecret(TEST_SECRET_TO_DELAYED_DESTROY.getName());
@@ -600,7 +603,7 @@ public void testEditSecretAnnotations() throws IOException {
600603

601604
@Test
602605
public void testDeleteSecretAnnotations() throws IOException {
603-
SecretName name = SecretName.parse(TEST_SECRET.getName());
606+
SecretName name = SecretName.parse(TEST_SECRET_TO_DELETE_ANNOTATIONS.getName());
604607
Secret updatedSecret =
605608
DeleteSecretAnnotations.deleteSecretAnnotations(name.getProject(), name.getSecret());
606609

secretmanager/src/test/java/secretmanager/regionalsamples/SnippetsIT.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public class SnippetsIT {
100100
private static Secret TEST_REGIONAL_SECRET;
101101
private static Secret TEST_REGIONAL_SECRET_TO_DELETE;
102102
private static Secret TEST_REGIONAL_SECRET_TO_DELETE_WITH_ETAG;
103+
private static Secret TEST_REGIONAL_SECRET_TO_DELETE_ANNOTATIONS;
103104
private static Secret TEST_REGIONAL_SECRET_WITH_VERSIONS;
104105
private static Secret TEST_REGIONAL_SECRET_TO_DELAYED_DESTROY;
105106
private static SecretName TEST_REGIONAL_SECRET_WITH_DELAYED_DESTROY;
@@ -132,6 +133,7 @@ public static void beforeAll() throws Exception {
132133
TEST_REGIONAL_SECRET = createRegionalSecret();
133134
TEST_REGIONAL_SECRET_TO_DELETE = createRegionalSecret();
134135
TEST_REGIONAL_SECRET_TO_DELETE_WITH_ETAG = createRegionalSecret();
136+
TEST_REGIONAL_SECRET_TO_DELETE_ANNOTATIONS = createRegionalSecret();
135137
TEST_REGIONAL_SECRET_WITH_VERSIONS = createRegionalSecret();
136138
TEST_REGIONAL_SECRET_TO_DELAYED_DESTROY = createRegionalSecret();
137139
TEST_REGIONAL_SECRET_WITH_DELAYED_DESTROY =
@@ -190,6 +192,7 @@ public static void afterAll() throws Exception {
190192
deleteRegionalSecret(TEST_REGIONAL_SECRET_WITH_CMEK_TO_CREATE_NAME.toString());
191193
deleteRegionalSecret(TEST_REGIONAL_SECRET_TO_DELETE.getName());
192194
deleteRegionalSecret(TEST_REGIONAL_SECRET_TO_DELETE_WITH_ETAG.getName());
195+
deleteRegionalSecret(TEST_REGIONAL_SECRET_TO_DELETE_ANNOTATIONS.getName());
193196
deleteRegionalSecret(TEST_REGIONAL_SECRET_WITH_VERSIONS.getName());
194197
deleteRegionalSecret(TEST_REGIONAL_SECRET_WITH_DELAYED_DESTROY.toString());
195198
deleteRegionalSecret(TEST_REGIONAL_SECRET_TO_DELAYED_DESTROY.getName());
@@ -703,7 +706,7 @@ public void testEditSecretAnnotations() throws IOException {
703706

704707
@Test
705708
public void testDeleteRegionalSecretAnnotations() throws IOException {
706-
SecretName name = SecretName.parse(TEST_REGIONAL_SECRET.getName());
709+
SecretName name = SecretName.parse(TEST_REGIONAL_SECRET_TO_DELETE_ANNOTATIONS.getName());
707710
Secret updatedSecret = DeleteRegionalSecretAnnotations.deleteRegionalSecretAnnotations(
708711
name.getProject(), name.getLocation(), name.getSecret());
709712

0 commit comments

Comments
 (0)