Search in sources :

Example 1 with UserSecretReference

use of com.netflix.spinnaker.kork.secrets.user.UserSecretReference in project kork by spinnaker.

the class SecretsManagerSecretEngineTest method decryptJsonUserSecret.

@Test
public void decryptJsonUserSecret() {
    OpaqueUserSecret userSecret = OpaqueUserSecret.builder().roles(List.of("a", "b", "c")).stringData(Map.of("password", "hunter2")).build();
    byte[] secretBytes = userSecretMapper.serialize(userSecret, "json");
    GetSecretValueResult stubResult = new GetSecretValueResult().withSecretBinary(ByteBuffer.wrap(secretBytes));
    doReturn(stubResult).when(secretsManagerSecretEngine).getSecretValue(any(), any());
    UserSecretReference reference = UserSecretReference.parse("secret://secrets-manager?r=us-west-2&s=private-key&e=json");
    assertEquals("hunter2", secretsManagerSecretEngine.decrypt(reference).getSecretString("password"));
}
Also used : GetSecretValueResult(com.amazonaws.services.secretsmanager.model.GetSecretValueResult) OpaqueUserSecret(com.netflix.spinnaker.kork.secrets.user.OpaqueUserSecret) UserSecretReference(com.netflix.spinnaker.kork.secrets.user.UserSecretReference) Test(org.junit.Test)

Aggregations

GetSecretValueResult (com.amazonaws.services.secretsmanager.model.GetSecretValueResult)1 OpaqueUserSecret (com.netflix.spinnaker.kork.secrets.user.OpaqueUserSecret)1 UserSecretReference (com.netflix.spinnaker.kork.secrets.user.UserSecretReference)1 Test (org.junit.Test)1