Search in sources :

Example 1 with SecretVersionName

use of com.google.cloud.secretmanager.v1.SecretVersionName in project spring-cloud-gcp by spring-cloud.

the class SecretManagerTemplateTests method verifyEnableSecretVersionRequest.

private void verifyEnableSecretVersionRequest(String secretId, String version, String projectId) {
    SecretVersionName secretVersionName = SecretVersionName.newBuilder().setProject(projectId).setSecret(secretId).setSecretVersion(version).build();
    verify(this.client).enableSecretVersion(secretVersionName);
}
Also used : SecretVersionName(com.google.cloud.secretmanager.v1.SecretVersionName)

Example 2 with SecretVersionName

use of com.google.cloud.secretmanager.v1.SecretVersionName in project spring-cloud-gcp by spring-cloud.

the class SecretManagerTemplateTests method verifyDeleteSecretVersionRequest.

private void verifyDeleteSecretVersionRequest(String secretId, String version, String projectId) {
    SecretVersionName secretVersionName = SecretVersionName.newBuilder().setProject(projectId).setSecret(secretId).setSecretVersion(version).build();
    verify(this.client).destroySecretVersion(secretVersionName);
}
Also used : SecretVersionName(com.google.cloud.secretmanager.v1.SecretVersionName)

Example 3 with SecretVersionName

use of com.google.cloud.secretmanager.v1.SecretVersionName in project spring-cloud-gcp by spring-cloud.

the class SecretManagerTemplate method deleteSecretVersion.

@Override
public void deleteSecretVersion(String secretId, String version, String projectId) {
    SecretVersionName secretVersionName = SecretVersionName.newBuilder().setProject(projectId).setSecret(secretId).setSecretVersion(version).build();
    this.secretManagerServiceClient.destroySecretVersion(secretVersionName);
}
Also used : SecretVersionName(com.google.cloud.secretmanager.v1.SecretVersionName)

Example 4 with SecretVersionName

use of com.google.cloud.secretmanager.v1.SecretVersionName in project spring-cloud-gcp by spring-cloud.

the class SecretManagerPropertyUtilsTests method testLongProperty_projectSecret.

@Test
public void testLongProperty_projectSecret() {
    String property = "sm://projects/my-project/secrets/the-secret";
    SecretVersionName secretIdentifier = SecretManagerPropertyUtils.getSecretVersionName(property, DEFAULT_PROJECT_ID_PROVIDER);
    assertThat(secretIdentifier.getProject()).isEqualTo("my-project");
    assertThat(secretIdentifier.getSecret()).isEqualTo("the-secret");
    assertThat(secretIdentifier.getSecretVersion()).isEqualTo("latest");
}
Also used : SecretVersionName(com.google.cloud.secretmanager.v1.SecretVersionName) Test(org.junit.Test)

Example 5 with SecretVersionName

use of com.google.cloud.secretmanager.v1.SecretVersionName in project spring-cloud-gcp by spring-cloud.

the class SecretManagerPropertyUtilsTests method testShortProperty_projectSecretId.

@Test
public void testShortProperty_projectSecretId() {
    String property = "sm://the-secret/the-version";
    SecretVersionName secretIdentifier = SecretManagerPropertyUtils.getSecretVersionName(property, DEFAULT_PROJECT_ID_PROVIDER);
    assertThat(secretIdentifier.getProject()).isEqualTo("defaultProject");
    assertThat(secretIdentifier.getSecret()).isEqualTo("the-secret");
    assertThat(secretIdentifier.getSecretVersion()).isEqualTo("the-version");
}
Also used : SecretVersionName(com.google.cloud.secretmanager.v1.SecretVersionName) Test(org.junit.Test)

Aggregations

SecretVersionName (com.google.cloud.secretmanager.v1.SecretVersionName)53 Test (org.junit.Test)19 SecretManagerServiceClient (com.google.cloud.secretmanager.v1.SecretManagerServiceClient)13 SecretVersion (com.google.cloud.secretmanager.v1.SecretVersion)13 Test (org.junit.jupiter.api.Test)6 AccessSecretVersionResponse (com.google.cloud.secretmanager.v1.AccessSecretVersionResponse)3 ByteString (com.google.protobuf.ByteString)3 AccessSecretVersionRequest (com.google.cloud.secretmanager.v1.AccessSecretVersionRequest)1 DestroySecretVersionRequest (com.google.cloud.secretmanager.v1.DestroySecretVersionRequest)1 DisableSecretVersionRequest (com.google.cloud.secretmanager.v1.DisableSecretVersionRequest)1 EnableSecretVersionRequest (com.google.cloud.secretmanager.v1.EnableSecretVersionRequest)1 SecretName (com.google.cloud.secretmanager.v1.SecretName)1 SecretPayload (com.google.cloud.secretmanager.v1.SecretPayload)1