use of com.amazonaws.services.secretsmanager.model.GetSecretValueResult in project fernet-java8 by l0s.
the class SecretsManagerTest method verifyAssertDoesNothing.
@Test
public final void verifyAssertDoesNothing() {
// given
final GetSecretValueRequest request = new GetSecretValueRequest();
request.setSecretId("secret");
request.setVersionStage("AWSCURRENT");
given(delegate.getSecretValue(eq(request))).willReturn(new GetSecretValueResult());
// when
manager.assertCurrentStageExists("secret");
// then (nothing)
}
use of com.amazonaws.services.secretsmanager.model.GetSecretValueResult in project fernet-java8 by l0s.
the class SecretsManagerTest method verifyGetSecretVersionRetrievesBinary.
@Test
public final void verifyGetSecretVersionRetrievesBinary() throws UnsupportedEncodingException {
// given
final GetSecretValueRequest request = new GetSecretValueRequest();
request.setSecretId("secret");
request.setVersionId("version");
final GetSecretValueResult response = new GetSecretValueResult();
response.setSecretBinary(ByteBuffer.wrap("expected".getBytes("UTF-8")));
given(delegate.getSecretValue(eq(request))).willReturn(response);
// when
final ByteBuffer result = manager.getSecretVersion("secret", "version");
// then
final byte[] buffer = new byte[result.remaining()];
result.get(buffer);
assertEquals("expected", new String(buffer, "UTF-8"));
}
use of com.amazonaws.services.secretsmanager.model.GetSecretValueResult in project fernet-java8 by l0s.
the class SecretsManager method getSecretStage.
/**
* Retrieve a specific stage of the secret.
*
* @param secretId the ARN of the secret
* @param stage the stage of the secret to retrieve
* @return the Fernet key or keys in binary form
*/
public ByteBuffer getSecretStage(final String secretId, final Stage stage) {
final GetSecretValueRequest getSecretValueRequest = new GetSecretValueRequest();
getSecretValueRequest.setSecretId(secretId);
getSecretValueRequest.setVersionStage(stage.getAwsName());
final GetSecretValueResult result = getDelegate().getSecretValue(getSecretValueRequest);
return result.getSecretBinary();
}
use of com.amazonaws.services.secretsmanager.model.GetSecretValueResult in project JAQU-CAZ-Payments-API by InformedSolutions.
the class CredentialRetrievalManagerTest method canGetApiKeyWithOptionalWhitespaces.
@ParameterizedTest
@ValueSource(strings = { "testApiKey", " testApiKey", "testApiKey ", " testApiKey " })
void canGetApiKeyWithOptionalWhitespaces(String apiKey) throws JsonProcessingException {
UUID cleanAirZoneId = UUID.randomUUID();
ObjectNode node = objectMapper.createObjectNode();
node.put(cleanAirZoneId.toString().replace("-", ""), apiKey);
GetSecretValueResult getSecretValueResponse = mock(GetSecretValueResult.class);
Mockito.when(client.getSecretValue(Mockito.any(GetSecretValueRequest.class))).thenReturn(getSecretValueResponse);
Mockito.when(getSecretValueResponse.getSecretString()).thenReturn(objectMapper.writeValueAsString(node));
Optional<String> result = credentialRetrievalManager.getCardApiKey(cleanAirZoneId);
assertTrue(result.isPresent());
assertThat(result).contains("testApiKey");
}
use of com.amazonaws.services.secretsmanager.model.GetSecretValueResult in project JAQU-CAZ-Payments-API by InformedSolutions.
the class CredentialRetrievalManagerTest method mockAccessTokenForCaz.
@SneakyThrows
private void mockAccessTokenForCaz(UUID cazId, String accessToken) {
GetSecretValueResult getSecretValueResponse = mock(GetSecretValueResult.class);
Mockito.when(client.getSecretValue(Mockito.any(GetSecretValueRequest.class))).thenReturn(getSecretValueResponse);
Mockito.when(getSecretValueResponse.getSecretString()).thenReturn(objectMapper.writeValueAsString(Collections.singletonMap(cazId.toString().replace("-", ""), accessToken)));
}
Aggregations