use of com.yahoo.athenz.common.server.rest.ResourceException in project athenz by yahoo.
the class MockAWSParameterStoreSyncer method initClient.
@Override
SsmClient initClient() {
Date now = new Date();
SsmClient mock = mock(SsmClient.class);
when(mock.describeParameters(any(DescribeParametersRequest.class))).thenReturn(DescribeParametersResponse.builder().parameters(ParameterMetadata.builder().name("param1").lastModifiedDate(now.toInstant()).build(), ParameterMetadata.builder().name("param2").lastModifiedDate(now.toInstant()).build(), ParameterMetadata.builder().name("param4").lastModifiedDate(now.toInstant()).build()).build());
when(mock.getParameter(parameterRequest("param1"))).thenReturn(GetParameterResponse.builder().parameter(Parameter.builder().name("param1").value("param1-val").lastModifiedDate(now.toInstant()).build()).build());
when(mock.getParameter(parameterRequest("param2"))).thenReturn(GetParameterResponse.builder().parameter(Parameter.builder().name("param2").value("param2-val").lastModifiedDate(now.toInstant()).build()).build());
when(mock.getParameter(parameterRequest("param4"))).thenThrow(new ResourceException(INTERNAL_SERVER_ERROR));
return mock;
}
use of com.yahoo.athenz.common.server.rest.ResourceException in project athenz by yahoo.
the class AuthzHelper method convertEntityToAuthzDetailsEntity.
public static AuthzDetailsEntity convertEntityToAuthzDetailsEntity(Entity entity) throws JsonProcessingException {
Struct value = entity.getValue();
if (value == null) {
throw new ResourceException(ResourceException.BAD_REQUEST, "Entity has no value");
}
// the authorization details is the value of the data field
final String authzDetails = value.getString("data");
if (StringUtil.isEmpty(authzDetails)) {
throw new ResourceException(ResourceException.BAD_REQUEST, "Entity has no data field");
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Authorization Details json input: {}", authzDetails);
}
return JSON_MAPPER.readValue(authzDetails, AuthzDetailsEntity.class);
}
Aggregations