feat(sdk): Rename state encryption methods for improved clarity

Changes `Room::enable_encryption_with_state` to
`Room::enable_encryption_with_encrypted_state_events`, and updates the
respective unit test and testing utilities.

Signed-off-by: Skye Elliot <actuallyori@gmail.com>
This commit is contained in:
Skye Elliot
2025-08-20 11:06:50 +01:00
committed by Ivan Enderlin
parent 7920723bb4
commit 7adaf7be73
5 changed files with 14 additions and 13 deletions

View File

@@ -2000,13 +2000,13 @@ impl Room {
/// let room_id = room_id!("!SVkFJHzfwvuaIEawgC:localhost");
///
/// if let Some(room) = client.get_room(&room_id) {
/// room.enable_encryption_with_state().await?
/// room.enable_encryption_with_state_event_encryption().await?
/// }
/// # anyhow::Ok(()) };
/// ```
#[instrument(skip_all)]
#[cfg(feature = "experimental-encrypted-state-events")]
pub async fn enable_encryption_with_state(&self) -> Result<()> {
pub async fn enable_encryption_with_state_event_encryption(&self) -> Result<()> {
self.enable_encryption_inner(true).await
}

View File

@@ -2457,10 +2457,9 @@ impl<'a> MockEndpoint<'a, EncryptionStateEndpoint> {
/// # anyhow::Ok(()) });
#[cfg(feature = "experimental-encrypted-state-events")]
pub fn state_encrypted(self) -> MatrixMock<'a> {
self.respond_with(
ResponseTemplate::new(200)
.set_body_json(&*test_json::sync_events::ENCRYPTION_WITH_STATE_CONTENT),
)
self.respond_with(ResponseTemplate::new(200).set_body_json(
&*test_json::sync_events::ENCRYPTION_WITH_ENCRYPTED_STATE_EVENTS_CONTENT,
))
}
/// Marks the room as not encrypted.

View File

@@ -1133,7 +1133,9 @@ async fn test_enable_state_encryption_doesnt_stay_unknown() {
assert_matches!(room.latest_encryption_state().await.unwrap(), EncryptionState::NotEncrypted);
room.enable_encryption_with_state().await.expect("enabling encryption should work");
room.enable_encryption_with_state_event_encryption()
.await
.expect("enabling encryption should work");
mock.verify_and_reset().await;
mock.mock_room_state_encryption().state_encrypted().mount().await;

View File

@@ -15,7 +15,7 @@ pub enum StateTestEvent {
Aliases,
Create,
Encryption,
EncryptionWithState,
EncryptionWithEncryptedStateEvents,
HistoryVisibility,
JoinRules,
Member,
@@ -41,8 +41,8 @@ impl From<StateTestEvent> for JsonValue {
StateTestEvent::Aliases => test_json::sync_events::ALIASES.to_owned(),
StateTestEvent::Create => test_json::sync_events::CREATE.to_owned(),
StateTestEvent::Encryption => test_json::sync_events::ENCRYPTION.to_owned(),
StateTestEvent::EncryptionWithState => {
test_json::sync_events::ENCRYPTION_WITH_STATE.to_owned()
StateTestEvent::EncryptionWithEncryptedStateEvents => {
test_json::sync_events::ENCRYPTION_WITH_ENCRYPTED_STATE_EVENTS.to_owned()
}
StateTestEvent::HistoryVisibility => {
test_json::sync_events::HISTORY_VISIBILITY.to_owned()

View File

@@ -138,7 +138,7 @@ pub static ENCRYPTION: Lazy<JsonValue> = Lazy::new(|| {
})
});
pub static ENCRYPTION_WITH_STATE_CONTENT: Lazy<JsonValue> = Lazy::new(|| {
pub static ENCRYPTION_WITH_ENCRYPTED_STATE_EVENTS_CONTENT: Lazy<JsonValue> = Lazy::new(|| {
json!({
"algorithm": "m.megolm.v1.aes-sha2",
"rotation_period_ms": 604800000,
@@ -147,9 +147,9 @@ pub static ENCRYPTION_WITH_STATE_CONTENT: Lazy<JsonValue> = Lazy::new(|| {
})
});
pub static ENCRYPTION_WITH_STATE: Lazy<JsonValue> = Lazy::new(|| {
pub static ENCRYPTION_WITH_ENCRYPTED_STATE_EVENTS: Lazy<JsonValue> = Lazy::new(|| {
json!({
"content": *ENCRYPTION_WITH_STATE_CONTENT,
"content": *ENCRYPTION_WITH_ENCRYPTED_STATE_EVENTS_CONTENT,
"event_id": "$143273582443PhrSn:example.org",
"origin_server_ts": 1432735824653u64,
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",