mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix: issues 226 227 (#257)
* feat(eventbridge): add ListTagsForResource support * feat(lambda): add GetFunctionCodeSigningConfig endpoint
This commit is contained in:
1 parent
18bee5b278
commit
81f1a01c39
5 files changed
+270
No files matched your search
+131
@@ -0,0 +1,131 @@
|
||||
package io.github.hectorvent.floci.services.eventbridge;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.RestAssured;
|
||||
import io.restassured.config.EncoderConfig;
|
||||
import io.restassured.http.ContentType;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
@QuarkusTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class EventBridgeListTagsIntegrationTest {
|
||||
|
||||
private static final String EVENT_BRIDGE_CONTENT_TYPE = "application/x-amz-json-1.1";
|
||||
|
||||
@BeforeAll
|
||||
static void configureRestAssured() {
|
||||
RestAssured.config = RestAssured.config().encoderConfig(
|
||||
EncoderConfig.encoderConfig()
|
||||
.encodeContentTypeAs(EVENT_BRIDGE_CONTENT_TYPE, ContentType.TEXT)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void createRuleWithTags() {
|
||||
given()
|
||||
.contentType(EVENT_BRIDGE_CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSEvents.PutRule")
|
||||
.body("""
|
||||
{
|
||||
"Name": "tagged-rule",
|
||||
"Tags": [
|
||||
{"Key": "env", "Value": "test"},
|
||||
{"Key": "team", "Value": "platform"}
|
||||
]
|
||||
}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("RuleArn", notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void listTagsForRuleResource() {
|
||||
// First get the rule ARN
|
||||
String ruleArn = given()
|
||||
.contentType(EVENT_BRIDGE_CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSEvents.DescribeRule")
|
||||
.body("{\"Name\":\"tagged-rule\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().jsonPath().getString("Arn");
|
||||
|
||||
// Now list tags for the rule
|
||||
given()
|
||||
.contentType(EVENT_BRIDGE_CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSEvents.ListTagsForResource")
|
||||
.body("{\"ResourceARN\":\"" + ruleArn + "\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Tags", hasSize(2))
|
||||
.body("Tags.find { it.Key == 'env' }.Value", equalTo("test"))
|
||||
.body("Tags.find { it.Key == 'team' }.Value", equalTo("platform"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void listTagsForResourceWithNoTags() {
|
||||
// Create a rule with no tags
|
||||
given()
|
||||
.contentType(EVENT_BRIDGE_CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSEvents.PutRule")
|
||||
.body("{\"Name\":\"untagged-rule\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
String ruleArn = given()
|
||||
.contentType(EVENT_BRIDGE_CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSEvents.DescribeRule")
|
||||
.body("{\"Name\":\"untagged-rule\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().jsonPath().getString("Arn");
|
||||
|
||||
given()
|
||||
.contentType(EVENT_BRIDGE_CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSEvents.ListTagsForResource")
|
||||
.body("{\"ResourceARN\":\"" + ruleArn + "\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Tags", hasSize(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void cleanup() {
|
||||
given()
|
||||
.contentType(EVENT_BRIDGE_CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSEvents.DeleteRule")
|
||||
.body("{\"Name\":\"tagged-rule\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
given()
|
||||
.contentType(EVENT_BRIDGE_CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSEvents.DeleteRule")
|
||||
.body("{\"Name\":\"untagged-rule\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package io.github.hectorvent.floci.services.lambda;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
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 LambdaCodeSigningConfigIntegrationTest {
|
||||
|
||||
private static final String BASE_PATH = "/2015-03-31";
|
||||
private static final String FUNCTION_NAME = "code-signing-test-function";
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void createFunction() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.body(String.format("""
|
||||
{
|
||||
"FunctionName": "%s",
|
||||
"Runtime": "nodejs20.x",
|
||||
"Role": "arn:aws:iam::000000000000:role/lambda-role",
|
||||
"Handler": "index.handler",
|
||||
"Description": "Code signing config test function"
|
||||
}
|
||||
""", FUNCTION_NAME))
|
||||
.when()
|
||||
.post(BASE_PATH + "/functions")
|
||||
.then()
|
||||
.statusCode(201)
|
||||
.body("FunctionName", equalTo(FUNCTION_NAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void getFunctionCodeSigningConfig() {
|
||||
given()
|
||||
.when()
|
||||
.get(BASE_PATH + "/functions/" + FUNCTION_NAME + "/code-signing-config")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("FunctionName", equalTo(FUNCTION_NAME))
|
||||
.body("CodeSigningConfigArn", notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void getFunctionCodeSigningConfigNotFound() {
|
||||
given()
|
||||
.when()
|
||||
.get(BASE_PATH + "/functions/nonexistent-function/code-signing-config")
|
||||
.then()
|
||||
.statusCode(404);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void cleanup() {
|
||||
given()
|
||||
.when()
|
||||
.delete(BASE_PATH + "/functions/" + FUNCTION_NAME)
|
||||
.then()
|
||||
.statusCode(204);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user