Search in sources :

Example 61 with SecretVersionName

use of com.google.cloud.secretmanager.v1.SecretVersionName in project quarkus-google-cloud-services by quarkiverse.

the class SecretManagerConfigUtilsTest method testShortProperty_projectSecretId.

@Test
public void testShortProperty_projectSecretId() {
    String property = "sm//the-secret/the-version";
    SecretVersionName secretIdentifier = SecretManagerConfigUtils.getSecretVersionName(property, DEFAULT_PROJECT);
    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.jupiter.api.Test)

Example 62 with SecretVersionName

use of com.google.cloud.secretmanager.v1.SecretVersionName in project quarkus-google-cloud-services by quarkiverse.

the class SecretManagerConfigUtilsTest method testLongProperty_projectSecret.

@Test
public void testLongProperty_projectSecret() {
    String property = "sm//projects/my-project/secrets/the-secret";
    SecretVersionName secretIdentifier = SecretManagerConfigUtils.getSecretVersionName(property, DEFAULT_PROJECT);
    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.jupiter.api.Test)

Example 63 with SecretVersionName

use of com.google.cloud.secretmanager.v1.SecretVersionName in project quarkus-google-cloud-services by quarkiverse.

the class SecretManagerResource method secretManager.

@GET
@Produces(MediaType.TEXT_PLAIN)
public String secretManager() {
    SecretVersionName secretVersionName = SecretVersionName.of(projectId, "integration-test", "latest");
    AccessSecretVersionResponse response = client.accessSecretVersion(secretVersionName);
    return String.format("Secret accessed via client: %s || Secret accessed via property: %s", response.getPayload().getData().toStringUtf8(), secret);
}
Also used : SecretVersionName(com.google.cloud.secretmanager.v1.SecretVersionName) AccessSecretVersionResponse(com.google.cloud.secretmanager.v1.AccessSecretVersionResponse) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

SecretVersionName (com.google.cloud.secretmanager.v1.SecretVersionName)63 Test (org.junit.Test)19 SecretManagerServiceClient (com.google.cloud.secretmanager.v1.SecretManagerServiceClient)15 SecretVersion (com.google.cloud.secretmanager.v1.SecretVersion)13 Test (org.junit.jupiter.api.Test)12 AccessSecretVersionResponse (com.google.cloud.secretmanager.v1.AccessSecretVersionResponse)7 ByteString (com.google.protobuf.ByteString)3 ApiException (com.google.api.gax.rpc.ApiException)1 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 IOException (java.io.IOException)1 CRC32C (java.util.zip.CRC32C)1 Checksum (java.util.zip.Checksum)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1