mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(redshift-serverless): return HTTP 400 for ResourceNotFoundException and ConflictException (#5409)
This commit is contained in:
1 parent
58ac05433a
commit
972ff03f00
5 files changed
+46
-37
No files matched your search
+2
-2
@@ -149,8 +149,8 @@ class RedshiftServerlessCfnIntegrationTest {
|
||||
CfnStackWaits.awaitStackDeleted(STACK);
|
||||
|
||||
// The workgroup is deleted before the namespace, which would otherwise be refused.
|
||||
call("GetWorkgroup", "{\"workgroupName\":\"" + WORKGROUP + "\"}").statusCode(404);
|
||||
call("GetNamespace", "{\"namespaceName\":\"" + NAMESPACE + "\"}").statusCode(404);
|
||||
call("GetWorkgroup", "{\"workgroupName\":\"" + WORKGROUP + "\"}").statusCode(400);
|
||||
call("GetNamespace", "{\"namespaceName\":\"" + NAMESPACE + "\"}").statusCode(400);
|
||||
}
|
||||
|
||||
private static void cloudFormation(String action, String capacity) {
|
||||
|
||||
+10
-10
@@ -115,7 +115,7 @@ class RedshiftServerlessIntegrationTest {
|
||||
.body("namespace.status", equalTo("DELETING"));
|
||||
|
||||
call("GetNamespace", "{\"namespaceName\":\"lifecycle-ns\"}")
|
||||
.statusCode(404)
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class RedshiftServerlessIntegrationTest {
|
||||
call("CreateNamespace", "{\"namespaceName\":\"conflict-ns\",\"adminUsername\":\"admin\"}")
|
||||
.statusCode(200);
|
||||
call("CreateNamespace", "{\"namespaceName\":\"conflict-ns\",\"adminUsername\":\"admin\"}")
|
||||
.statusCode(409)
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ConflictException"));
|
||||
call("DeleteNamespace", "{\"namespaceName\":\"conflict-ns\"}").statusCode(200);
|
||||
}
|
||||
@@ -132,7 +132,7 @@ class RedshiftServerlessIntegrationTest {
|
||||
@Test
|
||||
void deletingAnUnknownNamespaceReturnsResourceNotFound() {
|
||||
call("DeleteNamespace", "{\"namespaceName\":\"absent-ns\"}")
|
||||
.statusCode(404)
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ class RedshiftServerlessIntegrationTest {
|
||||
String absent = "arn:aws:redshift-serverless:us-east-1:000000000000:"
|
||||
+ "namespace/00000000-0000-0000-0000-000000000000";
|
||||
call("ListTagsForResource", "{\"resourceArn\":\"" + absent + "\"}")
|
||||
.statusCode(404)
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ class RedshiftServerlessIntegrationTest {
|
||||
.extract().path("snapshot.snapshotArn");
|
||||
|
||||
call("CreateSnapshot", "{\"snapshotName\":\"snap-life\",\"namespaceName\":\"snap-life-ns\"}")
|
||||
.statusCode(409)
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ConflictException"));
|
||||
|
||||
call("GetSnapshot", "{\"snapshotName\":\"snap-life\"}")
|
||||
@@ -265,7 +265,7 @@ class RedshiftServerlessIntegrationTest {
|
||||
.statusCode(200)
|
||||
.body("snapshot.snapshotName", equalTo("snap-life"));
|
||||
call("GetSnapshot", "{\"snapshotName\":\"snap-life\"}")
|
||||
.statusCode(404)
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
}
|
||||
|
||||
@@ -308,14 +308,14 @@ class RedshiftServerlessIntegrationTest {
|
||||
.body("workgroup.pendingTrackName", equalTo("trailing"));
|
||||
|
||||
call("DeleteNamespace", "{\"namespaceName\":\"wg-life-ns\"}")
|
||||
.statusCode(409)
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ConflictException"));
|
||||
|
||||
call("DeleteWorkgroup", "{\"workgroupName\":\"wg-life\"}")
|
||||
.statusCode(200)
|
||||
.body("workgroup.status", equalTo("DELETING"));
|
||||
call("GetWorkgroup", "{\"workgroupName\":\"wg-life\"}")
|
||||
.statusCode(404)
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
call("DeleteNamespace", "{\"namespaceName\":\"wg-life-ns\"}").statusCode(200);
|
||||
}
|
||||
@@ -347,7 +347,7 @@ class RedshiftServerlessIntegrationTest {
|
||||
@Test
|
||||
void workgroupCreateRejectsAnUnknownNamespaceADuplicateAndABadPort() {
|
||||
call("CreateWorkgroup", "{\"workgroupName\":\"wg-orphan\",\"namespaceName\":\"absent-ns\"}")
|
||||
.statusCode(404)
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
|
||||
call("CreateNamespace", "{\"namespaceName\":\"wg-err-ns\",\"adminUsername\":\"admin\"}").statusCode(200);
|
||||
@@ -356,7 +356,7 @@ class RedshiftServerlessIntegrationTest {
|
||||
.body("__type", equalTo("ValidationException"));
|
||||
call("CreateWorkgroup", "{\"workgroupName\":\"wg-err\",\"namespaceName\":\"wg-err-ns\"}").statusCode(200);
|
||||
call("CreateWorkgroup", "{\"workgroupName\":\"wg-err\",\"namespaceName\":\"wg-err-ns\"}")
|
||||
.statusCode(409)
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ConflictException"));
|
||||
|
||||
call("DeleteWorkgroup", "{\"workgroupName\":\"wg-err\"}").statusCode(200);
|
||||
|
||||
+2
-2
@@ -236,7 +236,7 @@ class RedshiftServerlessJsonHandlerTest {
|
||||
assertEquals(400, wrongType.getStatus());
|
||||
|
||||
Response missing = handler.handle("GetCredentials", parse("{\"workgroupName\":\"absent-wg\"}"), REGION, "AUTH");
|
||||
assertEquals(404, missing.getStatus());
|
||||
assertEquals(400, missing.getStatus());
|
||||
assertEquals("ResourceNotFoundException", errorType(missing));
|
||||
|
||||
Response customDomain = handler.handle("GetCredentials",
|
||||
@@ -313,7 +313,7 @@ class RedshiftServerlessJsonHandlerTest {
|
||||
|
||||
assertEquals("DELETING", deleted.get("status").textValue());
|
||||
Response missing = handler.handle("GetWorkgroup", request("workgroupName", "del-shape-wg"), REGION);
|
||||
assertEquals(404, missing.getStatus());
|
||||
assertEquals(400, missing.getStatus());
|
||||
assertEquals("ResourceNotFoundException", errorType(missing));
|
||||
}
|
||||
|
||||
|
||||
+13
-6
@@ -368,8 +368,10 @@ class RedshiftServerlessServiceTest {
|
||||
|
||||
@Test
|
||||
void createWorkgroupRequiresAnExistingNamespace() {
|
||||
assertEquals("ResourceNotFoundException", assertThrows(AwsException.class,
|
||||
() -> createWorkgroup("wg-orphan", "absent-ns")).getErrorCode());
|
||||
AwsException ex = assertThrows(AwsException.class,
|
||||
() -> createWorkgroup("wg-orphan", "absent-ns"));
|
||||
assertEquals("ResourceNotFoundException", ex.getErrorCode());
|
||||
assertEquals(400, ex.getHttpStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -378,10 +380,15 @@ class RedshiftServerlessServiceTest {
|
||||
create("two-ns");
|
||||
createWorkgroup("wg-first", "one-ns");
|
||||
|
||||
assertEquals("ConflictException", assertThrows(AwsException.class,
|
||||
() -> createWorkgroup("wg-second", "one-ns")).getErrorCode());
|
||||
assertEquals("ConflictException", assertThrows(AwsException.class,
|
||||
() -> createWorkgroup("wg-first", "two-ns")).getErrorCode());
|
||||
AwsException conflict1 = assertThrows(AwsException.class,
|
||||
() -> createWorkgroup("wg-second", "one-ns"));
|
||||
assertEquals("ConflictException", conflict1.getErrorCode());
|
||||
assertEquals(400, conflict1.getHttpStatus());
|
||||
|
||||
AwsException conflict2 = assertThrows(AwsException.class,
|
||||
() -> createWorkgroup("wg-first", "two-ns"));
|
||||
assertEquals("ConflictException", conflict2.getErrorCode());
|
||||
assertEquals(400, conflict2.getHttpStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user