epp-client/src/logout.rs

54 lines
1.4 KiB
Rust
Raw Normal View History

2021-11-29 22:38:37 +00:00
use std::fmt::Debug;
use serde::{Deserialize, Serialize};
use crate::{
common::NoExtension,
request::{Command, Transaction},
2021-11-29 22:38:37 +00:00
};
impl Transaction<NoExtension> for Logout {}
2021-11-26 22:21:38 +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
#[derive(Serialize, Deserialize, Debug, PartialEq)]
2021-11-29 22:38:37 +00:00
/// Type corresponding to the &lt;logout&gt; tag in an EPP XML logout request
pub struct Logout;
#[cfg(test)]
mod tests {
use super::Logout;
use crate::request::Transaction;
2022-01-23 22:24:27 +00:00
use crate::response::ResultCode;
use crate::tests::{get_xml, CLTRID, SVTRID};
#[test]
fn command() {
let xml = get_xml("request/logout.xml").unwrap();
let object = Logout;
let serialized = object.serialize_request(None, CLTRID).unwrap();
assert_eq!(xml, serialized);
}
#[test]
fn response() {
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
);
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());
}
}