|
|
|
@ -35,22 +35,22 @@ pub enum LoginStatusResponse { |
|
|
|
/// The login request has been sent to the server, but the response hasn't
|
|
|
|
/// been received yet.
|
|
|
|
Pending {
|
|
|
|
/// The username used to log in.
|
|
|
|
username: String,
|
|
|
|
/// The user name used to log in.
|
|
|
|
user_name: String,
|
|
|
|
},
|
|
|
|
|
|
|
|
/// Login was successful.
|
|
|
|
Success {
|
|
|
|
/// The username used to log in.
|
|
|
|
username: String,
|
|
|
|
/// The user name used to log in.
|
|
|
|
user_name: String,
|
|
|
|
/// The message of the day sent by the server.
|
|
|
|
motd: String,
|
|
|
|
},
|
|
|
|
|
|
|
|
/// Login failed.
|
|
|
|
Failure {
|
|
|
|
/// The username used to log in.
|
|
|
|
username: String,
|
|
|
|
/// The user name used to log in.
|
|
|
|
user_name: String,
|
|
|
|
/// The reason the server gave for refusing the login request.
|
|
|
|
reason: String,
|
|
|
|
},
|
|
|
|
@ -122,12 +122,12 @@ mod tests { |
|
|
|
assert_eq!(
|
|
|
|
serde_json::from_str::<LoginStatusResponse>(
|
|
|
|
r#"{
|
|
|
|
"Pending": { "username": "karandeep" }
|
|
|
|
"Pending": { "user_name": "karandeep" }
|
|
|
|
}"#
|
|
|
|
)
|
|
|
|
.unwrap(),
|
|
|
|
LoginStatusResponse::Pending {
|
|
|
|
username: "karandeep".to_string()
|
|
|
|
user_name: "karandeep".to_string()
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
@ -138,14 +138,14 @@ mod tests { |
|
|
|
serde_json::from_str::<LoginStatusResponse>(
|
|
|
|
r#"{
|
|
|
|
"Success": {
|
|
|
|
"username": "karandeep",
|
|
|
|
"user_name": "karandeep",
|
|
|
|
"motd": "message of the day"
|
|
|
|
}
|
|
|
|
}"#
|
|
|
|
)
|
|
|
|
.unwrap(),
|
|
|
|
LoginStatusResponse::Success {
|
|
|
|
username: "karandeep".to_string(),
|
|
|
|
user_name: "karandeep".to_string(),
|
|
|
|
motd: "message of the day".to_string(),
|
|
|
|
}
|
|
|
|
);
|
|
|
|
@ -157,14 +157,14 @@ mod tests { |
|
|
|
serde_json::from_str::<LoginStatusResponse>(
|
|
|
|
r#"{
|
|
|
|
"Failure": {
|
|
|
|
"username": "karandeep",
|
|
|
|
"user_name": "karandeep",
|
|
|
|
"reason": "garbage!"
|
|
|
|
}
|
|
|
|
}"#
|
|
|
|
)
|
|
|
|
.unwrap(),
|
|
|
|
LoginStatusResponse::Failure {
|
|
|
|
username: "karandeep".to_string(),
|
|
|
|
user_name: "karandeep".to_string(),
|
|
|
|
reason: "garbage!".to_string(),
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|