client-api: Fix get_login_types::CustomLoginType
Add test for it.
This commit is contained in:
parent
9ee0436eb8
commit
fac7d53134
@ -1,5 +1,9 @@
|
|||||||
# [unreleased]
|
# [unreleased]
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
* Fix deserialization of `r0::session::get_login_types::CustomLoginType`.
|
||||||
|
|
||||||
Breaking changes:
|
Breaking changes:
|
||||||
|
|
||||||
* Use an enum for user-interactive auth stage type (used to be `&str` / `String`)
|
* Use an enum for user-interactive auth stage type (used to be `&str` / `String`)
|
||||||
|
@ -242,7 +242,7 @@ pub struct CustomLoginType {
|
|||||||
///
|
///
|
||||||
/// This field is named `type_` instead of `type` because the latter is a reserved
|
/// This field is named `type_` instead of `type` because the latter is a reserved
|
||||||
/// keyword in Rust.
|
/// keyword in Rust.
|
||||||
#[serde(rename = "override")]
|
#[serde(rename = "type")]
|
||||||
pub type_: String,
|
pub type_: String,
|
||||||
|
|
||||||
/// Remaining type content
|
/// Remaining type content
|
||||||
@ -260,9 +260,9 @@ mod tests {
|
|||||||
use serde_json::to_value as to_json_value;
|
use serde_json::to_value as to_json_value;
|
||||||
use serde_json::{from_value as from_json_value, json};
|
use serde_json::{from_value as from_json_value, json};
|
||||||
|
|
||||||
|
use super::{CustomLoginType, LoginType, PasswordLoginType};
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
use super::{IdentityProvider, IdentityProviderBrand, SsoLoginType, TokenLoginType};
|
use super::{IdentityProvider, IdentityProviderBrand, SsoLoginType, TokenLoginType};
|
||||||
use super::{LoginType, PasswordLoginType};
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
struct Wrapper {
|
struct Wrapper {
|
||||||
@ -283,6 +283,28 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn deserialize_custom_login_type() {
|
||||||
|
assert_matches!(
|
||||||
|
from_json_value::<Wrapper>(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]
|
#[test]
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
fn deserialize_sso_login_type() {
|
fn deserialize_sso_login_type() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user