From 1beccd81b693646e51c4cf8d31ad8492138e1e03 Mon Sep 17 00:00:00 2001 From: David Cook Date: Tue, 23 Jan 2024 15:36:16 -0600 Subject: [PATCH] Add serialization test for HpkeConfigList --- messages/src/lib.rs | 49 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/messages/src/lib.rs b/messages/src/lib.rs index f46d05241..509518408 100644 --- a/messages/src/lib.rs +++ b/messages/src/lib.rs @@ -2934,7 +2934,7 @@ mod tests { AggregationJobContinueReq, AggregationJobInitializeReq, AggregationJobResp, AggregationJobStep, BatchId, BatchSelector, Collection, CollectionReq, Duration, Extension, ExtensionType, FixedSize, FixedSizeQuery, HpkeAeadId, HpkeCiphertext, HpkeConfig, - HpkeConfigId, HpkeKdfId, HpkeKemId, HpkePublicKey, InputShareAad, Interval, + HpkeConfigId, HpkeConfigList, HpkeKdfId, HpkeKemId, HpkePublicKey, InputShareAad, Interval, PartialBatchSelector, PlaintextInputShare, PrepareContinue, PrepareError, PrepareInit, PrepareResp, PrepareStepResult, Query, Report, ReportId, ReportIdChecksum, ReportMetadata, ReportShare, Role, TaskId, Time, TimeInterval, Url, @@ -3352,6 +3352,53 @@ mod tests { ]) } + #[test] + fn roundtrip_hpke_config_list() { + roundtrip_encoding(&[( + HpkeConfigList::new(Vec::from([ + HpkeConfig::new( + HpkeConfigId::from(12), + HpkeKemId::P256HkdfSha256, + HpkeKdfId::HkdfSha512, + HpkeAeadId::Aes256Gcm, + HpkePublicKey::from(Vec::new()), + ), + HpkeConfig::new( + HpkeConfigId::from(12), + HpkeKemId::P256HkdfSha256, + HpkeKdfId::HkdfSha512, + HpkeAeadId::Other(0x9999), + HpkePublicKey::from(Vec::new()), + ), + ])), + concat!( + "0012", + concat!( + "0C", // id + "0010", // kem_id + "0003", // kdf_id + "0002", // aead_id + concat!( + // public_key + "0000", // length + "", // opaque data + ) + ), + concat!( + "0C", // id + "0010", // kem_id + "0003", // kdf_id + "9999", // aead_id + concat!( + // public_key + "0000", // length + "", // opaque data + ) + ), + ), + )]); + } + #[test] fn roundtrip_report_metadata() { roundtrip_encoding(&[