mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
Closes #7998 Validate description types before creating or changing an integration so malformed JSON returns BadRequestException instead of an uncaught ClassCastException. Preserve omitted, null and empty-string behavior. Cover create and update over REST and JSON 1.1, including rejection without stored changes.
This commit is contained in:
1 parent
5876a37888
commit
1bdc839350
6 files changed
+325
No files matched your search
@@ -2865,6 +2865,9 @@ public class ApiGatewayController {
|
||||
private ObjectNode toV2IntegrationNode(Integration i) {
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
node.put("integrationId", i.getIntegrationId());
|
||||
if (i.getDescription() != null) {
|
||||
node.put("description", i.getDescription());
|
||||
}
|
||||
node.put("integrationType", i.getIntegrationType());
|
||||
if (i.getIntegrationSubtype() != null) {
|
||||
node.put("integrationSubtype", i.getIntegrationSubtype());
|
||||
|
||||
@@ -650,6 +650,9 @@ public class ApiGatewayV2JsonHandler {
|
||||
private ObjectNode toIntegrationNode(Integration i) {
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
node.put("IntegrationId", i.getIntegrationId());
|
||||
if (i.getDescription() != null) {
|
||||
node.put("Description", i.getDescription());
|
||||
}
|
||||
node.put("IntegrationType", i.getIntegrationType());
|
||||
if (i.getIntegrationSubtype() != null) {
|
||||
node.put("IntegrationSubtype", i.getIntegrationSubtype());
|
||||
|
||||
@@ -794,6 +794,7 @@ public class ApiGatewayV2Service {
|
||||
|
||||
Integration integration = new Integration();
|
||||
integration.setIntegrationId(shortId(8));
|
||||
integration.setDescription(integrationDescription(request));
|
||||
integration.setIntegrationType((String) request.get("integrationType"));
|
||||
integration.setIntegrationSubtype(integrationSubtype);
|
||||
integration.setCredentialsArn((String) request.get("credentialsArn"));
|
||||
@@ -863,6 +864,10 @@ public class ApiGatewayV2Service {
|
||||
updatedValue(request, "integrationSubtype", integration.getIntegrationSubtype()),
|
||||
payloadFormatVersion, requestParameters);
|
||||
|
||||
String description = integrationDescription(request);
|
||||
if (description != null) {
|
||||
integration.setDescription(description);
|
||||
}
|
||||
if (request.get("credentialsArn") != null) {
|
||||
integration.setCredentialsArn((String) request.get("credentialsArn"));
|
||||
}
|
||||
@@ -907,6 +912,14 @@ public class ApiGatewayV2Service {
|
||||
return integration;
|
||||
}
|
||||
|
||||
private static String integrationDescription(Map<String, Object> request) {
|
||||
Object description = request.get("description");
|
||||
if (description != null && !(description instanceof String)) {
|
||||
throw new AwsException("BadRequestException", "Description must be a string.", 400);
|
||||
}
|
||||
return (String) description;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> T updatedValue(Map<String, Object> request, String key, T stored) {
|
||||
Object value = request.get(key);
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.Map;
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class Integration {
|
||||
private String integrationId;
|
||||
private String description;
|
||||
private String integrationType; // AWS_PROXY, HTTP_PROXY
|
||||
private String integrationSubtype;
|
||||
private String connectionType; // INTERNET, VPC_LINK
|
||||
@@ -33,6 +34,7 @@ public class Integration {
|
||||
public Integration(Integration src) {
|
||||
this.credentialsArn = src.credentialsArn;
|
||||
this.integrationId = src.integrationId;
|
||||
this.description = src.description;
|
||||
this.integrationType = src.integrationType;
|
||||
this.integrationSubtype = src.integrationSubtype;
|
||||
this.connectionType = src.connectionType;
|
||||
@@ -50,6 +52,9 @@ public class Integration {
|
||||
public String getIntegrationId() { return integrationId; }
|
||||
public void setIntegrationId(String integrationId) { this.integrationId = integrationId; }
|
||||
|
||||
public String getDescription() { return description; }
|
||||
public void setDescription(String description) { this.description = description; }
|
||||
|
||||
public String getIntegrationType() { return integrationType; }
|
||||
public void setIntegrationType(String integrationType) { this.integrationType = integrationType; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user