use of com.google.cloud.secretmanager.v1.Secret in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method testListSecretsWithFilter.
@Test
public void testListSecretsWithFilter() throws IOException {
SecretName name = SecretName.parse(TEST_SECRET.getName());
ListSecretsWithFilter.listSecrets(name.getProject(), String.format("name:%s", name.getSecret()));
assertThat(stdOut.toString()).contains("Secret projects/");
assertThat(stdOut.toString()).contains(name.getSecret());
}
use of com.google.cloud.secretmanager.v1.Secret in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method testDisableSecretVersion.
@Test
public void testDisableSecretVersion() throws IOException {
SecretVersionName name = SecretVersionName.parse(TEST_SECRET_VERSION_TO_DISABLE.getName());
DisableSecretVersion.disableSecretVersion(name.getProject(), name.getSecret(), name.getSecretVersion());
assertThat(stdOut.toString()).contains("Disabled secret version");
}
use of com.google.cloud.secretmanager.v1.Secret in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method createSecret.
private static Secret createSecret() throws IOException {
ProjectName parent = ProjectName.of(PROJECT_ID);
CreateSecretRequest request = CreateSecretRequest.newBuilder().setParent(parent.toString()).setSecretId(randomSecretId()).setSecret(Secret.newBuilder().setReplication(Replication.newBuilder().setAutomatic(Replication.Automatic.newBuilder().build()).build()).build()).build();
try (SecretManagerServiceClient client = SecretManagerServiceClient.create()) {
return client.createSecret(request);
}
}
use of com.google.cloud.secretmanager.v1.Secret in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method testGetSecret.
@Test
public void testGetSecret() throws IOException {
SecretName name = SecretName.parse(TEST_SECRET.getName());
GetSecret.getSecret(name.getProject(), name.getSecret());
assertThat(stdOut.toString()).contains("Secret");
assertThat(stdOut.toString()).contains("replication AUTOMATIC");
}
use of com.google.cloud.secretmanager.v1.Secret in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method testDestroySecretVersion.
@Test
public void testDestroySecretVersion() throws IOException {
SecretVersionName name = SecretVersionName.parse(TEST_SECRET_VERSION_TO_DESTROY.getName());
DestroySecretVersion.destroySecretVersion(name.getProject(), name.getSecret(), name.getSecretVersion());
assertThat(stdOut.toString()).contains("Destroyed secret version");
}
Aggregations