mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
Add KMS key state and description operations (#1251)
* feat(kms): support disabling keys * feat(kms): support key description updates * fix(kms): tighten key description update coverage
This commit is contained in:
1 parent
22cff99830
commit
6e4087b0f4
6 files changed
+165
-1
No files matched your search
@@ -24,6 +24,52 @@ class KmsIntegrationTest {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateKeyDescriptionRoundTripThroughJsonHandler() {
|
||||
String keyId = given()
|
||||
.header("X-Amz-Target", "TrentService.CreateKey")
|
||||
.contentType(KMS_CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"Description": "old description"
|
||||
}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("KeyMetadata.KeyId", notNullValue())
|
||||
.extract().jsonPath().getString("KeyMetadata.KeyId");
|
||||
|
||||
given()
|
||||
.header("X-Amz-Target", "TrentService.UpdateKeyDescription")
|
||||
.contentType(KMS_CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"KeyId": "%s",
|
||||
"Description": "new description"
|
||||
}
|
||||
""".formatted(keyId))
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
given()
|
||||
.header("X-Amz-Target", "TrentService.DescribeKey")
|
||||
.contentType(KMS_CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"KeyId": "%s"
|
||||
}
|
||||
""".formatted(keyId))
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("KeyMetadata.Description", equalTo("new description"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void generateMacAndVerifyMacRoundTripThroughJsonHandler() {
|
||||
String keyId = given()
|
||||
@@ -297,6 +343,70 @@ class KmsIntegrationTest {
|
||||
.body("KeyId", equalTo(keyId));
|
||||
}
|
||||
|
||||
@Test
|
||||
void disableKeyUpdatesDescribeKeyState() {
|
||||
String keyId = given()
|
||||
.header("X-Amz-Target", "TrentService.CreateKey")
|
||||
.contentType(KMS_CONTENT_TYPE)
|
||||
.body("{\"Description\":\"disable-key\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract()
|
||||
.path("KeyMetadata.KeyId");
|
||||
|
||||
given()
|
||||
.header("X-Amz-Target", "TrentService.DisableKey")
|
||||
.contentType(KMS_CONTENT_TYPE)
|
||||
.body("""
|
||||
{"KeyId":"%s"}
|
||||
""".formatted(keyId))
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
given()
|
||||
.header("X-Amz-Target", "TrentService.DescribeKey")
|
||||
.contentType(KMS_CONTENT_TYPE)
|
||||
.body("""
|
||||
{"KeyId":"%s"}
|
||||
""".formatted(keyId))
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("KeyMetadata.Enabled", equalTo(false))
|
||||
.body("KeyMetadata.KeyState", equalTo("Disabled"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateKeyDescriptionRequiresDescription() {
|
||||
String keyId = given()
|
||||
.header("X-Amz-Target", "TrentService.CreateKey")
|
||||
.contentType(KMS_CONTENT_TYPE)
|
||||
.body("{\"Description\":\"missing-description-update\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract()
|
||||
.path("KeyMetadata.KeyId");
|
||||
|
||||
given()
|
||||
.header("X-Amz-Target", "TrentService.UpdateKeyDescription")
|
||||
.contentType(KMS_CONTENT_TYPE)
|
||||
.body("""
|
||||
{"KeyId":"%s"}
|
||||
""".formatted(keyId))
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listGrantsReturnsEmptyGrantListThroughJsonHandler() {
|
||||
String keyId = given()
|
||||
|
||||
@@ -61,6 +61,16 @@ class KmsServiceTest {
|
||||
assertEquals("Enabled", key.getKeyState());
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateKeyDescriptionPersistsDescription() {
|
||||
KmsKey key = kmsService.createKey("old description", REGION);
|
||||
|
||||
kmsService.updateKeyDescription(key.getKeyId(), "new description", REGION);
|
||||
|
||||
KmsKey updated = kmsService.describeKey(key.getKeyId(), REGION);
|
||||
assertEquals("new description", updated.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
void listKeys() {
|
||||
kmsService.createKey("key1", REGION);
|
||||
|
||||
Reference in new issue
Block a user