use of com.google.cloud.secretmanager.v1.SecretName in project java-secretmanager by googleapis.
the class SnippetsIT method testCreateSecret.
@Test
public void testCreateSecret() throws IOException {
SecretName name = TEST_SECRET_TO_CREATE_NAME;
new CreateSecret().createSecret(name.getProject(), name.getSecret());
assertThat(stdOut.toString()).contains("Created secret");
}
use of com.google.cloud.secretmanager.v1.SecretName in project java-secretmanager by googleapis.
the class SnippetsIT method addSecretVersion.
private static SecretVersion addSecretVersion(Secret secret) throws IOException {
SecretName parent = SecretName.parse(secret.getName());
AddSecretVersionRequest request = AddSecretVersionRequest.newBuilder().setParent(parent.toString()).setPayload(SecretPayload.newBuilder().setData(ByteString.copyFromUtf8("my super secret data")).build()).build();
try (SecretManagerServiceClient client = SecretManagerServiceClient.create()) {
return client.addSecretVersion(request);
}
}
use of com.google.cloud.secretmanager.v1.SecretName in project java-secretmanager by googleapis.
the class SnippetsIT method testListSecrets.
@Test
public void testListSecrets() throws IOException {
SecretName name = SecretName.parse(TEST_SECRET.getName());
new ListSecrets().listSecrets(name.getProject());
assertThat(stdOut.toString()).contains("Secret projects/");
assertThat(stdOut.toString()).contains(name.getSecret());
}
use of com.google.cloud.secretmanager.v1.SecretName in project java-secretmanager by googleapis.
the class SnippetsIT method testIamGrantAccess.
@Test
public void testIamGrantAccess() throws IOException {
SecretName name = SecretName.parse(TEST_SECRET.getName());
new IamGrantAccess().iamGrantAccess(name.getProject(), name.getSecret(), IAM_USER);
assertThat(stdOut.toString()).contains("Updated IAM policy");
}
use of com.google.cloud.secretmanager.v1.SecretName in project java-secretmanager by googleapis.
the class SnippetsIT method testIamRevokeAccess.
@Test
public void testIamRevokeAccess() throws IOException {
SecretName name = SecretName.parse(TEST_SECRET.getName());
new IamRevokeAccess().iamRevokeAccess(name.getProject(), name.getSecret(), IAM_USER);
assertThat(stdOut.toString()).contains("Updated IAM policy");
}
Aggregations