mirror of
https://github.com/floci-io/floci.git
synced 2026-12-02 01:43:02 -05:00
fix(bedrock): list guardrails in the tagging api and route its writes (#6646)
* fix(bedrock): list guardrails in the tagging api and route its writes guardrails were not a ResourceProvider, so GetResources with bedrock:guardrail came back empty, and TagResources had no bedrock handler to forward to. list the draft of each guardrail with its own tags and add a tagging-api-only handler that calls the existing tag methods. * test(bedrock): cover guardrail discovery and tagging writes with the sdk
This commit is contained in:
1 parent
8b13c75fa2
commit
c4ad788e62
6 files changed
+184
-1
No files matched your search
+52
@@ -647,6 +647,46 @@ class ResourceGroupsTaggingDiscoveryIntegrationTest {
|
||||
""".formatted(queueUrl)).then().statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void bedrockGuardrailIsDiscoveredAndTaggingApiWritesReachIt() {
|
||||
String marker = unique();
|
||||
String value = unique();
|
||||
Response created = given()
|
||||
.contentType("application/json")
|
||||
.body("""
|
||||
{"name": "discovery-%s", "blockedInputMessaging": "in", "blockedOutputsMessaging": "out",
|
||||
"tags": [{"key": "fd", "value": "%s"}]}
|
||||
""".formatted(marker, marker))
|
||||
.when()
|
||||
.post("/guardrails");
|
||||
created.then().statusCode(202);
|
||||
String arn = created.path("guardrailArn");
|
||||
String guardrailId = created.path("guardrailId");
|
||||
|
||||
getResources(markerFilter("bedrock:guardrail", marker))
|
||||
.body("ResourceTagMappingList.ResourceARN", contains(arn));
|
||||
|
||||
tagAddedThroughTaggingApi(arn, value);
|
||||
guardrailTags(arn)
|
||||
.body("tags.find { it.key == 'fd' }.value", equalTo(marker))
|
||||
.body("tags.find { it.key == 'added' }.value", equalTo(value));
|
||||
addedTagIsListedOnce(arn, value);
|
||||
|
||||
untagAddedThroughTaggingApi(arn);
|
||||
guardrailTags(arn)
|
||||
.body("tags.key", not(hasItem("added")));
|
||||
addedTagIsNotListed(arn);
|
||||
|
||||
// Bedrock tags through its own actions, so the shared tags paths still reject a guardrail.
|
||||
for (String path : List.of("/tags/{arn}", "/v1/tags/{arn}")) {
|
||||
tagsPathRejectsArn(path, arn);
|
||||
}
|
||||
|
||||
given().when().delete("/guardrails/" + guardrailId).then().statusCode(202);
|
||||
getResources(markerFilter("bedrock:guardrail", marker))
|
||||
.body("ResourceTagMappingList", empty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void taggingApiReportsAnotherAccountsArn() {
|
||||
String name = "discovery-" + unique();
|
||||
@@ -996,6 +1036,18 @@ class ResourceGroupsTaggingDiscoveryIntegrationTest {
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
private static ValidatableResponse guardrailTags(String arn) {
|
||||
return given()
|
||||
.contentType("application/json")
|
||||
.body("""
|
||||
{"resourceARN": "%s"}
|
||||
""".formatted(arn))
|
||||
.when()
|
||||
.post("/listTagsForResource")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
private static ValidatableResponse lambdaTags(String arn) {
|
||||
return given()
|
||||
.when()
|
||||
|
||||
Reference in new issue
Block a user