Skip to content

Commit

Permalink
test: add support for generating dehydrated devices
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed Jan 16, 2025
1 parent 2cd9dc0 commit 5085c2d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions testing/matrix-sdk-test/src/test_json/keys_query_sets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ impl KeyQueryResponseTemplate {
"user_id": self.user_id.clone(),
});

if options.dehydrated {
device_keys["dehydrated"] = Value::Bool(true);
}

sign_json(&mut device_keys, ed25519_secret_key, &self.user_id, device_id.as_str());
if options.verified {
let ssk = self
Expand Down Expand Up @@ -288,6 +292,7 @@ impl KeyQueryResponseTemplate {
/// [`KeyQueryResponseTemplate`], via [`KeyQueryResponseTemplate::with_device`].
pub struct KeyQueryResponseTemplateDeviceOptions {
verified: bool,
dehydrated: bool,
}

impl KeyQueryResponseTemplateDeviceOptions {
Expand All @@ -304,6 +309,15 @@ impl KeyQueryResponseTemplateDeviceOptions {
self.verified = verified;
self
}

/// Sets the option for whether the device will be marked as "dehydrated",
/// as per [MSC3814].
///
/// [MSC3814]: https://github.com/matrix-org/matrix-spec-proposals/pull/3814
pub fn dehydrated(mut self, dehydrated: bool) -> Self {
self.dehydrated = dehydrated;
self
}
}

/// This set of keys/query response was generated using a local synapse.
Expand Down

0 comments on commit 5085c2d

Please sign in to comment.