mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
Add key rotation management with persisted state on the KmsKey model. Rotation is only supported for symmetric ENCRYPT_DECRYPT keys, matching AWS behavior. Includes validation that rejects asymmetric keys with UnsupportedOperationException.
This commit is contained in:
5 files changed
+103
No files matched your search
@@ -287,4 +287,43 @@ class KmsServiceTest {
|
||||
assertThrows(AwsException.class, () ->
|
||||
kmsService.putKeyPolicy("non-existent", "{}", REGION));
|
||||
}
|
||||
|
||||
// ── Issue #290 — Key Rotation ───────────────────────────────────────────
|
||||
|
||||
@Test
|
||||
void getKeyRotationStatusDefaultFalse() {
|
||||
KmsKey key = kmsService.createKey(null, REGION);
|
||||
assertFalse(kmsService.getKeyRotationStatus(key.getKeyId(), REGION));
|
||||
}
|
||||
|
||||
@Test
|
||||
void enableAndGetKeyRotationStatus() {
|
||||
KmsKey key = kmsService.createKey(null, REGION);
|
||||
kmsService.enableKeyRotation(key.getKeyId(), REGION);
|
||||
assertTrue(kmsService.getKeyRotationStatus(key.getKeyId(), REGION));
|
||||
}
|
||||
|
||||
@Test
|
||||
void disableKeyRotationAfterEnable() {
|
||||
KmsKey key = kmsService.createKey(null, REGION);
|
||||
kmsService.enableKeyRotation(key.getKeyId(), REGION);
|
||||
kmsService.disableKeyRotation(key.getKeyId(), REGION);
|
||||
assertFalse(kmsService.getKeyRotationStatus(key.getKeyId(), REGION));
|
||||
}
|
||||
|
||||
@Test
|
||||
void keyRotationOnNonExistentKeyThrows() {
|
||||
assertThrows(AwsException.class, () ->
|
||||
kmsService.getKeyRotationStatus("non-existent", REGION));
|
||||
}
|
||||
|
||||
@Test
|
||||
void keyRotationOnAsymmetricKeyThrows() {
|
||||
KmsKey key = kmsService.createKey(null, REGION);
|
||||
key.setCustomerMasterKeySpec("RSA_2048");
|
||||
key.setKeyUsage("SIGN_VERIFY");
|
||||
// Persist the modified key
|
||||
assertThrows(AwsException.class, () ->
|
||||
kmsService.enableKeyRotation(key.getKeyId(), REGION));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user