mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2025-12-24 00:01:03 -05:00
feat(testing): add mock for get device endpoint
Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
This commit is contained in:
committed by
Damir Jelić
parent
046d8ebdd1
commit
b60b042cfe
@@ -1428,6 +1428,12 @@ impl MatrixMockServer {
|
||||
self.mock_endpoint(mock, DevicesEndpoint).expect_default_access_token()
|
||||
}
|
||||
|
||||
/// Create a prebuilt mock for the endpoint used to query a single device.
|
||||
pub fn mock_get_device(&self) -> MockEndpoint<'_, GetDeviceEndpoint> {
|
||||
let mock = Mock::given(method("GET")).and(path_regex("/_matrix/client/v3/devices/.*"));
|
||||
self.mock_endpoint(mock, GetDeviceEndpoint).expect_default_access_token()
|
||||
}
|
||||
|
||||
/// Create a prebuilt mock for the endpoint used to search in the user
|
||||
/// directory.
|
||||
pub fn mock_user_directory(&self) -> MockEndpoint<'_, UserDirectoryEndpoint> {
|
||||
@@ -4180,6 +4186,16 @@ impl<'a> MockEndpoint<'a, DevicesEndpoint> {
|
||||
}
|
||||
}
|
||||
|
||||
/// A prebuilt mock for `GET /devices/{deviceId}` requests.
|
||||
pub struct GetDeviceEndpoint;
|
||||
|
||||
impl<'a> MockEndpoint<'a, GetDeviceEndpoint> {
|
||||
/// Returns a successful response.
|
||||
pub fn ok(self) -> MatrixMock<'a> {
|
||||
self.respond_with(ResponseTemplate::new(200).set_body_json(&*test_json::DEVICE))
|
||||
}
|
||||
}
|
||||
|
||||
/// A prebuilt mock for `POST /user_directory/search` requests.
|
||||
pub struct UserDirectoryEndpoint;
|
||||
|
||||
|
||||
@@ -25,6 +25,16 @@ pub static DEVICES: Lazy<JsonValue> = Lazy::new(|| {
|
||||
})
|
||||
});
|
||||
|
||||
/// `GET /_matrix/client/v3/device/{deviceId}`
|
||||
pub static DEVICE: Lazy<JsonValue> = Lazy::new(|| {
|
||||
json!({
|
||||
"device_id": "QBUAZIFURK",
|
||||
"display_name": "android",
|
||||
"last_seen_ip": "1.2.3.4",
|
||||
"last_seen_ts": 1474491775024u64
|
||||
})
|
||||
});
|
||||
|
||||
/// `GET /_matrix/client/v3/directory/room/{roomAlias}`
|
||||
pub static GET_ALIAS: Lazy<JsonValue> = Lazy::new(|| {
|
||||
json!({
|
||||
|
||||
@@ -18,7 +18,7 @@ pub mod sync;
|
||||
pub mod sync_events;
|
||||
|
||||
pub use api_responses::{
|
||||
DEVICES, GET_ALIAS, KEYS_QUERY, KEYS_QUERY_TWO_DEVICES_ONE_SIGNED, KEYS_UPLOAD, LOGIN,
|
||||
DEVICE, DEVICES, GET_ALIAS, KEYS_QUERY, KEYS_QUERY_TWO_DEVICES_ONE_SIGNED, KEYS_UPLOAD, LOGIN,
|
||||
LOGIN_RESPONSE_ERR, LOGIN_TYPES, LOGIN_WITH_DISCOVERY, LOGIN_WITH_REFRESH_TOKEN, NOT_FOUND,
|
||||
PUBLIC_ROOMS, PUBLIC_ROOMS_FINAL_PAGE, REFRESH_TOKEN, REFRESH_TOKEN_WITH_REFRESH_TOKEN,
|
||||
REGISTRATION_RESPONSE_ERR, UNKNOWN_TOKEN_SOFT_LOGOUT, VERSIONS, WELL_KNOWN, WHOAMI,
|
||||
|
||||
Reference in New Issue
Block a user