client-api: Fix sso_login query param serialization

This commit is contained in:
Kévin Commaille 2021-03-15 12:15:43 +01:00 committed by GitHub
parent 02e6c935b3
commit 92ee92ad7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,7 @@ ruma_api! {
/// URL to which the homeserver should return the user after completing
/// authentication with the SSO identity provider.
#[ruma_api(query)]
#[serde(rename = "redirectUrl")]
pub redirect_url: &'a str,
}
@ -42,3 +43,22 @@ impl Response {
Self { location }
}
}
#[cfg(test)]
mod tests {
use ruma_api::OutgoingRequest;
use super::Request;
#[test]
fn serialize_sso_login_request_uri() {
let req: http::Request<Vec<u8>> = Request { redirect_url: "https://example.com/sso" }
.try_into_http_request("https://homeserver.tld", None)
.unwrap();
assert_eq!(
req.uri().to_string(),
"https://homeserver.tld/_matrix/client/r0/login/sso/redirect?redirectUrl=https%3A%2F%2Fexample.com%2Fsso"
);
}
}