1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use std::fmt::Debug;

use instant_xml::{FromXml, ToXml};

use crate::{
    common::{NoExtension, EPP_XMLNS},
    request::{Command, Transaction},
};

impl Transaction<NoExtension> for Logout {}

impl Command for Logout {
    type Response = ();
    const COMMAND: &'static str = "logout";
}

#[derive(Debug, Eq, FromXml, PartialEq, ToXml)]
/// Type corresponding to the `<logout>` tag in an EPP XML logout request
#[xml(rename = "logout", ns(EPP_XMLNS))]
pub struct Logout;

#[cfg(test)]
mod tests {
    use super::Logout;
    use crate::response::ResultCode;
    use crate::tests::{assert_serialized, response_from_file, CLTRID, SVTRID};

    #[test]
    fn command() {
        let object = Logout;
        assert_serialized("request/logout.xml", &object);
    }

    #[test]
    fn response() {
        let object = response_from_file::<Logout>("response/logout.xml");

        assert_eq!(
            object.result.code,
            ResultCode::CommandCompletedSuccessfullyEndingSession
        );
        assert_eq!(
            object.result.message,
            "Command completed successfully; ending session"
        );
        assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID);
        assert_eq!(object.tr_ids.server_tr_id, SVTRID);
    }
}