2021-11-29 22:38:37 +00:00
|
|
|
use std::fmt::Debug;
|
|
|
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
|
|
use crate::{
|
2021-12-09 09:17:00 +00:00
|
|
|
common::NoExtension,
|
|
|
|
request::{Command, Transaction},
|
2021-11-29 22:38:37 +00:00
|
|
|
};
|
|
|
|
|
2021-12-09 09:17:00 +00:00
|
|
|
impl Transaction<NoExtension> for Logout {}
|
2021-11-26 22:21:38 +00:00
|
|
|
|
2021-12-09 09:17:00 +00:00
|
|
|
impl Command for Logout {
|
|
|
|
type Response = ();
|
|
|
|
const COMMAND: &'static str = "logout";
|
2021-11-26 22:21:38 +00:00
|
|
|
}
|
2021-11-29 22:38:37 +00:00
|
|
|
|
2021-12-09 09:17:00 +00:00
|
|
|
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
2021-11-29 22:38:37 +00:00
|
|
|
/// Type corresponding to the <logout> tag in an EPP XML logout request
|
2021-12-09 09:17:00 +00:00
|
|
|
pub struct Logout;
|
2021-12-07 09:04:57 +00:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::Logout;
|
|
|
|
use crate::request::Transaction;
|
2022-01-23 22:24:27 +00:00
|
|
|
use crate::response::ResultCode;
|
2022-03-10 11:50:09 +00:00
|
|
|
use crate::tests::{assert_serialized, get_xml, CLTRID, SVTRID};
|
2021-12-07 09:04:57 +00:00
|
|
|
|
|
|
|
#[test]
|
2021-12-07 09:32:06 +00:00
|
|
|
fn command() {
|
|
|
|
let object = Logout;
|
2022-03-10 11:50:09 +00:00
|
|
|
assert_serialized("request/logout.xml", &object);
|
2021-12-07 09:32:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn response() {
|
2021-12-07 09:04:57 +00:00
|
|
|
let xml = get_xml("response/logout.xml").unwrap();
|
|
|
|
let object = Logout::deserialize_response(xml.as_str()).unwrap();
|
|
|
|
|
2022-01-23 22:24:27 +00:00
|
|
|
assert_eq!(
|
|
|
|
object.result.code,
|
|
|
|
ResultCode::CommandCompletedSuccessfullyEndingSession
|
|
|
|
);
|
2021-12-07 09:04:57 +00:00
|
|
|
assert_eq!(
|
|
|
|
object.result.message,
|
|
|
|
"Command completed successfully; ending session".into()
|
|
|
|
);
|
|
|
|
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
|
|
|
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
|
|
|
}
|
|
|
|
}
|