Merge branch 'master' into sas-verification
commit
7f2b268a59
|
@ -22,6 +22,7 @@ use std::path::Path;
|
|||
use std::result::Result as StdResult;
|
||||
use std::sync::Arc;
|
||||
|
||||
use matrix_sdk_common::identifiers::ServerName;
|
||||
use matrix_sdk_common::instant::{Duration, Instant};
|
||||
use matrix_sdk_common::js_int::UInt;
|
||||
use matrix_sdk_common::locks::RwLock;
|
||||
|
@ -472,7 +473,7 @@ impl Client {
|
|||
login_info: login::LoginInfo::Password {
|
||||
password: password.into(),
|
||||
},
|
||||
device_id: device_id.map(|d| d.into().into_boxed_str()),
|
||||
device_id: device_id.map(|d| d.into().into()),
|
||||
initial_device_display_name: initial_device_display_name.map(|d| d.into()),
|
||||
};
|
||||
|
||||
|
@ -562,7 +563,7 @@ impl Client {
|
|||
pub async fn join_room_by_id_or_alias(
|
||||
&self,
|
||||
alias: &RoomIdOrAliasId,
|
||||
server_names: &[String],
|
||||
server_names: &[Box<ServerName>],
|
||||
) -> Result<join_room_by_id_or_alias::Response> {
|
||||
let request = join_room_by_id_or_alias::Request {
|
||||
room_id_or_alias: alias.clone(),
|
||||
|
@ -1553,7 +1554,7 @@ mod test {
|
|||
use mockito::{mock, Matcher};
|
||||
use tempfile::tempdir;
|
||||
|
||||
use std::convert::TryFrom;
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use std::path::Path;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
|
@ -1567,7 +1568,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
@ -1632,7 +1633,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:example.com").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
@ -1660,7 +1661,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "12345".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
let homeserver = url::Url::parse(&mockito::server_url()).unwrap();
|
||||
let client = Client::new(homeserver).unwrap();
|
||||
|
@ -1772,7 +1773,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
@ -1801,7 +1802,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
@ -1819,7 +1820,7 @@ mod test {
|
|||
assert_eq!(
|
||||
// this is the `join_by_room_id::Response` but since no PartialEq we check the RoomId field
|
||||
client
|
||||
.join_room_by_id_or_alias(&room_id, &["server.com".to_string()])
|
||||
.join_room_by_id_or_alias(&room_id, &["server.com".try_into().unwrap()])
|
||||
.await
|
||||
.unwrap()
|
||||
.room_id,
|
||||
|
@ -1837,7 +1838,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: user.clone(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
@ -1864,7 +1865,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: user.clone(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
@ -1925,7 +1926,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: user.clone(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
@ -1960,7 +1961,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
@ -1996,7 +1997,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: user.clone(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
@ -2031,7 +2032,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: user.clone(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
@ -2066,7 +2067,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: user.clone(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
@ -2102,7 +2103,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id,
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
@ -2138,7 +2139,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id,
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
@ -2173,7 +2174,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: user.clone(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
@ -2217,7 +2218,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: user.clone(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
@ -2255,7 +2256,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
@ -2292,7 +2293,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
@ -2324,7 +2325,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "12345".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let homeserver = url::Url::parse(&mockito::server_url()).unwrap();
|
||||
|
@ -2358,7 +2359,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "12345".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let homeserver = url::Url::parse(&mockito::server_url()).unwrap();
|
||||
|
@ -2392,7 +2393,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@cheeky_monkey:matrix.org").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
@ -2469,7 +2470,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
@ -2499,7 +2500,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mock(
|
||||
|
|
|
@ -309,7 +309,7 @@ impl RegistrationBuilder {
|
|||
///
|
||||
/// If this does not correspond to a known client device, a new device will be created.
|
||||
/// The server will auto-generate a device_id if this is not specified.
|
||||
pub fn device_id<S: Into<Box<str>>>(&mut self, device_id: S) -> &mut Self {
|
||||
pub fn device_id<S: Into<Box<DeviceId>>>(&mut self, device_id: S) -> &mut Self {
|
||||
self.device_id = Some(device_id.into());
|
||||
self
|
||||
}
|
||||
|
@ -479,7 +479,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let mut builder = RoomBuilder::new();
|
||||
|
@ -527,7 +527,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let mut builder = MessagesRequestBuilder::new(
|
||||
|
|
|
@ -1754,13 +1754,13 @@ impl BaseClient {
|
|||
|
||||
match event {
|
||||
AnySyncEphemeralRoomEvent::FullyRead(full_read) => {
|
||||
event_emitter.on_non_room_fully_read(room, &full_read).await
|
||||
event_emitter.on_non_room_fully_read(room, full_read).await
|
||||
}
|
||||
AnySyncEphemeralRoomEvent::Typing(typing) => {
|
||||
event_emitter.on_non_room_typing(room, &typing).await
|
||||
event_emitter.on_non_room_typing(room, typing).await
|
||||
}
|
||||
AnySyncEphemeralRoomEvent::Receipt(receipt) => {
|
||||
event_emitter.on_non_room_receipt(room, &receipt).await
|
||||
event_emitter.on_non_room_receipt(room, receipt).await
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -1859,7 +1859,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
let client = BaseClient::new().unwrap();
|
||||
client.restore_login(session).await.unwrap();
|
||||
|
@ -2361,7 +2361,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@cheeky_monkey:matrix.org").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
let _m = mockito::mock(
|
||||
|
|
|
@ -37,7 +37,7 @@ use crate::events::{
|
|||
tombstone::TombstoneEventContent,
|
||||
},
|
||||
typing::TypingEventContent,
|
||||
BasicEvent, EphemeralRoomEvent, StrippedStateEvent, SyncMessageEvent, SyncStateEvent,
|
||||
BasicEvent, StrippedStateEvent, SyncEphemeralRoomEvent, SyncMessageEvent, SyncStateEvent,
|
||||
};
|
||||
use crate::{Room, RoomState};
|
||||
use matrix_sdk_common_macros::async_trait;
|
||||
|
@ -53,7 +53,7 @@ pub enum CustomOrRawEvent<'c> {
|
|||
/// A custom basic event.
|
||||
Basic(&'c BasicEvent<CustomEventContent>),
|
||||
/// A custom basic event.
|
||||
EphemeralRoom(&'c EphemeralRoomEvent<CustomEventContent>),
|
||||
EphemeralRoom(&'c SyncEphemeralRoomEvent<CustomEventContent>),
|
||||
/// A custom room event.
|
||||
Message(&'c SyncMessageEvent<CustomEventContent>),
|
||||
/// A custom state event.
|
||||
|
@ -234,15 +234,25 @@ pub trait EventEmitter: Send + Sync {
|
|||
async fn on_non_room_fully_read(
|
||||
&self,
|
||||
_: SyncRoom,
|
||||
_: &EphemeralRoomEvent<FullyReadEventContent>,
|
||||
_: &SyncEphemeralRoomEvent<FullyReadEventContent>,
|
||||
) {
|
||||
}
|
||||
/// Fires when `Client` receives a `NonRoomEvent::Typing` event.
|
||||
async fn on_non_room_typing(&self, _: SyncRoom, _: &EphemeralRoomEvent<TypingEventContent>) {}
|
||||
async fn on_non_room_typing(
|
||||
&self,
|
||||
_: SyncRoom,
|
||||
_: &SyncEphemeralRoomEvent<TypingEventContent>,
|
||||
) {
|
||||
}
|
||||
/// Fires when `Client` receives a `NonRoomEvent::Receipt` event.
|
||||
///
|
||||
/// This is always a read receipt.
|
||||
async fn on_non_room_receipt(&self, _: SyncRoom, _: &EphemeralRoomEvent<ReceiptEventContent>) {}
|
||||
async fn on_non_room_receipt(
|
||||
&self,
|
||||
_: SyncRoom,
|
||||
_: &SyncEphemeralRoomEvent<ReceiptEventContent>,
|
||||
) {
|
||||
}
|
||||
|
||||
// `PresenceEvent` is a struct so there is only the one method
|
||||
/// Fires when `Client` receives a `NonRoomEvent::RoomAliases` event.
|
||||
|
@ -435,21 +445,21 @@ mod test {
|
|||
async fn on_non_room_fully_read(
|
||||
&self,
|
||||
_: SyncRoom,
|
||||
_: &EphemeralRoomEvent<FullyReadEventContent>,
|
||||
_: &SyncEphemeralRoomEvent<FullyReadEventContent>,
|
||||
) {
|
||||
self.0.lock().await.push("account read".to_string())
|
||||
}
|
||||
async fn on_non_room_typing(
|
||||
&self,
|
||||
_: SyncRoom,
|
||||
_: &EphemeralRoomEvent<TypingEventContent>,
|
||||
_: &SyncEphemeralRoomEvent<TypingEventContent>,
|
||||
) {
|
||||
self.0.lock().await.push("typing event".to_string())
|
||||
}
|
||||
async fn on_non_room_receipt(
|
||||
&self,
|
||||
_: SyncRoom,
|
||||
_: &EphemeralRoomEvent<ReceiptEventContent>,
|
||||
_: &SyncEphemeralRoomEvent<ReceiptEventContent>,
|
||||
) {
|
||||
self.0.lock().await.push("receipt event".to_string())
|
||||
}
|
||||
|
@ -470,7 +480,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:example.com").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
let client = BaseClient::new().unwrap();
|
||||
client.restore_login(session).await.unwrap();
|
||||
|
|
|
@ -683,7 +683,7 @@ impl Room {
|
|||
msg.0 = AnyPossiblyRedactedSyncMessageEvent::Redacted(
|
||||
event
|
||||
.clone()
|
||||
.redact(redacted_event.clone(), RoomVersionId::version_6()),
|
||||
.redact(redacted_event.clone(), RoomVersionId::Version6),
|
||||
);
|
||||
}
|
||||
AnyPossiblyRedactedSyncMessageEvent::Redacted(_) => return false,
|
||||
|
@ -1097,7 +1097,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
let client = BaseClient::new().unwrap();
|
||||
client.restore_login(session).await.unwrap();
|
||||
|
@ -1605,7 +1605,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
let client = BaseClient::new().unwrap();
|
||||
client.restore_login(session).await.unwrap();
|
||||
|
@ -1629,7 +1629,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
let client = BaseClient::new().unwrap();
|
||||
client.restore_login(session).await.unwrap();
|
||||
|
@ -1679,7 +1679,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: user_id.clone(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
let client = BaseClient::new().unwrap();
|
||||
client.restore_login(session).await.unwrap();
|
||||
|
|
|
@ -171,7 +171,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@example:localhost").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
let client = BaseClient::new().unwrap();
|
||||
client.restore_login(session).await.unwrap();
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
|
||||
//! User sessions.
|
||||
|
||||
use crate::identifiers::UserId;
|
||||
use crate::identifiers::{DeviceId, UserId};
|
||||
|
||||
/// A user session, containing an access token and information about the
|
||||
/// associated user account.
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
||||
|
@ -25,5 +26,5 @@ pub struct Session {
|
|||
/// The user the access token was issued for.
|
||||
pub user_id: UserId,
|
||||
/// The ID of the client device
|
||||
pub device_id: String,
|
||||
pub device_id: Box<DeviceId>,
|
||||
}
|
||||
|
|
|
@ -239,7 +239,7 @@ mod test {
|
|||
let sess = Session {
|
||||
access_token: "32nj9zu034btz90".to_string(),
|
||||
user_id: user.clone(),
|
||||
device_id: "Tester".to_string(),
|
||||
device_id: "Tester".into(),
|
||||
};
|
||||
|
||||
let state = ClientState {
|
||||
|
@ -369,7 +369,7 @@ mod test {
|
|||
let session = Session {
|
||||
access_token: "1234".to_owned(),
|
||||
user_id: UserId::try_from("@cheeky_monkey:matrix.org").unwrap(),
|
||||
device_id: "DEVICEID".to_owned(),
|
||||
device_id: "DEVICEID".into(),
|
||||
};
|
||||
|
||||
// a sync response to populate our JSON store
|
||||
|
|
|
@ -17,7 +17,7 @@ js_int = "0.1.8"
|
|||
[dependencies.ruma]
|
||||
git = "https://github.com/ruma/ruma"
|
||||
features = ["client-api"]
|
||||
rev = "848b22568106d05c5444f3fe46070d5aa16e422b"
|
||||
rev = "9190bff1d03fb188aa1d24502129f9dd19a824e6"
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
uuid = { version = "0.8.1", features = ["v4"] }
|
||||
|
|
|
@ -163,7 +163,7 @@ impl Device {
|
|||
.get_key(KeyAlgorithm::Ed25519)
|
||||
.ok_or(SignatureError::MissingSigningKey)?;
|
||||
|
||||
verify_json(&self.user_id, &self.device_id, signing_key, json)
|
||||
verify_json(&self.user_id, &self.device_id.as_str(), signing_key, json)
|
||||
}
|
||||
|
||||
pub(crate) fn verify_device_keys(
|
||||
|
|
|
@ -1409,7 +1409,7 @@ mod test {
|
|||
|
||||
let ret = verify_json(
|
||||
&machine.user_id,
|
||||
&machine.device_id,
|
||||
machine.device_id.as_str(),
|
||||
ed25519_key,
|
||||
&mut json!(&mut device_keys),
|
||||
);
|
||||
|
@ -1440,7 +1440,7 @@ mod test {
|
|||
|
||||
let ret = verify_json(
|
||||
&machine.user_id,
|
||||
&machine.device_id,
|
||||
machine.device_id.as_str(),
|
||||
"fake_key",
|
||||
&mut json!(&mut device_keys),
|
||||
);
|
||||
|
@ -1460,7 +1460,7 @@ mod test {
|
|||
|
||||
let ret = verify_json(
|
||||
&machine.user_id,
|
||||
&machine.device_id,
|
||||
machine.device_id.as_str(),
|
||||
ed25519_key,
|
||||
&mut json!(&mut one_time_key),
|
||||
);
|
||||
|
@ -1482,7 +1482,7 @@ mod test {
|
|||
|
||||
let ret = verify_json(
|
||||
&machine.user_id,
|
||||
&machine.device_id,
|
||||
machine.device_id.as_str(),
|
||||
ed25519_key,
|
||||
&mut json!(&mut one_time_keys.as_mut().unwrap().values_mut().next()),
|
||||
);
|
||||
|
@ -1490,7 +1490,7 @@ mod test {
|
|||
|
||||
let ret = verify_json(
|
||||
&machine.user_id,
|
||||
&machine.device_id,
|
||||
machine.device_id.as_str(),
|
||||
ed25519_key,
|
||||
&mut json!(&mut device_keys.unwrap()),
|
||||
);
|
||||
|
@ -1516,7 +1516,7 @@ mod test {
|
|||
let (mut machine, _) = get_prepared_machine().await;
|
||||
let response = keys_query_response();
|
||||
let alice_id = UserId::try_from("@alice:example.org").unwrap();
|
||||
let alice_device_id = "JLAFKJWSCS".to_owned();
|
||||
let alice_device_id: &DeviceId = "JLAFKJWSCS".into();
|
||||
|
||||
let alice_devices = machine.store.get_user_devices(&alice_id).await.unwrap();
|
||||
assert!(alice_devices.devices().peekable().peek().is_none());
|
||||
|
@ -1528,12 +1528,12 @@ mod test {
|
|||
|
||||
let device = machine
|
||||
.store
|
||||
.get_device(&alice_id, &alice_device_id)
|
||||
.get_device(&alice_id, alice_device_id)
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
assert_eq!(device.user_id(), &alice_id);
|
||||
assert_eq!(device.device_id(), &alice_device_id);
|
||||
assert_eq!(device.device_id(), alice_device_id);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
|
|
@ -573,8 +573,8 @@ impl SqliteStore {
|
|||
",
|
||||
)
|
||||
.bind(account_id)
|
||||
.bind(&device.user_id().to_string())
|
||||
.bind(device.device_id())
|
||||
.bind(device.user_id().as_str())
|
||||
.bind(device.device_id().as_str())
|
||||
.bind(device.display_name())
|
||||
.bind(device.trust_state() as i64)
|
||||
.execute(&mut *connection)
|
||||
|
@ -584,8 +584,8 @@ impl SqliteStore {
|
|||
"SELECT id FROM devices
|
||||
WHERE user_id = ? and device_id = ?",
|
||||
)
|
||||
.bind(&device.user_id().to_string())
|
||||
.bind(device.device_id())
|
||||
.bind(device.user_id().as_str())
|
||||
.bind(device.device_id().as_str())
|
||||
.fetch_one(&mut *connection)
|
||||
.await?;
|
||||
|
||||
|
@ -658,7 +658,7 @@ impl CryptoStore for SqliteStore {
|
|||
WHERE user_id = ? and device_id = ?",
|
||||
)
|
||||
.bind(self.user_id.as_str())
|
||||
.bind((&*self.device_id).as_ref())
|
||||
.bind(self.device_id.as_str())
|
||||
.fetch_optional(&mut *connection)
|
||||
.await?;
|
||||
|
||||
|
@ -857,7 +857,7 @@ impl CryptoStore for SqliteStore {
|
|||
)
|
||||
.bind(account_id)
|
||||
.bind(&device.user_id().to_string())
|
||||
.bind(&device.device_id())
|
||||
.bind(device.device_id().as_str())
|
||||
.execute(&mut *connection)
|
||||
.await?;
|
||||
|
||||
|
@ -897,21 +897,27 @@ mod test {
|
|||
|
||||
use super::{Account, CryptoStore, InboundGroupSession, RoomId, Session, SqliteStore, TryFrom};
|
||||
|
||||
static USER_ID: &str = "@example:localhost";
|
||||
static DEVICE_ID: &DeviceId = "DEVICEID";
|
||||
fn example_user_id() -> UserId {
|
||||
UserId::try_from("@example:localhost").unwrap()
|
||||
}
|
||||
|
||||
fn example_device_id() -> &'static DeviceId {
|
||||
"DEVICEID".into()
|
||||
}
|
||||
|
||||
async fn get_store(passphrase: Option<&str>) -> (SqliteStore, tempfile::TempDir) {
|
||||
let tmpdir = tempdir().unwrap();
|
||||
let tmpdir_path = tmpdir.path().to_str().unwrap();
|
||||
|
||||
let user_id = &UserId::try_from(USER_ID).unwrap();
|
||||
let user_id = &example_user_id();
|
||||
let device_id = example_device_id();
|
||||
|
||||
let store = if let Some(passphrase) = passphrase {
|
||||
SqliteStore::open_with_passphrase(&user_id, DEVICE_ID, tmpdir_path, passphrase)
|
||||
SqliteStore::open_with_passphrase(&user_id, device_id, tmpdir_path, passphrase)
|
||||
.await
|
||||
.expect("Can't create a passphrase protected store")
|
||||
} else {
|
||||
SqliteStore::open(&user_id, DEVICE_ID, tmpdir_path)
|
||||
SqliteStore::open(&user_id, device_id, tmpdir_path)
|
||||
.await
|
||||
.expect("Can't create store")
|
||||
};
|
||||
|
@ -981,7 +987,7 @@ mod test {
|
|||
async fn create_store() {
|
||||
let tmpdir = tempdir().unwrap();
|
||||
let tmpdir_path = tmpdir.path().to_str().unwrap();
|
||||
let _ = SqliteStore::open(&UserId::try_from(USER_ID).unwrap(), "DEVICEID", tmpdir_path)
|
||||
let _ = SqliteStore::open(&example_user_id(), "DEVICEID".into(), tmpdir_path)
|
||||
.await
|
||||
.expect("Can't create store");
|
||||
}
|
||||
|
@ -1108,8 +1114,7 @@ mod test {
|
|||
|
||||
drop(store);
|
||||
|
||||
let mut store =
|
||||
SqliteStore::open(&UserId::try_from(USER_ID).unwrap(), DEVICE_ID, dir.path())
|
||||
let mut store = SqliteStore::open(&example_user_id(), example_device_id(), dir.path())
|
||||
.await
|
||||
.expect("Can't create store");
|
||||
|
||||
|
@ -1201,8 +1206,7 @@ mod test {
|
|||
assert!(store.users_for_key_query().contains(device.user_id()));
|
||||
drop(store);
|
||||
|
||||
let mut store =
|
||||
SqliteStore::open(&UserId::try_from(USER_ID).unwrap(), DEVICE_ID, dir.path())
|
||||
let mut store = SqliteStore::open(&example_user_id(), example_device_id(), dir.path())
|
||||
.await
|
||||
.expect("Can't create store");
|
||||
|
||||
|
@ -1218,8 +1222,7 @@ mod test {
|
|||
.unwrap();
|
||||
assert!(!store.users_for_key_query().contains(device.user_id()));
|
||||
|
||||
let mut store =
|
||||
SqliteStore::open(&UserId::try_from(USER_ID).unwrap(), DEVICE_ID, dir.path())
|
||||
let mut store = SqliteStore::open(&example_user_id(), example_device_id(), dir.path())
|
||||
.await
|
||||
.expect("Can't create store");
|
||||
|
||||
|
@ -1237,8 +1240,7 @@ mod test {
|
|||
|
||||
drop(store);
|
||||
|
||||
let mut store =
|
||||
SqliteStore::open(&UserId::try_from(USER_ID).unwrap(), DEVICE_ID, dir.path())
|
||||
let mut store = SqliteStore::open(&example_user_id(), example_device_id(), dir.path())
|
||||
.await
|
||||
.expect("Can't create store");
|
||||
|
||||
|
@ -1271,8 +1273,7 @@ mod test {
|
|||
store.save_devices(&[device.clone()]).await.unwrap();
|
||||
store.delete_device(device.clone()).await.unwrap();
|
||||
|
||||
let mut store =
|
||||
SqliteStore::open(&UserId::try_from(USER_ID).unwrap(), DEVICE_ID, dir.path())
|
||||
let mut store = SqliteStore::open(&example_user_id(), example_device_id(), dir.path())
|
||||
.await
|
||||
.expect("Can't create store");
|
||||
|
||||
|
|
Loading…
Reference in New Issue