mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(paymentcryptography): the list of keys answers with their summaries (#8135)
The model's KeySummary holds the identifier, the state, the attributes, the check value and the two flags, and not the whole key. The list answered with the whole key, so it carried the timestamps and the origin that a summary does not hold. The list answers with the summary now, and the whole key stays the answer of the operation that names one key. The control plane's answers are driven through a real SDK and through the AWS CLI, so the wire format of the operations the summary fix touches is the one the clients read. The certificate of a key pair, a tag that is added and removed, a key pair that keeps the usage its derived keys have, the RSA cryptogram the key exchange serves, the key the two parties agreed, and the timestamps the answers carry. The page said the member was read and checked. Nothing reads it: the shape check is what checks it, against the range the model states. The page said each key in the list is the whole key rather than the summary the model names, which the change that answers with the summary makes untrue. The page says what a listed key carries now. The round trip through the RSA cryptogram asserted the ARN of the key that came in and the usage it was given, which a wrong key of the same usage would also pass. It compares the check value with the exported key's, so the test shows that the same key came back. The key that came in was not added to the list the cleanup walks, so it was left in the service when the class finished. It is added now.
This commit is contained in:
1 parent
9fac49cdb0
commit
7c138ce3f1
7 files changed
+404
-8
No files matched your search
+25
@@ -400,6 +400,31 @@ class PaymentCryptographyIntegrationTest {
|
||||
.body("Keys.KeyArn", hasItem(equalTo(arn)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aListedKeyIsItsSummary() {
|
||||
// A list carries the key's summary and not the whole key: the identifier, the state,
|
||||
// the attributes, the check value and the two flags.
|
||||
String arn = call("CreateKey", CREATE_KEY).then().statusCode(200)
|
||||
.extract().path("Key.KeyArn");
|
||||
|
||||
call("ListKeys", "{}")
|
||||
.then().statusCode(200)
|
||||
.body("Keys.find { it.KeyArn == '" + arn + "' }.KeyState",
|
||||
equalTo("CREATE_COMPLETE"))
|
||||
.body("Keys.find { it.KeyArn == '" + arn + "' }.KeyAttributes.KeyAlgorithm",
|
||||
equalTo("AES_256"))
|
||||
.body("Keys.find { it.KeyArn == '" + arn + "' }.KeyAttributes.KeyUsage",
|
||||
equalTo("TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY"))
|
||||
.body("Keys.find { it.KeyArn == '" + arn + "' }.KeyCheckValue", notNullValue())
|
||||
.body("Keys.find { it.KeyArn == '" + arn + "' }.Enabled", equalTo(true))
|
||||
.body("Keys.find { it.KeyArn == '" + arn + "' }.Exportable", equalTo(true))
|
||||
// The summary holds no timestamp and no origin: those belong to the whole
|
||||
// key, which the list does not carry.
|
||||
.body("Keys.find { it.KeyArn == '" + arn + "' }.CreateTimestamp", nullValue())
|
||||
.body("Keys.find { it.KeyArn == '" + arn + "' }.KeyOrigin", nullValue())
|
||||
.body("Keys.find { it.KeyArn == '" + arn + "' }.UsageStartTimestamp", nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void anAliasIsCreatedAndListed() {
|
||||
String arn = call("CreateKey", CREATE_KEY).then().statusCode(200)
|
||||
|
||||
+11
@@ -395,6 +395,17 @@ class PaymentCryptographyKeyExchangeTest {
|
||||
"the private key was written to the store");
|
||||
}
|
||||
|
||||
@Test
|
||||
void aKeyPairHasACertificate() {
|
||||
PaymentCryptographyKey key = createKeyPair("RSA_2048");
|
||||
|
||||
Map<String, Object> answer = service.publicKeyCertificate(key);
|
||||
|
||||
String certificate = (String) answer.get("KeyCertificate");
|
||||
assertNotNull(certificate);
|
||||
assertNotNull(Certificates.parseCertificate(certificate));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aFormTheServiceDoesNotKnowIsRefused() {
|
||||
PaymentCryptographyKey key = createKey("AES_256", "TR31_D0_SYMMETRIC_DATA_ENCRYPTION_KEY");
|
||||
|
||||
+16
@@ -174,6 +174,22 @@ class PaymentCryptographyServiceTest {
|
||||
"the two pairs are different");
|
||||
}
|
||||
|
||||
@Test
|
||||
void aKeyPairCarriesTheUsageItsDerivedKeysHave() {
|
||||
// The usage a derived key is for is named when the key pair is made, as the export
|
||||
// guide's key agreement flow does.
|
||||
Map<String, Object> attributes = new LinkedHashMap<>();
|
||||
attributes.put("KeyAlgorithm", "ECC_NIST_P256");
|
||||
attributes.put("KeyClass", "ASYMMETRIC_KEY_PAIR");
|
||||
attributes.put("KeyUsage", "TR31_K3_ASYMMETRIC_KEY_FOR_KEY_AGREEMENT");
|
||||
attributes.put("DeriveKeyUsage", "TR31_K1_KEY_BLOCK_PROTECTION_KEY");
|
||||
|
||||
PaymentCryptographyKey key = service.createKey("us-east-1", attributes,
|
||||
Map.of("DeriveKey", Boolean.TRUE), true, true, Map.of());
|
||||
|
||||
assertEquals("TR31_K1_KEY_BLOCK_PROTECTION_KEY", key.getDeriveKeyUsage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void everyAsymmetricUsageTakesAKeyPair() {
|
||||
// The usages the model names for a key pair, each of which is made.
|
||||
|
||||
Reference in new issue
Block a user