Rerun cargo fmt
This commit is contained in:
parent
1df77c2c19
commit
50b74e2b76
@ -202,13 +202,7 @@ impl EndpointError for Error {
|
|||||||
|
|
||||||
impl Display for Error {
|
impl Display for Error {
|
||||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||||
write!(
|
write!(f, "[{} / {}] {}", self.status_code.as_u16(), self.kind, self.message)
|
||||||
f,
|
|
||||||
"[{} / {}] {}",
|
|
||||||
self.status_code.as_u16(),
|
|
||||||
self.kind,
|
|
||||||
self.message
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,21 +210,14 @@ impl std::error::Error for Error {}
|
|||||||
|
|
||||||
impl From<Error> for ErrorBody {
|
impl From<Error> for ErrorBody {
|
||||||
fn from(error: Error) -> Self {
|
fn from(error: Error) -> Self {
|
||||||
Self {
|
Self { kind: error.kind, message: error.message }
|
||||||
kind: error.kind,
|
|
||||||
message: error.message,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ErrorBody {
|
impl ErrorBody {
|
||||||
/// Convert the ErrorBody into an Error by adding the http status code.
|
/// Convert the ErrorBody into an Error by adding the http status code.
|
||||||
pub fn into_error(self, status_code: http::StatusCode) -> Error {
|
pub fn into_error(self, status_code: http::StatusCode) -> Error {
|
||||||
Error {
|
Error { kind: self.kind, message: self.message, status_code }
|
||||||
kind: self.kind,
|
|
||||||
message: self.message,
|
|
||||||
status_code,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,11 +2,7 @@
|
|||||||
//! endpoint in the [Matrix](https://matrix.org/) client API specification. These types can be
|
//! endpoint in the [Matrix](https://matrix.org/) client API specification. These types can be
|
||||||
//! shared by client and server code.
|
//! shared by client and server code.
|
||||||
|
|
||||||
#![deny(
|
#![deny(missing_copy_implementations, missing_debug_implementations, missing_docs)]
|
||||||
missing_copy_implementations,
|
|
||||||
missing_debug_implementations,
|
|
||||||
missing_docs
|
|
||||||
)]
|
|
||||||
|
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod r0;
|
pub mod r0;
|
||||||
|
@ -72,13 +72,7 @@ mod tests {
|
|||||||
"added_at": 1_535_336_848_756u64
|
"added_at": 1_535_336_848_756u64
|
||||||
});
|
});
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(to_json_value(third_party_id.clone()).unwrap(), third_party_id_serialized);
|
||||||
to_json_value(third_party_id.clone()).unwrap(),
|
assert_eq!(third_party_id, from_json_value(third_party_id_serialized).unwrap());
|
||||||
third_party_id_serialized
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
third_party_id,
|
|
||||||
from_json_value(third_party_id_serialized).unwrap()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,10 +187,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_deserialize_matrix_network_only() {
|
fn test_deserialize_matrix_network_only() {
|
||||||
let json = json!({ "include_all_networks": false });
|
let json = json!({ "include_all_networks": false });
|
||||||
assert_eq!(
|
assert_eq!(from_json_value::<RoomNetwork>(json).unwrap(), RoomNetwork::Matrix);
|
||||||
from_json_value::<RoomNetwork>(json).unwrap(),
|
|
||||||
RoomNetwork::Matrix
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -202,10 +199,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_deserialize_empty_network_is_default() {
|
fn test_deserialize_empty_network_is_default() {
|
||||||
let json = json!({});
|
let json = json!({});
|
||||||
assert_eq!(
|
assert_eq!(from_json_value::<RoomNetwork>(json).unwrap(), RoomNetwork::default());
|
||||||
from_json_value::<RoomNetwork>(json).unwrap(),
|
|
||||||
RoomNetwork::default()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -217,19 +211,13 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_deserialize_include_all_networks() {
|
fn test_deserialize_include_all_networks() {
|
||||||
let json = json!({ "include_all_networks": true });
|
let json = json!({ "include_all_networks": true });
|
||||||
assert_eq!(
|
assert_eq!(from_json_value::<RoomNetwork>(json).unwrap(), RoomNetwork::All);
|
||||||
from_json_value::<RoomNetwork>(json).unwrap(),
|
|
||||||
RoomNetwork::All
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_serialize_third_party_network() {
|
fn test_serialize_third_party_network() {
|
||||||
let json = json!({ "third_party_instance_id": "freenode" });
|
let json = json!({ "third_party_instance_id": "freenode" });
|
||||||
assert_eq!(
|
assert_eq!(to_json_value(RoomNetwork::ThirdParty("freenode".to_string())).unwrap(), json);
|
||||||
to_json_value(RoomNetwork::ThirdParty("freenode".to_string())).unwrap(),
|
|
||||||
json
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -245,10 +233,7 @@ mod tests {
|
|||||||
fn test_deserialize_include_all_networks_and_third_party_exclusivity() {
|
fn test_deserialize_include_all_networks_and_third_party_exclusivity() {
|
||||||
let json = json!({ "include_all_networks": true, "third_party_instance_id": "freenode" });
|
let json = json!({ "include_all_networks": true, "third_party_instance_id": "freenode" });
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
from_json_value::<RoomNetwork>(json)
|
from_json_value::<RoomNetwork>(json).unwrap_err().to_string().as_str(),
|
||||||
.unwrap_err()
|
|
||||||
.to_string()
|
|
||||||
.as_str(),
|
|
||||||
"`include_all_networks = true` and `third_party_instance_id` are mutually exclusive."
|
"`include_all_networks = true` and `third_party_instance_id` are mutually exclusive."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -87,10 +87,7 @@ pub struct RoomEventFilter {
|
|||||||
impl RoomEventFilter {
|
impl RoomEventFilter {
|
||||||
/// A filter that can be used to ignore all room events
|
/// A filter that can be used to ignore all room events
|
||||||
pub fn ignore_all() -> Self {
|
pub fn ignore_all() -> Self {
|
||||||
Self {
|
Self { types: Some(vec![]), ..Default::default() }
|
||||||
types: Some(vec![]),
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,10 +136,7 @@ pub struct RoomFilter {
|
|||||||
impl RoomFilter {
|
impl RoomFilter {
|
||||||
/// A filter that can be used to ignore all room events (of any type)
|
/// A filter that can be used to ignore all room events (of any type)
|
||||||
pub fn ignore_all() -> Self {
|
pub fn ignore_all() -> Self {
|
||||||
Self {
|
Self { rooms: Some(vec![]), ..Default::default() }
|
||||||
rooms: Some(vec![]),
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,10 +179,7 @@ pub struct Filter {
|
|||||||
impl Filter {
|
impl Filter {
|
||||||
/// A filter that can be used to ignore all events
|
/// A filter that can be used to ignore all events
|
||||||
pub fn ignore_all() -> Self {
|
pub fn ignore_all() -> Self {
|
||||||
Self {
|
Self { types: Some(vec![]), ..Default::default() }
|
||||||
types: Some(vec![]),
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,9 +251,7 @@ impl Serialize for LazyLoadOptions {
|
|||||||
{
|
{
|
||||||
let mut state;
|
let mut state;
|
||||||
match *self {
|
match *self {
|
||||||
Self::Enabled {
|
Self::Enabled { include_redundant_members: true } => {
|
||||||
include_redundant_members: true,
|
|
||||||
} => {
|
|
||||||
state = serializer.serialize_struct("LazyLoad", 2)?;
|
state = serializer.serialize_struct("LazyLoad", 2)?;
|
||||||
state.serialize_field("lazy_load_members", &true)?;
|
state.serialize_field("lazy_load_members", &true)?;
|
||||||
state.serialize_field("include_redundant_members", &true)?;
|
state.serialize_field("include_redundant_members", &true)?;
|
||||||
@ -309,9 +298,7 @@ impl<'de> Visitor<'de> for LazyLoadOptionsVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ok(if lazy_load_members {
|
Ok(if lazy_load_members {
|
||||||
LazyLoadOptions::Enabled {
|
LazyLoadOptions::Enabled { include_redundant_members }
|
||||||
include_redundant_members,
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
LazyLoadOptions::Disabled
|
LazyLoadOptions::Disabled
|
||||||
})
|
})
|
||||||
@ -341,20 +328,13 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_serializing_lazy_load_no_redundant() {
|
fn test_serializing_lazy_load_no_redundant() {
|
||||||
let lazy_load_options = LazyLoadOptions::Enabled {
|
let lazy_load_options = LazyLoadOptions::Enabled { include_redundant_members: false };
|
||||||
include_redundant_members: false,
|
assert_eq!(to_json_value(lazy_load_options).unwrap(), json!({ "lazy_load_members": true }));
|
||||||
};
|
|
||||||
assert_eq!(
|
|
||||||
to_json_value(lazy_load_options).unwrap(),
|
|
||||||
json!({ "lazy_load_members": true })
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_serializing_lazy_load_with_redundant() {
|
fn test_serializing_lazy_load_with_redundant() {
|
||||||
let lazy_load_options = LazyLoadOptions::Enabled {
|
let lazy_load_options = LazyLoadOptions::Enabled { include_redundant_members: true };
|
||||||
include_redundant_members: true,
|
|
||||||
};
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
to_json_value(lazy_load_options).unwrap(),
|
to_json_value(lazy_load_options).unwrap(),
|
||||||
json!({ "lazy_load_members": true, "include_redundant_members": true })
|
json!({ "lazy_load_members": true, "include_redundant_members": true })
|
||||||
@ -364,18 +344,12 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_deserializing_no_lazy_load() {
|
fn test_deserializing_no_lazy_load() {
|
||||||
let json = json!({});
|
let json = json!({});
|
||||||
assert_eq!(
|
assert_eq!(from_json_value::<LazyLoadOptions>(json).unwrap(), LazyLoadOptions::Disabled,);
|
||||||
from_json_value::<LazyLoadOptions>(json).unwrap(),
|
|
||||||
LazyLoadOptions::Disabled,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_deserializing_ignore_redundant_members_when_no_lazy_load() {
|
fn test_deserializing_ignore_redundant_members_when_no_lazy_load() {
|
||||||
let json = json!({ "include_redundant_members": true });
|
let json = json!({ "include_redundant_members": true });
|
||||||
assert_eq!(
|
assert_eq!(from_json_value::<LazyLoadOptions>(json).unwrap(), LazyLoadOptions::Disabled,);
|
||||||
from_json_value::<LazyLoadOptions>(json).unwrap(),
|
|
||||||
LazyLoadOptions::Disabled,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,10 +103,9 @@ impl<'de> Deserialize<'de> for AlgorithmAndDeviceId {
|
|||||||
let algorithm_result = KeyAlgorithm::try_from(parts[0]);
|
let algorithm_result = KeyAlgorithm::try_from(parts[0]);
|
||||||
match algorithm_result {
|
match algorithm_result {
|
||||||
Ok(algorithm) => Ok(AlgorithmAndDeviceId(algorithm, parts[1].to_string())),
|
Ok(algorithm) => Ok(AlgorithmAndDeviceId(algorithm, parts[1].to_string())),
|
||||||
Err(_) => Err(de::Error::invalid_value(
|
Err(_) => {
|
||||||
Unexpected::Str(parts[0]),
|
Err(de::Error::invalid_value(Unexpected::Str(parts[0]), &"valid key algorithm"))
|
||||||
&"valid key algorithm",
|
}
|
||||||
)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,15 +51,9 @@ mod tests {
|
|||||||
fn raw_json_deserialize() {
|
fn raw_json_deserialize() {
|
||||||
type OptRawJson = Option<Box<RawJsonValue>>;
|
type OptRawJson = Option<Box<RawJsonValue>>;
|
||||||
|
|
||||||
assert!(from_json_value::<OptRawJson>(json!(null))
|
assert!(from_json_value::<OptRawJson>(json!(null)).unwrap().is_none());
|
||||||
.unwrap()
|
assert!(from_json_value::<OptRawJson>(json!("test")).unwrap().is_some());
|
||||||
.is_none());
|
assert!(from_json_value::<OptRawJson>(json!({ "a": "b" })).unwrap().is_some());
|
||||||
assert!(from_json_value::<OptRawJson>(json!("test"))
|
|
||||||
.unwrap()
|
|
||||||
.is_some());
|
|
||||||
assert!(from_json_value::<OptRawJson>(json!({ "a": "b" }))
|
|
||||||
.unwrap()
|
|
||||||
.is_some());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// For completeness sake, make sure serialization works too
|
// For completeness sake, make sure serialization works too
|
||||||
|
@ -112,9 +112,7 @@ mod tests {
|
|||||||
fn test_serialize_some_room_event_filter() {
|
fn test_serialize_some_room_event_filter() {
|
||||||
let room_id = RoomId::try_from("!roomid:example.org").unwrap();
|
let room_id = RoomId::try_from("!roomid:example.org").unwrap();
|
||||||
let filter = RoomEventFilter {
|
let filter = RoomEventFilter {
|
||||||
lazy_load_options: LazyLoadOptions::Enabled {
|
lazy_load_options: LazyLoadOptions::Enabled { include_redundant_members: true },
|
||||||
include_redundant_members: true,
|
|
||||||
},
|
|
||||||
rooms: Some(vec![room_id.clone()]),
|
rooms: Some(vec![room_id.clone()]),
|
||||||
not_rooms: vec!["room".into(), "room2".into(), "room3".into()],
|
not_rooms: vec!["room".into(), "room2".into(), "room3".into()],
|
||||||
not_types: vec!["type".into()],
|
not_types: vec!["type".into()],
|
||||||
@ -149,10 +147,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let request: http::Request<Vec<u8>> = req.try_into().unwrap();
|
let request: http::Request<Vec<u8>> = req.try_into().unwrap();
|
||||||
assert_eq!(
|
assert_eq!("from=token&to=token2&dir=b&limit=0", request.uri().query().unwrap(),);
|
||||||
"from=token&to=token2&dir=b&limit=0",
|
|
||||||
request.uri().query().unwrap(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -116,19 +116,11 @@ impl CreationContent {
|
|||||||
/// Given a `CreationContent` and the other fields that a homeserver has to fill, construct
|
/// Given a `CreationContent` and the other fields that a homeserver has to fill, construct
|
||||||
/// a `CreateEventContent`.
|
/// a `CreateEventContent`.
|
||||||
pub fn into_event_content(
|
pub fn into_event_content(
|
||||||
Self {
|
Self { federate, predecessor }: Self,
|
||||||
federate,
|
|
||||||
predecessor,
|
|
||||||
}: Self,
|
|
||||||
creator: UserId,
|
creator: UserId,
|
||||||
room_version: RoomVersionId,
|
room_version: RoomVersionId,
|
||||||
) -> CreateEventContent {
|
) -> CreateEventContent {
|
||||||
CreateEventContent {
|
CreateEventContent { creator, federate, room_version, predecessor }
|
||||||
creator,
|
|
||||||
federate,
|
|
||||||
room_version,
|
|
||||||
predecessor,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,9 +155,7 @@ mod tests {
|
|||||||
"password": "ilovebananas"
|
"password": "ilovebananas"
|
||||||
}),)
|
}),)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
LoginInfo::Password {
|
LoginInfo::Password { password: "ilovebananas".into() }
|
||||||
password: "ilovebananas".into()
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -166,9 +164,7 @@ mod tests {
|
|||||||
"token": "1234567890abcdef"
|
"token": "1234567890abcdef"
|
||||||
}),)
|
}),)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
LoginInfo::Token {
|
LoginInfo::Token { token: "1234567890abcdef".into() }
|
||||||
token: "1234567890abcdef".into()
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,9 +189,7 @@ mod tests {
|
|||||||
address: "hello@example.com".to_owned(),
|
address: "hello@example.com".to_owned(),
|
||||||
medium: Medium::Email,
|
medium: Medium::Email,
|
||||||
},
|
},
|
||||||
login_info: LoginInfo::Token {
|
login_info: LoginInfo::Token { token: "0xdeadbeef".to_owned() },
|
||||||
token: "0xdeadbeef".to_owned(),
|
|
||||||
},
|
|
||||||
device_id: None,
|
device_id: None,
|
||||||
initial_device_display_name: Some("test".to_string()),
|
initial_device_display_name: Some("test".to_string()),
|
||||||
}
|
}
|
||||||
|
@ -28,15 +28,13 @@ impl From<super::UserInfo> for UserInfo {
|
|||||||
use super::UserInfo::*;
|
use super::UserInfo::*;
|
||||||
|
|
||||||
match info {
|
match info {
|
||||||
MatrixId(user) => UserInfo {
|
MatrixId(user) => UserInfo { identifier: UserIdentifier::MatrixId { user } },
|
||||||
identifier: UserIdentifier::MatrixId { user },
|
ThirdPartyId { address, medium } => {
|
||||||
},
|
UserInfo { identifier: UserIdentifier::ThirdPartyId { address, medium } }
|
||||||
ThirdPartyId { address, medium } => UserInfo {
|
}
|
||||||
identifier: UserIdentifier::ThirdPartyId { address, medium },
|
PhoneNumber { country, phone } => {
|
||||||
},
|
UserInfo { identifier: UserIdentifier::PhoneNumber { country, phone } }
|
||||||
PhoneNumber { country, phone } => UserInfo {
|
}
|
||||||
identifier: UserIdentifier::PhoneNumber { country, phone },
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,19 +253,13 @@ pub struct RoomSummary {
|
|||||||
/// Number of users whose membership status is `join`.
|
/// Number of users whose membership status is `join`.
|
||||||
/// Required if field has changed since last sync; otherwise, it may be
|
/// Required if field has changed since last sync; otherwise, it may be
|
||||||
/// omitted.
|
/// omitted.
|
||||||
#[serde(
|
#[serde(rename = "m.joined_member_count", skip_serializing_if = "Option::is_none")]
|
||||||
rename = "m.joined_member_count",
|
|
||||||
skip_serializing_if = "Option::is_none"
|
|
||||||
)]
|
|
||||||
pub joined_member_count: Option<UInt>,
|
pub joined_member_count: Option<UInt>,
|
||||||
|
|
||||||
/// Number of users whose membership status is `invite`.
|
/// Number of users whose membership status is `invite`.
|
||||||
/// Required if field has changed since last sync; otherwise, it may be
|
/// Required if field has changed since last sync; otherwise, it may be
|
||||||
/// omitted.
|
/// omitted.
|
||||||
#[serde(
|
#[serde(rename = "m.invited_member_count", skip_serializing_if = "Option::is_none")]
|
||||||
rename = "m.invited_member_count",
|
|
||||||
skip_serializing_if = "Option::is_none"
|
|
||||||
)]
|
|
||||||
pub invited_member_count: Option<UInt>,
|
pub invited_member_count: Option<UInt>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,12 +364,8 @@ mod tests {
|
|||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let req: Request = http::Request::builder()
|
let req: Request =
|
||||||
.uri(uri)
|
http::Request::builder().uri(uri).body(Vec::<u8>::new()).unwrap().try_into().unwrap();
|
||||||
.body(Vec::<u8>::new())
|
|
||||||
.unwrap()
|
|
||||||
.try_into()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_matches!(req.filter, Some(Filter::FilterId(id)) if id == "myfilter");
|
assert_matches!(req.filter, Some(Filter::FilterId(id)) if id == "myfilter");
|
||||||
assert_eq!(req.since, Some("myts".into()));
|
assert_eq!(req.since, Some("myts".into()));
|
||||||
@ -393,12 +383,8 @@ mod tests {
|
|||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let req: Request = http::Request::builder()
|
let req: Request =
|
||||||
.uri(uri)
|
http::Request::builder().uri(uri).body(Vec::<u8>::new()).unwrap().try_into().unwrap();
|
||||||
.body(Vec::<u8>::new())
|
|
||||||
.unwrap()
|
|
||||||
.try_into()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_matches!(req.filter, None);
|
assert_matches!(req.filter, None);
|
||||||
assert_eq!(req.since, None);
|
assert_eq!(req.since, None);
|
||||||
@ -420,12 +406,8 @@ mod tests {
|
|||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let req: Request = http::Request::builder()
|
let req: Request =
|
||||||
.uri(uri)
|
http::Request::builder().uri(uri).body(Vec::<u8>::new()).unwrap().try_into().unwrap();
|
||||||
.body(Vec::<u8>::new())
|
|
||||||
.unwrap()
|
|
||||||
.try_into()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_matches!(req.filter, Some(Filter::FilterId(id)) if id == "EOKFFmdZYF");
|
assert_matches!(req.filter, Some(Filter::FilterId(id)) if id == "EOKFFmdZYF");
|
||||||
assert_eq!(req.since, None);
|
assert_eq!(req.since, None);
|
||||||
|
@ -40,9 +40,7 @@ impl TryFrom<&str> for DeviceIdOrAllDevices {
|
|||||||
} else if "*" == device_id_or_all_devices {
|
} else if "*" == device_id_or_all_devices {
|
||||||
Ok(DeviceIdOrAllDevices::AllDevices)
|
Ok(DeviceIdOrAllDevices::AllDevices)
|
||||||
} else {
|
} else {
|
||||||
Ok(DeviceIdOrAllDevices::DeviceId(
|
Ok(DeviceIdOrAllDevices::DeviceId(device_id_or_all_devices.to_string()))
|
||||||
device_id_or_all_devices.to_string(),
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,14 +187,10 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_serialize_authentication_data_fallback() {
|
fn test_serialize_authentication_data_fallback() {
|
||||||
let authentication_data = AuthData::FallbackAcknowledgement {
|
let authentication_data =
|
||||||
session: "ZXY000".to_string(),
|
AuthData::FallbackAcknowledgement { session: "ZXY000".to_string() };
|
||||||
};
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(json!({ "session": "ZXY000" }), to_json_value(authentication_data).unwrap());
|
||||||
json!({ "session": "ZXY000" }),
|
|
||||||
to_json_value(authentication_data).unwrap()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -331,10 +327,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(uiaa_response.status(), http::status::StatusCode::UNAUTHORIZED);
|
||||||
uiaa_response.status(),
|
|
||||||
http::status::StatusCode::UNAUTHORIZED
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user