use of com.netflix.spinnaker.kork.secrets.user.OpaqueUserSecret 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"));
}
Aggregations