Merge branch 'fix_register_error'
commit
98ee4a3bca
|
@ -2566,10 +2566,13 @@ mod test {
|
||||||
let homeserver = Url::from_str(&mockito::server_url()).unwrap();
|
let homeserver = Url::from_str(&mockito::server_url()).unwrap();
|
||||||
let client = Client::new(homeserver).unwrap();
|
let client = Client::new(homeserver).unwrap();
|
||||||
|
|
||||||
let _m = mock("POST", "/_matrix/client/r0/register")
|
let _m = mock(
|
||||||
.with_status(403)
|
"POST",
|
||||||
.with_body(test_json::REGISTRATION_RESPONSE_ERR.to_string())
|
Matcher::Regex(r"^/_matrix/client/r0/register\?.*$".to_string()),
|
||||||
.create();
|
)
|
||||||
|
.with_status(403)
|
||||||
|
.with_body(test_json::REGISTRATION_RESPONSE_ERR.to_string())
|
||||||
|
.create();
|
||||||
|
|
||||||
let user = assign!(RegistrationRequest::new(), {
|
let user = assign!(RegistrationRequest::new(), {
|
||||||
username: Some("user"),
|
username: Some("user"),
|
||||||
|
@ -2580,14 +2583,27 @@ mod test {
|
||||||
|
|
||||||
if let Err(err) = client.register(user).await {
|
if let Err(err) = client.register(user).await {
|
||||||
if let crate::Error::Http(HttpError::UiaaError(crate::FromHttpResponseError::Http(
|
if let crate::Error::Http(HttpError::UiaaError(crate::FromHttpResponseError::Http(
|
||||||
// TODO this should be a UiaaError need to investigate
|
crate::ServerError::Known(crate::api::r0::uiaa::UiaaResponse::MatrixError(
|
||||||
crate::ServerError::Unknown(e),
|
crate::api::Error {
|
||||||
|
kind,
|
||||||
|
message,
|
||||||
|
status_code,
|
||||||
|
},
|
||||||
|
)),
|
||||||
))) = err
|
))) = err
|
||||||
{
|
{
|
||||||
assert!(e.to_string().starts_with("EOF while parsing"))
|
if let crate::api::error::ErrorKind::Forbidden = kind {
|
||||||
|
} else {
|
||||||
|
panic!(
|
||||||
|
"found the wrong `ErrorKind` {:?}, expected `Forbidden",
|
||||||
|
kind
|
||||||
|
);
|
||||||
|
}
|
||||||
|
assert_eq!(message, "Invalid password".to_string());
|
||||||
|
assert_eq!(status_code, http::StatusCode::from_u16(403).unwrap());
|
||||||
} else {
|
} else {
|
||||||
panic!(
|
panic!(
|
||||||
"found the wrong `Error` type {:#?}, expected `ServerError::Unknown",
|
"found the wrong `Error` type {:#?}, expected `UiaaResponse`",
|
||||||
err
|
err
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue