mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(wafv2): reject logging for nonexistent web ACLs (#6203)
* fix(wafv2): reject logging for nonexistent web ACLs * fix(wafv2): preserve legacy web ACL ARN lookups * fix(wafv2): drop legacy web ACL fallback
This commit is contained in:
1 parent
da66550c70
commit
52b7cbe75f
2 files changed
+52
-12
No files matched your search
@@ -9,6 +9,8 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
@@ -28,6 +30,8 @@ class WafV2IntegrationTest {
|
||||
private static final String PREFIX = "AWSWAF_20190729.";
|
||||
private static final String API_RESOURCE_ARN =
|
||||
"arn:aws:apigateway:us-east-1::/restapis/floci-waf-test/stages/prod";
|
||||
private static final String LOG_DESTINATION_ARN =
|
||||
"arn:aws:firehose:us-east-1:000000000000:deliverystream/aws-waf-logs-test";
|
||||
|
||||
private static String ipSetId;
|
||||
private static String ipSetArn;
|
||||
@@ -419,6 +423,24 @@ class WafV2IntegrationTest {
|
||||
|
||||
@Test
|
||||
@Order(19)
|
||||
void putLoggingConfigurationForExistingWebAclSucceeds() {
|
||||
call("PutLoggingConfiguration",
|
||||
"{\"LoggingConfiguration\":{\"ResourceArn\":\"" + webAclArn + "\","
|
||||
+ "\"LogDestinationConfigs\":[\"" + LOG_DESTINATION_ARN + "\"]}}")
|
||||
.then().statusCode(200)
|
||||
.body("LoggingConfiguration.ResourceArn", equalTo(webAclArn))
|
||||
.body("LoggingConfiguration.LogDestinationConfigs[0]", equalTo(LOG_DESTINATION_ARN));
|
||||
|
||||
call("GetLoggingConfiguration", "{\"ResourceArn\":\"" + webAclArn + "\"}")
|
||||
.then().statusCode(200)
|
||||
.body("LoggingConfiguration.ResourceArn", equalTo(webAclArn));
|
||||
|
||||
call("DeleteLoggingConfiguration", "{\"ResourceArn\":\"" + webAclArn + "\"}")
|
||||
.then().statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(20)
|
||||
void teardown() {
|
||||
call("DisassociateWebACL", "{\"ResourceArn\":\"" + API_RESOURCE_ARN + "\"}")
|
||||
.then().statusCode(200);
|
||||
@@ -440,7 +462,7 @@ class WafV2IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(20)
|
||||
@Order(21)
|
||||
void getMissingWebAclReturnsNonexistentItem() {
|
||||
call("GetWebACL",
|
||||
"{\"Name\":\"nope\",\"Scope\":\"REGIONAL\",\"Id\":\"00000000-0000-0000-0000-000000000000\"}")
|
||||
@@ -449,7 +471,7 @@ class WafV2IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(21)
|
||||
@Order(22)
|
||||
void arnLookupsOnMissingResourcesReturnNonexistentItemAs400() {
|
||||
String missingArn = "arn:aws:wafv2:us-east-1:000000000000:regional/webacl/nope/"
|
||||
+ "00000000-0000-0000-0000-000000000000";
|
||||
@@ -471,4 +493,20 @@ class WafV2IntegrationTest {
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("WAFNonexistentItemException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(23)
|
||||
void putLoggingConfigurationForMissingWebAclDoesNotPersist() {
|
||||
String missingArn = "arn:aws:wafv2:us-east-1:000000000000:regional/webacl/nope/" + UUID.randomUUID();
|
||||
|
||||
call("PutLoggingConfiguration",
|
||||
"{\"LoggingConfiguration\":{\"ResourceArn\":\"" + missingArn + "\","
|
||||
+ "\"LogDestinationConfigs\":[\"" + LOG_DESTINATION_ARN + "\"]}}")
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("WAFNonexistentItemException"));
|
||||
|
||||
call("GetLoggingConfiguration", "{\"ResourceArn\":\"" + missingArn + "\"}")
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("WAFNonexistentItemException"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user