mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(config): add AWS Config service emulation (#934)
* feat(config): add AWS Config service emulation (#913) * docs: add AWS Config service page and align service counts across all docs Add docs/services/config.md with all 20 supported actions, CLI examples, and configuration reference. Add 5 services that had doc pages but were missing from the service matrix (Textract, Pricing, Cost Explorer, CUR, BCM Data Exports). Reconcile service count to 51 across README, docs/index.md, and docs/services/index.md.
This commit is contained in:
1 parent
9bdb5436f0
commit
96a6fa6517
23 files changed
+1590
-7
No files matched your search
+215
@@ -0,0 +1,215 @@
|
||||
package io.github.hectorvent.floci.services.configservice;
|
||||
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
@QuarkusTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class ConfigRuleIntegrationTest {
|
||||
|
||||
private static final String CONTENT_TYPE = "application/x-amz-json-1.1";
|
||||
private static final String TARGET_PREFIX = "StarlingDoveService.";
|
||||
|
||||
@BeforeAll
|
||||
static void configureRestAssured() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void putConfigRule() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "PutConfigRule")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"ConfigRule": {
|
||||
"ConfigRuleName": "rule-crud-test",
|
||||
"Source": {
|
||||
"Owner": "AWS",
|
||||
"SourceIdentifier": "S3_ACCESS_POINT_PUBLIC_ACCESS_BLOCKS"
|
||||
}
|
||||
}
|
||||
}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void describeConfigRules() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "DescribeConfigRules")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConfigRuleNames": ["rule-crud-test"]}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ConfigRules", hasSize(1))
|
||||
.body("ConfigRules[0].ConfigRuleName", equalTo("rule-crud-test"))
|
||||
.body("ConfigRules[0].ConfigRuleArn", notNullValue())
|
||||
.body("ConfigRules[0].ConfigRuleId", notNullValue())
|
||||
.body("ConfigRules[0].ConfigRuleState", equalTo("ACTIVE"))
|
||||
.body("ConfigRules[0].Source.Owner", equalTo("AWS"))
|
||||
.body("ConfigRules[0].Source.SourceIdentifier", equalTo("S3_ACCESS_POINT_PUBLIC_ACCESS_BLOCKS"));
|
||||
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "DescribeConfigRules")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("{}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ConfigRules", hasSize(greaterThanOrEqualTo(1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void describeComplianceByConfigRule() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "DescribeComplianceByConfigRule")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConfigRuleNames": ["rule-crud-test"]}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ComplianceByConfigRules", hasSize(1))
|
||||
.body("ComplianceByConfigRules[0].ConfigRuleName", equalTo("rule-crud-test"))
|
||||
.body("ComplianceByConfigRules[0].Compliance.ComplianceType", equalTo("INSUFFICIENT_DATA"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void putConfigRuleUpdate() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "PutConfigRule")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"ConfigRule": {
|
||||
"ConfigRuleName": "rule-crud-test",
|
||||
"Source": {
|
||||
"Owner": "CUSTOM_LAMBDA",
|
||||
"SourceIdentifier": "arn:aws:lambda:us-east-1:123456789012:function:my-rule"
|
||||
}
|
||||
}
|
||||
}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "DescribeConfigRules")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConfigRuleNames": ["rule-crud-test"]}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ConfigRules[0].Source.Owner", equalTo("CUSTOM_LAMBDA"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void describeConfigRuleEvaluationStatus() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "DescribeConfigRuleEvaluationStatus")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConfigRuleNames": ["rule-crud-test"]}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ConfigRulesEvaluationStatus", hasSize(1))
|
||||
.body("ConfigRulesEvaluationStatus[0].ConfigRuleName", equalTo("rule-crud-test"))
|
||||
.body("ConfigRulesEvaluationStatus[0].ConfigRuleArn", notNullValue())
|
||||
.body("ConfigRulesEvaluationStatus[0].ConfigRuleId", notNullValue())
|
||||
.body("ConfigRulesEvaluationStatus[0].FirstEvaluationStarted", equalTo(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
void startConfigRulesEvaluation() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "StartConfigRulesEvaluation")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConfigRuleNames": ["rule-crud-test"]}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void startConfigRulesEvaluationNonexistent() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "StartConfigRulesEvaluation")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConfigRuleNames": ["no-such-rule"]}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("NoSuchConfigRuleException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(8)
|
||||
void deleteConfigRule() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "DeleteConfigRule")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConfigRuleName": "rule-crud-test"}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
void deleteNonexistentConfigRule() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "DeleteConfigRule")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConfigRuleName": "no-such-rule"}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("NoSuchConfigRuleException"));
|
||||
}
|
||||
}
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
package io.github.hectorvent.floci.services.configservice;
|
||||
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
@QuarkusTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class ConfigTaggingIntegrationTest {
|
||||
|
||||
private static final String CONTENT_TYPE = "application/x-amz-json-1.1";
|
||||
private static final String TARGET_PREFIX = "StarlingDoveService.";
|
||||
|
||||
@BeforeAll
|
||||
static void configureRestAssured() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void putConfigRuleForTagging() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "PutConfigRule")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"ConfigRule": {
|
||||
"ConfigRuleName": "tag-test-rule",
|
||||
"Source": {
|
||||
"Owner": "AWS",
|
||||
"SourceIdentifier": "S3_BUCKET_VERSIONING_ENABLED"
|
||||
}
|
||||
}
|
||||
}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void tagResource() {
|
||||
String arn = getConfigRuleArn("tag-test-rule");
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "TagResource")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"ResourceArn": "%s",
|
||||
"Tags": [
|
||||
{"Key": "Environment", "Value": "test"},
|
||||
{"Key": "Team", "Value": "platform"}
|
||||
]
|
||||
}
|
||||
""".formatted(arn))
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void tagResourceAddTag() {
|
||||
String arn = getConfigRuleArn("tag-test-rule");
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "TagResource")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"ResourceArn": "%s",
|
||||
"Tags": [{"Key": "CostCenter", "Value": "12345"}]
|
||||
}
|
||||
""".formatted(arn))
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "ListTagsForResource")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ResourceArn": "%s"}
|
||||
""".formatted(arn))
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Tags", hasSize(3));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void untagResource() {
|
||||
String arn = getConfigRuleArn("tag-test-rule");
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "UntagResource")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"ResourceArn": "%s",
|
||||
"TagKeys": ["CostCenter"]
|
||||
}
|
||||
""".formatted(arn))
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "ListTagsForResource")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ResourceArn": "%s"}
|
||||
""".formatted(arn))
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Tags", hasSize(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void listTagsForResourceNoTags() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "ListTagsForResource")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ResourceArn": "arn:aws:config:us-east-1:123456789012:config-rule/nonexistent"}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Tags", hasSize(0));
|
||||
}
|
||||
|
||||
private String getConfigRuleArn(String ruleName) {
|
||||
return given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "DescribeConfigRules")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConfigRuleNames": ["%s"]}
|
||||
""".formatted(ruleName))
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract()
|
||||
.path("ConfigRules[0].ConfigRuleArn");
|
||||
}
|
||||
}
|
||||
+219
@@ -0,0 +1,219 @@
|
||||
package io.github.hectorvent.floci.services.configservice;
|
||||
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
@QuarkusTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class ConfigurationRecorderIntegrationTest {
|
||||
|
||||
private static final String CONTENT_TYPE = "application/x-amz-json-1.1";
|
||||
private static final String TARGET_PREFIX = "StarlingDoveService.";
|
||||
|
||||
@BeforeAll
|
||||
static void configureRestAssured() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
}
|
||||
|
||||
// --- Configuration Recorder ---
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void putConfigurationRecorder() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "PutConfigurationRecorder")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"ConfigurationRecorder": {
|
||||
"name": "default",
|
||||
"roleARN": "arn:aws:iam::123456789012:role/config-role",
|
||||
"recordingGroup": {
|
||||
"allSupported": true,
|
||||
"includeGlobalResourceTypes": false
|
||||
}
|
||||
}
|
||||
}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void describeConfigurationRecorders() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "DescribeConfigurationRecorders")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConfigurationRecorderNames": ["default"]}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ConfigurationRecorders", hasSize(1))
|
||||
.body("ConfigurationRecorders[0].name", equalTo("default"))
|
||||
.body("ConfigurationRecorders[0].roleARN", equalTo("arn:aws:iam::123456789012:role/config-role"))
|
||||
.body("ConfigurationRecorders[0].recordingGroup.allSupported", equalTo(true));
|
||||
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "DescribeConfigurationRecorders")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("{}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ConfigurationRecorders", hasSize(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void startConfigurationRecorder() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "StartConfigurationRecorder")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConfigurationRecorderName": "default"}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void describeConfigurationRecorderStatusAfterStart() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "DescribeConfigurationRecorderStatus")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConfigurationRecorderNames": ["default"]}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ConfigurationRecordersStatus", hasSize(1))
|
||||
.body("ConfigurationRecordersStatus[0].name", equalTo("default"))
|
||||
.body("ConfigurationRecordersStatus[0].recording", equalTo(true))
|
||||
.body("ConfigurationRecordersStatus[0].lastStatus", equalTo("SUCCESS"))
|
||||
.body("ConfigurationRecordersStatus[0].lastStartTime", notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void stopConfigurationRecorder() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "StopConfigurationRecorder")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConfigurationRecorderName": "default"}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
void describeConfigurationRecorderStatusAfterStop() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "DescribeConfigurationRecorderStatus")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConfigurationRecorderNames": ["default"]}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ConfigurationRecordersStatus[0].recording", equalTo(false))
|
||||
.body("ConfigurationRecordersStatus[0].lastStopTime", notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
void startNonexistentConfigurationRecorder() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "StartConfigurationRecorder")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConfigurationRecorderName": "no-such-recorder"}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("NoSuchConfigurationRecorderException"));
|
||||
}
|
||||
|
||||
// --- Delivery Channel ---
|
||||
|
||||
@Test
|
||||
@Order(8)
|
||||
void putDeliveryChannel() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "PutDeliveryChannel")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"DeliveryChannel": {
|
||||
"name": "default",
|
||||
"s3BucketName": "my-config-bucket",
|
||||
"s3KeyPrefix": "config-snapshots",
|
||||
"configSnapshotDeliveryProperties": {
|
||||
"deliveryFrequency": "Twelve_Hours"
|
||||
}
|
||||
}
|
||||
}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
void describeDeliveryChannels() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "DescribeDeliveryChannels")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"DeliveryChannelNames": ["default"]}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DeliveryChannels", hasSize(1))
|
||||
.body("DeliveryChannels[0].name", equalTo("default"))
|
||||
.body("DeliveryChannels[0].s3BucketName", equalTo("my-config-bucket"))
|
||||
.body("DeliveryChannels[0].s3KeyPrefix", equalTo("config-snapshots"))
|
||||
.body("DeliveryChannels[0].configSnapshotDeliveryProperties.deliveryFrequency", equalTo("Twelve_Hours"));
|
||||
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "DescribeDeliveryChannels")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("{}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DeliveryChannels", hasSize(1));
|
||||
}
|
||||
}
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
package io.github.hectorvent.floci.services.configservice;
|
||||
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
@QuarkusTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class ConformancePackIntegrationTest {
|
||||
|
||||
private static final String CONTENT_TYPE = "application/x-amz-json-1.1";
|
||||
private static final String TARGET_PREFIX = "StarlingDoveService.";
|
||||
|
||||
@BeforeAll
|
||||
static void configureRestAssured() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void putConformancePack() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "PutConformancePack")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"ConformancePackName": "pack-crud-test",
|
||||
"TemplateS3Uri": "s3://my-bucket/template.yaml"
|
||||
}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ConformancePackArn", notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void describeConformancePacks() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "DescribeConformancePacks")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConformancePackNames": ["pack-crud-test"]}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ConformancePackDetails", hasSize(1))
|
||||
.body("ConformancePackDetails[0].ConformancePackName", equalTo("pack-crud-test"))
|
||||
.body("ConformancePackDetails[0].ConformancePackArn", notNullValue())
|
||||
.body("ConformancePackDetails[0].ConformancePackId", notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void describeConformancePackStatus() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "DescribeConformancePackStatus")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConformancePackNames": ["pack-crud-test"]}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ConformancePackStatusDetails", hasSize(1))
|
||||
.body("ConformancePackStatusDetails[0].ConformancePackName", equalTo("pack-crud-test"))
|
||||
.body("ConformancePackStatusDetails[0].ConformancePackState", equalTo("CREATE_SUCCESSFUL"))
|
||||
.body("ConformancePackStatusDetails[0].LastUpdateRequestedTime", notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void deleteConformancePack() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "DeleteConformancePack")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConformancePackName": "pack-crud-test"}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void deleteNonexistentConformancePack() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "DeleteConformancePack")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConformancePackName": "no-such-pack"}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("NoSuchConformancePackException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
void describeConformancePacksNonexistent() {
|
||||
given()
|
||||
.header("X-Amz-Target", TARGET_PREFIX + "DescribeConformancePacks")
|
||||
.contentType(CONTENT_TYPE)
|
||||
.body("""
|
||||
{"ConformancePackNames": ["no-such-pack"]}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("NoSuchConformancePackException"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user