mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
fix(room_member): Strip join_authorized_via_users_server (#1542)
Added test. Signed-off-by: Jonathan Sutton <jonathansutton91@proton.me>
This commit is contained in:
committed by
Ellis Git
parent
e94e614498
commit
0338539221
@@ -1,3 +1,5 @@
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
use axum::extract::State;
|
||||
use axum_client_ip::InsecureClientIp;
|
||||
use conduwuit::{
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_strip_room_member() -> Result<()> {
|
||||
//Test setup
|
||||
let body = r#"
|
||||
{
|
||||
"avatar_url": "Something",
|
||||
"displayname": "Someone",
|
||||
"join_authorized_via_users_server": "@someone:domain.tld",
|
||||
"membership": "join"
|
||||
}"#;
|
||||
println!("JSON (original): {body}");
|
||||
let json: &mut Raw<AnyStateEventContent> =
|
||||
&mut Raw::<AnyStateEventContent>::from_json_string(body.to_string())?;
|
||||
let mut membership_content: RoomMemberEventContent =
|
||||
json.deserialize_as::<RoomMemberEventContent>()?;
|
||||
|
||||
//Begin Test
|
||||
membership_content.join_authorized_via_users_server = None;
|
||||
*json = Raw::<AnyStateEventContent>::from_json_string(serde_json::to_string(
|
||||
&membership_content,
|
||||
)?)?;
|
||||
|
||||
//Compare result
|
||||
let result = json.json().get();
|
||||
println!("JSON (modified): {result}");
|
||||
assert_eq!(
|
||||
result,
|
||||
r#"{"avatar_url":"Something","displayname":"Someone","membership":"join"}"#
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user