diff --git a/crates/ruma-client-api/CHANGELOG.md b/crates/ruma-client-api/CHANGELOG.md index 5ce8d9d0..a430aa67 100644 --- a/crates/ruma-client-api/CHANGELOG.md +++ b/crates/ruma-client-api/CHANGELOG.md @@ -1,5 +1,9 @@ # [unreleased] +Bug fixes: + +* Fix deserialization of `r0::session::get_login_types::CustomLoginType`. + Breaking changes: * Use an enum for user-interactive auth stage type (used to be `&str` / `String`) diff --git a/crates/ruma-client-api/src/r0/session/get_login_types.rs b/crates/ruma-client-api/src/r0/session/get_login_types.rs index 020b45bb..f556a4ca 100644 --- a/crates/ruma-client-api/src/r0/session/get_login_types.rs +++ b/crates/ruma-client-api/src/r0/session/get_login_types.rs @@ -242,7 +242,7 @@ pub struct CustomLoginType { /// /// This field is named `type_` instead of `type` because the latter is a reserved /// keyword in Rust. - #[serde(rename = "override")] + #[serde(rename = "type")] pub type_: String, /// Remaining type content @@ -260,9 +260,9 @@ mod tests { use serde_json::to_value as to_json_value; use serde_json::{from_value as from_json_value, json}; + use super::{CustomLoginType, LoginType, PasswordLoginType}; #[cfg(feature = "unstable-pre-spec")] use super::{IdentityProvider, IdentityProviderBrand, SsoLoginType, TokenLoginType}; - use super::{LoginType, PasswordLoginType}; #[derive(Debug, Deserialize, Serialize)] struct Wrapper { @@ -283,6 +283,28 @@ mod tests { ); } + #[test] + fn deserialize_custom_login_type() { + assert_matches!( + from_json_value::(json!({ + "flows": [ + { + "type": "io.ruma.custom", + "color": "green", + } + ], + })), + Ok(Wrapper { flows }) + if flows.len() == 1 + && matches!( + &flows[0], + LoginType::_Custom(CustomLoginType { type_, data }) + if type_ == "io.ruma.custom" + && data == json!({ "color": "green" }).as_object().unwrap() + ) + ); + } + #[test] #[cfg(feature = "unstable-pre-spec")] fn deserialize_sso_login_type() {