Search in sources :

Example 46 with SecretName

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");
}
Also used : SecretName(com.google.cloud.secretmanager.v1.SecretName) Test(org.junit.Test)

Example 47 with SecretName

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);
    }
}
Also used : SecretName(com.google.cloud.secretmanager.v1.SecretName) AddSecretVersionRequest(com.google.cloud.secretmanager.v1.AddSecretVersionRequest) SecretManagerServiceClient(com.google.cloud.secretmanager.v1.SecretManagerServiceClient)

Example 48 with SecretName

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());
}
Also used : SecretName(com.google.cloud.secretmanager.v1.SecretName) Test(org.junit.Test)

Example 49 with SecretName

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");
}
Also used : SecretName(com.google.cloud.secretmanager.v1.SecretName) Test(org.junit.Test)

Example 50 with SecretName

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");
}
Also used : SecretName(com.google.cloud.secretmanager.v1.SecretName) Test(org.junit.Test)

Aggregations

SecretName (com.google.cloud.secretmanager.v1.SecretName)53 SecretManagerServiceClient (com.google.cloud.secretmanager.v1.SecretManagerServiceClient)23 Test (org.junit.Test)22 DeleteSecretRequest (com.google.cloud.secretmanager.v1.DeleteSecretRequest)8 SecretVersion (com.google.cloud.secretmanager.v1.SecretVersion)6 Secret (com.google.cloud.secretmanager.v1.Secret)5 SecretPayload (com.google.cloud.secretmanager.v1.SecretPayload)5 AddSecretVersionRequest (com.google.cloud.secretmanager.v1.AddSecretVersionRequest)4 ListSecretVersionsPagedResponse (com.google.cloud.secretmanager.v1.SecretManagerServiceClient.ListSecretVersionsPagedResponse)4 Binding (com.google.iam.v1.Binding)4 Policy (com.google.iam.v1.Policy)4 FieldMask (com.google.protobuf.FieldMask)3 AfterClass (org.junit.AfterClass)3 ListSecretVersionsRequest (com.google.cloud.secretmanager.v1.ListSecretVersionsRequest)2 AccessSecretVersionResponse (com.google.cloud.secretmanager.v1.AccessSecretVersionResponse)1 SecretVersionName (com.google.cloud.secretmanager.v1.SecretVersionName)1 AbstractMessage (com.google.protobuf.AbstractMessage)1 ByteString (com.google.protobuf.ByteString)1 EventListener (io.micronaut.runtime.event.annotation.EventListener)1 ArrayList (java.util.ArrayList)1