mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(secretsmanager): return KmsKeyId in DescribeSecret and improve ListSecrets (#195)
This commit is contained in:
1 parent
ecf25d4736
commit
1e44f39c7c
3 files changed
+69
-2
No files matched your search
+32
@@ -124,4 +124,36 @@ class SecretsManagerJsonHandlerTest {
|
||||
request.put("RequireEachIncludedType", false);
|
||||
assertThat(getRandomPassword(request), matchesPattern("[0-9]+"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeSecretResponseIncludesKmsKeyId() {
|
||||
ObjectNode createReq = MAPPER.createObjectNode();
|
||||
createReq.put("Name", "kms-secret");
|
||||
createReq.put("KmsKeyId", "my-kms-key");
|
||||
handler.handle("CreateSecret", createReq, REGION);
|
||||
|
||||
ObjectNode describeReq = MAPPER.createObjectNode();
|
||||
describeReq.put("SecretId", "kms-secret");
|
||||
Response response = handler.handle("DescribeSecret", describeReq, REGION);
|
||||
|
||||
assertThat(response.getStatus(), is(200));
|
||||
ObjectNode body = (ObjectNode) response.getEntity();
|
||||
assertThat(body.get("KmsKeyId").asText(), is("my-kms-key"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listSecretsResponseIncludesKmsKeyId() {
|
||||
ObjectNode createReq = MAPPER.createObjectNode();
|
||||
createReq.put("Name", "list-kms-secret");
|
||||
createReq.put("KmsKeyId", "list-kms-key");
|
||||
handler.handle("CreateSecret", createReq, REGION);
|
||||
|
||||
Response response = handler.handle("ListSecrets", MAPPER.createObjectNode(), REGION);
|
||||
|
||||
assertThat(response.getStatus(), is(200));
|
||||
ObjectNode body = (ObjectNode) response.getEntity();
|
||||
ObjectNode secret = (ObjectNode) body.get("SecretList").get(0);
|
||||
assertThat(secret.get("KmsKeyId").asText(), is("list-kms-key"));
|
||||
assertThat(secret.has("CreatedDate"), is(true));
|
||||
}
|
||||
}
|
||||
+18
-1
@@ -200,4 +200,21 @@ class SecretsManagerServiceTest {
|
||||
SecretVersion fetched = service.getSecretValue("my-secret", v1Id, null, REGION);
|
||||
assertEquals("v1", fetched.getSecretString());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void kmsKeyIdIsPreserved() {
|
||||
String kmsKeyId = "arn:aws:kms:us-east-1:000000000000:key/my-key";
|
||||
// Signature: name, secretString, secretBinary, description, kmsKeyId, tags, region
|
||||
Secret secret = service.createSecret("kms-secret", "value", null,
|
||||
"desc", kmsKeyId, null, REGION);
|
||||
|
||||
assertEquals(kmsKeyId, secret.getKmsKeyId());
|
||||
|
||||
Secret described = service.describeSecret("kms-secret", REGION);
|
||||
assertEquals(kmsKeyId, described.getKmsKeyId());
|
||||
|
||||
service.updateSecret("kms-secret", "new desc", "arn:aws:kms:us-east-1:000000000000:key/other-key", REGION);
|
||||
Secret updated = service.describeSecret("kms-secret", REGION);
|
||||
assertEquals("arn:aws:kms:us-east-1:000000000000:key/other-key", updated.getKmsKeyId());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user