mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(codedeploy): answer ApplicationNameRequiredException when applicationName is missing (#7392)
This commit is contained in:
1 parent
d0747f26d1
commit
52055b774e
3 files changed
+50
No files matched your search
@@ -353,6 +353,14 @@ public class CodeDeployService {
|
||||
}
|
||||
|
||||
public Application getApplication(String region, String name) {
|
||||
if (name == null || name.isEmpty()) {
|
||||
throw new AwsException("ApplicationNameRequiredException",
|
||||
"The minimum number of required characters for applicationName is 1.", 400);
|
||||
}
|
||||
if (name.isBlank()) {
|
||||
throw new AwsException("InvalidApplicationNameException",
|
||||
"The application name was specified in an invalid format.", 400);
|
||||
}
|
||||
Application app = applicationsFor(region).get(name);
|
||||
if (app == null) {
|
||||
throw new AwsException("ApplicationDoesNotExistException",
|
||||
|
||||
+14
@@ -206,6 +206,20 @@ class CodeDeployIntegrationTest {
|
||||
.body("deploymentGroups", hasItem("my-lambda-dg"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
void listDeploymentGroupsWithoutApplicationNameFails() {
|
||||
given()
|
||||
.header("X-Amz-Target", "CodeDeploy_20141006.ListDeploymentGroups")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("{}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", containsString("ApplicationNameRequiredException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(11)
|
||||
void batchGetDeploymentGroups() {
|
||||
|
||||
+28
@@ -2,6 +2,7 @@ package io.github.hectorvent.floci.services.codedeploy;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.services.codedeploy.model.Deployment;
|
||||
import io.github.hectorvent.floci.services.ec2.Ec2Service;
|
||||
@@ -25,6 +26,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
@@ -432,6 +434,32 @@ class CodeDeployServiceTest {
|
||||
return (List<Map<String, Object>>) lambdaTarget.get("lifecycleEvents");
|
||||
}
|
||||
|
||||
@Test
|
||||
void listDeploymentGroupsWithoutApplicationNameThrowsApplicationNameRequired() {
|
||||
AwsException missing = assertThrows(AwsException.class,
|
||||
() -> service.listDeploymentGroups("us-east-1", null));
|
||||
assertEquals("ApplicationNameRequiredException", missing.getErrorCode());
|
||||
assertEquals(400, missing.getHttpStatus());
|
||||
AwsException empty = assertThrows(AwsException.class,
|
||||
() -> service.listDeploymentGroups("us-east-1", ""));
|
||||
assertEquals("ApplicationNameRequiredException", empty.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void listDeploymentGroupsWithWhitespaceApplicationNameThrowsInvalidApplicationName() {
|
||||
AwsException blank = assertThrows(AwsException.class,
|
||||
() -> service.listDeploymentGroups("us-east-1", " "));
|
||||
assertEquals("InvalidApplicationNameException", blank.getErrorCode());
|
||||
assertEquals(400, blank.getHttpStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
void listDeploymentGroupsForUnknownApplicationStillThrowsDoesNotExist() {
|
||||
AwsException unknown = assertThrows(AwsException.class,
|
||||
() -> service.listDeploymentGroups("us-east-1", "nope"));
|
||||
assertEquals("ApplicationDoesNotExistException", unknown.getErrorCode());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<String, String> diagnosticsOf(Map<String, Object> event) {
|
||||
return (Map<String, String>) event.get("diagnostics");
|
||||
|
||||
Reference in new issue
Block a user