From 699b1e0f3003b5c4b6f5d3596dfc951f52e2526f Mon Sep 17 00:00:00 2001 From: Ritesh Chitlangi Date: Mon, 26 Jul 2021 15:05:53 +0800 Subject: [PATCH] added deserialization tests for all responses so far --- epp-client/examples/client.rs | 12 +- epp-client/src/epp/object/data.rs | 4 +- epp-client/src/epp/response.rs | 12 +- epp-client/src/epp/response/domain/info.rs | 5 +- .../src/epp/response/domain/transfer.rs | 6 +- epp-client/src/epp/response/host/check.rs | 3 +- epp-client/src/epp/response/host/create.rs | 2 +- epp-client/src/epp/response/message/ack.rs | 5 +- epp-client/src/epp/response/message/poll.rs | 14 +- epp-client/src/tests/de.rs | 439 +++++++++++++++++- .../test/resources/response/domain/info.xml | 33 ++ .../test/resources/response/domain/renew.xml | 24 + .../response/domain/transfer_approve.xml | 12 + .../response/domain/transfer_cancel.xml | 12 + .../response/domain/transfer_query.xml | 23 + .../response/domain/transfer_reject.xml | 12 + .../response/domain/transfer_request.xml | 23 + .../test/resources/response/domain/update.xml | 18 + .../test/resources/response/host/check.xml | 22 + .../test/resources/response/host/create.xml | 18 + .../test/resources/response/host/delete.xml | 12 + .../test/resources/response/host/info.xml | 26 ++ .../test/resources/response/host/update.xml | 12 + .../test/resources/response/message/ack.xml | 13 + .../test/resources/response/message/poll.xml | 27 ++ 25 files changed, 760 insertions(+), 29 deletions(-) create mode 100644 epp-client/test/resources/response/domain/info.xml create mode 100644 epp-client/test/resources/response/domain/renew.xml create mode 100644 epp-client/test/resources/response/domain/transfer_approve.xml create mode 100644 epp-client/test/resources/response/domain/transfer_cancel.xml create mode 100644 epp-client/test/resources/response/domain/transfer_query.xml create mode 100644 epp-client/test/resources/response/domain/transfer_reject.xml create mode 100644 epp-client/test/resources/response/domain/transfer_request.xml create mode 100644 epp-client/test/resources/response/domain/update.xml create mode 100644 epp-client/test/resources/response/host/check.xml create mode 100644 epp-client/test/resources/response/host/create.xml create mode 100644 epp-client/test/resources/response/host/delete.xml create mode 100644 epp-client/test/resources/response/host/info.xml create mode 100644 epp-client/test/resources/response/host/update.xml create mode 100644 epp-client/test/resources/response/message/ack.xml create mode 100644 epp-client/test/resources/response/message/poll.xml diff --git a/epp-client/examples/client.rs b/epp-client/examples/client.rs index 17a1433..2925b7a 100644 --- a/epp-client/examples/client.rs +++ b/epp-client/examples/client.rs @@ -150,7 +150,7 @@ async fn delete_domain(client: &mut EppClient) { } async fn renew_domain(client: &mut EppClient) { - let exp_date = NaiveDate::from_ymd(2022, 7, 23); + let exp_date = NaiveDate::from_ymd(2023, 7, 23); let renew_domain = EppDomainRenew::new("eppdev-1.com", exp_date, 1, gen_client_tr_id("eppdev").unwrap().as_str()); @@ -195,10 +195,10 @@ async fn check_hosts(client: &mut EppClient) { async fn create_host(client: &mut EppClient) { let host = Host { - name: "host1.eppdev-1.com".to_string_value(), + name: "host2.eppdev-1.com".to_string_value(), addresses: Some(vec![ HostAddr::new("v4", "29.245.122.14"), - HostAddr::new("v6", "2400:6180:100:d0::8d6:4001"), + HostAddr::new("v6", "2404:6800:4001:801::200e"), ]) }; @@ -215,7 +215,7 @@ async fn query_host(client: &mut EppClient) { async fn update_host(client: &mut EppClient) { let addr = vec![ - HostAddr::new("v6", "2400:6180:100:d0::8d6:4001"), + HostAddr::new("v6", "2404:6800:4001:801::200e"), ]; let add = HostAddRemove { @@ -298,7 +298,7 @@ async fn main() { // update_domain(&mut client).await; - delete_domain(&mut client).await; + // delete_domain(&mut client).await; // renew_domain(&mut client).await; @@ -322,7 +322,7 @@ async fn main() { // delete_host(&mut client).await; - // poll_message(&mut client).await; + poll_message(&mut client).await; // ack_message(&mut client).await; } diff --git a/epp-client/src/epp/object/data.rs b/epp-client/src/epp/object/data.rs index c865784..2a4c3ff 100644 --- a/epp-client/src/epp/object/data.rs +++ b/epp-client/src/epp/object/data.rs @@ -19,9 +19,9 @@ pub enum DomainNsList { #[derive(Serialize, Deserialize, Debug)] pub struct HostAddr { #[serde(rename = "ip")] - ip_version: Option, + pub ip_version: Option, #[serde(rename = "$value")] - address: String, + pub address: String, } impl HostAddr { diff --git a/epp-client/src/epp/response.rs b/epp-client/src/epp/response.rs index 2a53029..7488cf5 100644 --- a/epp-client/src/epp/response.rs +++ b/epp-client/src/epp/response.rs @@ -158,9 +158,9 @@ pub struct MessageQueue { pub count: u32, pub id: String, #[serde(rename = "qDate")] - pub date: StringValue, + pub date: Option, #[serde(rename = "msg")] - pub message: StringValue, + pub message: Option, } #[derive(Serialize, Deserialize, Debug, PartialEq, ElementName)] @@ -185,10 +185,16 @@ pub struct CommandResponseStatus { } impl CommandResponse { - pub fn results(&self) -> Option<&T> { + pub fn res_data(&self) -> Option<&T> { match &self.res_data { Some(res_data) => Some(&res_data), None => None, } } + pub fn message_queue(&self) -> Option<&MessageQueue> { + match &self.message_queue { + Some(queue) => Some(&queue), + None => None, + } + } } diff --git a/epp-client/src/epp/response/domain/info.rs b/epp-client/src/epp/response/domain/info.rs index 55546bd..c89471a 100644 --- a/epp-client/src/epp/response/domain/info.rs +++ b/epp-client/src/epp/response/domain/info.rs @@ -28,7 +28,8 @@ pub struct DomainInfoData { schema_location: String, pub name: StringValue, pub roid: StringValue, - pub status: Vec, + #[serde(rename = "status")] + pub statuses: Vec, pub registrant: StringValue, #[serde(rename = "contact")] pub contacts: Vec, @@ -49,7 +50,7 @@ pub struct DomainInfoData { #[serde(rename = "trDate")] pub transferred_at: Option, #[serde(rename = "authInfo")] - pub auth_info: AuthInfo, + pub auth_info: Option, } #[derive(Serialize, Deserialize, Debug)] diff --git a/epp-client/src/epp/response/domain/transfer.rs b/epp-client/src/epp/response/domain/transfer.rs index 8bdb3cd..1baff19 100644 --- a/epp-client/src/epp/response/domain/transfer.rs +++ b/epp-client/src/epp/response/domain/transfer.rs @@ -22,11 +22,11 @@ pub struct DomainTransferData { #[serde(rename = "reID")] pub requester_id: StringValue, #[serde(rename = "reDate")] - pub request_date: StringValue, + pub requested_at: StringValue, #[serde(rename = "acID")] - pub responder_id: StringValue, + pub ack_id: StringValue, #[serde(rename = "acDate")] - pub respond_by_date: StringValue, + pub ack_by: StringValue, #[serde(rename = "exDate")] pub expiry_date: StringValue, } diff --git a/epp-client/src/epp/response/host/check.rs b/epp-client/src/epp/response/host/check.rs index e297613..51c1426 100644 --- a/epp-client/src/epp/response/host/check.rs +++ b/epp-client/src/epp/response/host/check.rs @@ -15,7 +15,8 @@ pub struct HostCheck { #[derive(Serialize, Deserialize, Debug)] pub struct HostCheckDataItem { - pub name: HostCheck, + #[serde(rename = "name")] + pub host: HostCheck, pub reason: Option, } diff --git a/epp-client/src/epp/response/host/create.rs b/epp-client/src/epp/response/host/create.rs index b4ba228..e9025e0 100644 --- a/epp-client/src/epp/response/host/create.rs +++ b/epp-client/src/epp/response/host/create.rs @@ -17,5 +17,5 @@ pub struct HostCreateData { #[derive(Serialize, Deserialize, Debug)] pub struct HostCreateResult { #[serde(rename = "creData")] - pub check_data: HostCreateData, + pub create_data: HostCreateData, } diff --git a/epp-client/src/epp/response/message/ack.rs b/epp-client/src/epp/response/message/ack.rs index c129fb4..9d8132e 100644 --- a/epp-client/src/epp/response/message/ack.rs +++ b/epp-client/src/epp/response/message/ack.rs @@ -1,3 +1,4 @@ -use crate::epp::response::EppCommandResponse; +use crate::epp::object::EppObject; +use crate::epp::response::CommandResponse; -pub type EppMessageAckResponse = EppCommandResponse; +pub type EppMessageAckResponse = EppObject>; diff --git a/epp-client/src/epp/response/message/poll.rs b/epp-client/src/epp/response/message/poll.rs index b4bcc7a..2040d08 100644 --- a/epp-client/src/epp/response/message/poll.rs +++ b/epp-client/src/epp/response/message/poll.rs @@ -2,7 +2,7 @@ use crate::epp::object::{EppObject, StringValue}; use crate::epp::response::CommandResponse; use serde::{Deserialize, Serialize}; -pub type EppMessagePollResponse = EppObject>; +pub type EppMessagePollResponse = EppObject>; #[derive(Serialize, Deserialize, Debug)] pub struct MessageDomainTransferData { @@ -14,11 +14,17 @@ pub struct MessageDomainTransferData { #[serde(rename = "reID")] pub requester_id: StringValue, #[serde(rename = "reDate")] - pub request_date: StringValue, + pub requested_at: StringValue, #[serde(rename = "acID")] - pub responder_id: StringValue, + pub ack_id: StringValue, #[serde(rename = "acDate")] - pub respond_by_date: StringValue, + pub ack_by: StringValue, #[serde(rename = "exDate")] pub expiry_date: StringValue, } + +#[derive(Serialize, Deserialize, Debug)] +pub struct MessagePollResult { + #[serde(rename = "trnData")] + pub message_data: MessageDomainTransferData, +} diff --git a/epp-client/src/tests/de.rs b/epp-client/src/tests/de.rs index dbd0342..1fb0fa2 100644 --- a/epp-client/src/tests/de.rs +++ b/epp-client/src/tests/de.rs @@ -96,7 +96,7 @@ mod response { let xml = get_xml("response/contact/check.xml").unwrap(); let object = EppContactCheckResponse::deserialize(xml.as_str()).unwrap(); - let results = object.data.results().unwrap(); + let results = object.data.res_data().unwrap(); assert_eq!(object.data.result.code, 1000); assert_eq!(object.data.result.message, SUCCESS_MSG.to_string_value()); @@ -122,7 +122,7 @@ mod response { let xml = get_xml("response/contact/create.xml").unwrap(); let object = EppContactCreateResponse::deserialize(xml.as_str()).unwrap(); - let results = object.data.results().unwrap(); + let results = object.data.res_data().unwrap(); assert_eq!(object.data.result.code, 1000); assert_eq!(object.data.result.message, SUCCESS_MSG.to_string_value()); @@ -157,7 +157,7 @@ mod response { let xml = get_xml("response/contact/info.xml").unwrap(); let object = EppContactInfoResponse::deserialize(xml.as_str()).unwrap(); - let result = object.data.results().unwrap(); + let result = object.data.res_data().unwrap(); let fax = result.info_data.fax.as_ref().unwrap(); let voice_ext = result.info_data.voice.extension.as_ref().unwrap(); let fax_ext = fax.extension.as_ref().unwrap(); @@ -250,7 +250,7 @@ mod response { let xml = get_xml("response/domain/check.xml").unwrap(); let object = EppDomainCheckResponse::deserialize(xml.as_str()).unwrap(); - let result = object.data.results().unwrap(); + let result = object.data.res_data().unwrap(); assert_eq!(object.data.result.code, 1000); assert_eq!(object.data.result.message, SUCCESS_MSG.to_string_value()); @@ -276,7 +276,7 @@ mod response { let xml = get_xml("response/domain/create.xml").unwrap(); let object = EppDomainCreateResponse::deserialize(xml.as_str()).unwrap(); - let result = object.data.results().unwrap(); + let result = object.data.res_data().unwrap(); assert_eq!(object.data.result.code, 1000); assert_eq!(object.data.result.message, SUCCESS_MSG.to_string_value()); @@ -309,4 +309,433 @@ mod response { ); assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.to_string_value()); } + + #[test] + fn domain_info() { + let xml = get_xml("response/domain/info.xml").unwrap(); + let object = EppDomainInfoResponse::deserialize(xml.as_str()).unwrap(); + + let result = object.data.res_data().unwrap(); + let auth_info = result.info_data.auth_info.as_ref().unwrap(); + + assert_eq!(object.data.result.code, 1000); + assert_eq!(object.data.result.message, SUCCESS_MSG.to_string_value()); + assert_eq!(result.info_data.name, "eppdev-1.com".to_string_value()); + assert_eq!( + result.info_data.roid, + "125899511_DOMAIN_COM-VRSN".to_string_value() + ); + assert_eq!(result.info_data.statuses[0].status, "ok".to_string()); + assert_eq!( + result.info_data.statuses[1].status, + "clientTransferProhibited".to_string() + ); + assert_eq!( + result.info_data.registrant, + "eppdev-contact-2".to_string_value() + ); + assert_eq!( + result.info_data.contacts[0].id, + "eppdev-contact-2".to_string() + ); + assert_eq!( + result.info_data.contacts[0].contact_type, + "admin".to_string() + ); + assert_eq!( + result.info_data.contacts[1].id, + "eppdev-contact-2".to_string() + ); + assert_eq!( + result.info_data.contacts[1].contact_type, + "tech".to_string() + ); + assert_eq!( + result.info_data.contacts[2].id, + "eppdev-contact-2".to_string() + ); + assert_eq!( + result.info_data.contacts[2].contact_type, + "billing".to_string() + ); + assert_eq!(result.info_data.client_id, "eppdev".to_string_value()); + assert_eq!(result.info_data.creator_id, "SYSTEM".to_string_value()); + assert_eq!( + result.info_data.created_at, + "2021-07-23T15:31:20.0Z".to_string_value() + ); + assert_eq!(result.info_data.updater_id, "SYSTEM".to_string_value()); + assert_eq!( + result.info_data.updated_at, + "2021-07-23T15:31:21.0Z".to_string_value() + ); + assert_eq!( + result.info_data.expiry_date, + "2023-07-23T15:31:20.0Z".to_string_value() + ); + assert_eq!((*auth_info).password, "epP4uthd#v".to_string_value()); + assert_eq!( + object.data.tr_ids.client_tr_id.unwrap(), + CLTRID.to_string_value() + ); + assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.to_string_value()); + } + + #[test] + fn domain_renew() { + let xml = get_xml("response/domain/renew.xml").unwrap(); + let object = EppDomainRenewResponse::deserialize(xml.as_str()).unwrap(); + + let result = object.data.res_data().unwrap(); + + assert_eq!(object.data.result.code, 1000); + assert_eq!(object.data.result.message, SUCCESS_MSG.to_string_value()); + assert_eq!(result.renew_data.name, "eppdev-1.com".to_string_value()); + assert_eq!( + result.renew_data.expiry_date, + "2024-07-23T15:31:20.0Z".to_string_value() + ); + assert_eq!( + object.data.tr_ids.client_tr_id.unwrap(), + CLTRID.to_string_value() + ); + assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.to_string_value()); + } + + #[test] + fn domain_transfer_request() { + let xml = get_xml("response/domain/transfer_request.xml").unwrap(); + let object = EppDomainTransferRequestResponse::deserialize(xml.as_str()).unwrap(); + + let result = object.data.res_data().unwrap(); + + assert_eq!(object.data.result.code, 1001); + assert_eq!( + object.data.result.message, + "Command completed successfully; action pending".to_string_value() + ); + assert_eq!( + result.transfer_data.name, + "eppdev-transfer.com".to_string_value() + ); + assert_eq!( + result.transfer_data.transfer_status, + "pending".to_string_value() + ); + assert_eq!( + result.transfer_data.requester_id, + "eppdev".to_string_value() + ); + assert_eq!( + result.transfer_data.requested_at, + "2021-07-23T15:31:21.0Z".to_string_value() + ); + assert_eq!(result.transfer_data.ack_id, "ClientY".to_string_value()); + assert_eq!( + result.transfer_data.ack_by, + "2021-07-28T15:31:21.0Z".to_string_value() + ); + assert_eq!( + result.transfer_data.expiry_date, + "2022-07-02T14:53:19.0Z".to_string_value() + ); + assert_eq!( + object.data.tr_ids.client_tr_id.unwrap(), + CLTRID.to_string_value() + ); + assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.to_string_value()); + } + + #[test] + fn domain_transfer_approve() { + let xml = get_xml("response/domain/transfer_approve.xml").unwrap(); + let object = EppDomainTransferApproveResponse::deserialize(xml.as_str()).unwrap(); + + assert_eq!(object.data.result.code, 1000); + assert_eq!(object.data.result.message, SUCCESS_MSG.to_string_value()); + assert_eq!( + object.data.tr_ids.client_tr_id.unwrap(), + CLTRID.to_string_value() + ); + assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.to_string_value()); + } + + #[test] + fn domain_transfer_reject() { + let xml = get_xml("response/domain/transfer_reject.xml").unwrap(); + let object = EppDomainTransferRejectResponse::deserialize(xml.as_str()).unwrap(); + + assert_eq!(object.data.result.code, 1000); + assert_eq!(object.data.result.message, SUCCESS_MSG.to_string_value()); + assert_eq!( + object.data.tr_ids.client_tr_id.unwrap(), + CLTRID.to_string_value() + ); + assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.to_string_value()); + } + + #[test] + fn domain_transfer_cancel() { + let xml = get_xml("response/domain/transfer_cancel.xml").unwrap(); + let object = EppDomainTransferCancelResponse::deserialize(xml.as_str()).unwrap(); + + assert_eq!(object.data.result.code, 1000); + assert_eq!(object.data.result.message, SUCCESS_MSG.to_string_value()); + assert_eq!( + object.data.tr_ids.client_tr_id.unwrap(), + CLTRID.to_string_value() + ); + assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.to_string_value()); + } + + #[test] + fn domain_transfer_query() { + let xml = get_xml("response/domain/transfer_query.xml").unwrap(); + let object = EppDomainTransferQueryResponse::deserialize(xml.as_str()).unwrap(); + + let result = object.data.res_data().unwrap(); + + assert_eq!(object.data.result.code, 1000); + assert_eq!(object.data.result.message, SUCCESS_MSG.to_string_value()); + assert_eq!( + result.transfer_data.name, + "eppdev-transfer.com".to_string_value() + ); + assert_eq!( + result.transfer_data.transfer_status, + "pending".to_string_value() + ); + assert_eq!( + result.transfer_data.requester_id, + "eppdev".to_string_value() + ); + assert_eq!( + result.transfer_data.requested_at, + "2021-07-23T15:31:21.0Z".to_string_value() + ); + assert_eq!(result.transfer_data.ack_id, "ClientY".to_string_value()); + assert_eq!( + result.transfer_data.ack_by, + "2021-07-28T15:31:21.0Z".to_string_value() + ); + assert_eq!( + result.transfer_data.expiry_date, + "2022-07-02T14:53:19.0Z".to_string_value() + ); + assert_eq!( + object.data.tr_ids.client_tr_id.unwrap(), + CLTRID.to_string_value() + ); + assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.to_string_value()); + } + + #[test] + fn domain_update() { + let xml = get_xml("response/domain/update.xml").unwrap(); + let object = EppDomainUpdateResponse::deserialize(xml.as_str()).unwrap(); + + assert_eq!(object.data.result.code, 1000); + assert_eq!(object.data.result.message, SUCCESS_MSG.to_string_value()); + assert_eq!( + object.data.tr_ids.client_tr_id.unwrap(), + CLTRID.to_string_value() + ); + assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.to_string_value()); + } + + #[test] + fn host_check() { + let xml = get_xml("response/host/check.xml").unwrap(); + let object = EppHostCheckResponse::deserialize(xml.as_str()).unwrap(); + + let result = object.data.res_data().unwrap(); + + assert_eq!(object.data.result.code, 1000); + assert_eq!(object.data.result.message, SUCCESS_MSG.to_string_value()); + assert_eq!( + result.check_data.host_list[0].host.name, + "host1.eppdev-1.com".to_string_value() + ); + assert_eq!(result.check_data.host_list[0].host.available, 1); + assert_eq!( + result.check_data.host_list[1].host.name, + "ns1.testing.com".to_string_value() + ); + assert_eq!(result.check_data.host_list[1].host.available, 0); + assert_eq!( + object.data.tr_ids.client_tr_id.unwrap(), + CLTRID.to_string_value() + ); + assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.to_string_value()); + } + + #[test] + fn host_create() { + let xml = get_xml("response/host/create.xml").unwrap(); + let object = EppHostCreateResponse::deserialize(xml.as_str()).unwrap(); + + let result = object.data.res_data().unwrap(); + + assert_eq!(object.data.result.code, 1000); + assert_eq!(object.data.result.message, SUCCESS_MSG.to_string_value()); + assert_eq!( + result.create_data.name, + "host2.eppdev-1.com".to_string_value() + ); + assert_eq!( + result.create_data.created_at, + "2021-07-26T05:28:55.0Z".to_string_value() + ); + assert_eq!( + object.data.tr_ids.client_tr_id.unwrap(), + CLTRID.to_string_value() + ); + assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.to_string_value()); + } + + #[test] + fn host_info() { + let xml = get_xml("response/host/info.xml").unwrap(); + let object = EppHostInfoResponse::deserialize(xml.as_str()).unwrap(); + + let result = object.data.res_data().unwrap(); + + assert_eq!(object.data.result.code, 1000); + assert_eq!(object.data.result.message, SUCCESS_MSG.to_string_value()); + assert_eq!( + result.info_data.name, + "host2.eppdev-1.com".to_string_value() + ); + assert_eq!(result.info_data.roid, "UNDEF-ROID".to_string_value()); + assert_eq!(result.info_data.statuses[0].status, "ok".to_string()); + assert_eq!( + *(result.info_data.addresses[0].ip_version.as_ref().unwrap()), + "v4".to_string() + ); + assert_eq!( + result.info_data.addresses[0].address, + "29.245.122.14".to_string() + ); + assert_eq!( + *(result.info_data.addresses[1].ip_version.as_ref().unwrap()), + "v6".to_string() + ); + assert_eq!( + result.info_data.addresses[1].address, + "2404:6800:4001:0801:0000:0000:0000:200e".to_string() + ); + assert_eq!(result.info_data.client_id, "eppdev".to_string_value()); + assert_eq!(result.info_data.creator_id, "creator".to_string_value()); + assert_eq!( + result.info_data.created_at, + "2021-07-26T05:28:55.0Z".to_string_value() + ); + assert_eq!( + *(result.info_data.updater_id.as_ref().unwrap()), + "creator".to_string_value() + ); + assert_eq!( + *(result.info_data.updated_at.as_ref().unwrap()), + "2021-07-26T05:28:55.0Z".to_string_value() + ); + assert_eq!( + object.data.tr_ids.client_tr_id.unwrap(), + CLTRID.to_string_value() + ); + assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.to_string_value()); + } + + #[test] + fn host_update() { + let xml = get_xml("response/host/update.xml").unwrap(); + let object = EppHostUpdateResponse::deserialize(xml.as_str()).unwrap(); + + assert_eq!(object.data.result.code, 1000); + assert_eq!(object.data.result.message, SUCCESS_MSG.to_string_value()); + assert_eq!( + object.data.tr_ids.client_tr_id.unwrap(), + CLTRID.to_string_value() + ); + assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.to_string_value()); + } + + #[test] + fn host_delete() { + let xml = get_xml("response/host/delete.xml").unwrap(); + let object = EppHostDeleteResponse::deserialize(xml.as_str()).unwrap(); + + assert_eq!(object.data.result.code, 1000); + assert_eq!(object.data.result.message, SUCCESS_MSG.to_string_value()); + assert_eq!( + object.data.tr_ids.client_tr_id.unwrap(), + CLTRID.to_string_value() + ); + assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.to_string_value()); + } + + #[test] + fn message_poll() { + let xml = get_xml("response/message/poll.xml").unwrap(); + let object = EppMessagePollResponse::deserialize(xml.as_str()).unwrap(); + + let result = object.data.res_data().unwrap(); + let msg = object.data.message_queue().unwrap(); + + assert_eq!(object.data.result.code, 1301); + assert_eq!( + object.data.result.message, + "Command completed successfully; ack to dequeue".to_string_value() + ); + assert_eq!(msg.count, 5); + assert_eq!(msg.id, "12345".to_string()); + assert_eq!( + *(msg.date.as_ref().unwrap()), + "2021-07-23T19:12:43.0Z".to_string_value() + ); + assert_eq!( + *(msg.message.as_ref().unwrap()), + "Transfer requested.".to_string_value() + ); + assert_eq!( + result.message_data.name, + "eppdev-transfer.com".to_string_value() + ); + assert_eq!( + result.message_data.transfer_status, + "pending".to_string_value() + ); + assert_eq!(result.message_data.requester_id, "eppdev".to_string_value()); + assert_eq!( + result.message_data.requested_at, + "2021-07-23T15:31:21.0Z".to_string_value() + ); + assert_eq!(result.message_data.ack_id, "ClientY".to_string_value()); + assert_eq!( + result.message_data.ack_by, + "2021-07-28T15:31:21.0Z".to_string_value() + ); + assert_eq!( + result.message_data.expiry_date, + "2022-07-02T14:53:19.0Z".to_string_value() + ); + assert_eq!( + object.data.tr_ids.client_tr_id.unwrap(), + CLTRID.to_string_value() + ); + assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.to_string_value()); + } + + #[test] + fn message_ack() { + let xml = get_xml("response/message/ack.xml").unwrap(); + let object = EppMessageAckResponse::deserialize(xml.as_str()).unwrap(); + + let msg = object.data.message_queue().unwrap(); + + assert_eq!(object.data.result.code, 1000); + assert_eq!(object.data.result.message, SUCCESS_MSG.to_string_value()); + assert_eq!(msg.count, 4); + assert_eq!(msg.id, "12345".to_string()); + assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.to_string_value()); + } } diff --git a/epp-client/test/resources/response/domain/info.xml b/epp-client/test/resources/response/domain/info.xml new file mode 100644 index 0000000..a4e13a4 --- /dev/null +++ b/epp-client/test/resources/response/domain/info.xml @@ -0,0 +1,33 @@ + + + + + Command completed successfully + + + + eppdev-1.com + 125899511_DOMAIN_COM-VRSN + + + eppdev-contact-2 + eppdev-contact-2 + eppdev-contact-2 + eppdev-contact-2 + eppdev + SYSTEM + 2021-07-23T15:31:20.0Z + SYSTEM + 2021-07-23T15:31:21.0Z + 2023-07-23T15:31:20.0Z + + epP4uthd#v + + + + + cltrid:1626454866 + RO-6879-1627224678242975 + + + \ No newline at end of file diff --git a/epp-client/test/resources/response/domain/renew.xml b/epp-client/test/resources/response/domain/renew.xml new file mode 100644 index 0000000..32f2b9e --- /dev/null +++ b/epp-client/test/resources/response/domain/renew.xml @@ -0,0 +1,24 @@ + + + + + Command completed successfully + + + + + 200 Command completed successfully + + + + + eppdev-1.com + 2024-07-23T15:31:20.0Z + + + + cltrid:1626454866 + RO-6879-1627224678242975 + + + \ No newline at end of file diff --git a/epp-client/test/resources/response/domain/transfer_approve.xml b/epp-client/test/resources/response/domain/transfer_approve.xml new file mode 100644 index 0000000..cd66da1 --- /dev/null +++ b/epp-client/test/resources/response/domain/transfer_approve.xml @@ -0,0 +1,12 @@ + + + + + Command completed successfully + + + cltrid:1626454866 + RO-6879-1627224678242975 + + + \ No newline at end of file diff --git a/epp-client/test/resources/response/domain/transfer_cancel.xml b/epp-client/test/resources/response/domain/transfer_cancel.xml new file mode 100644 index 0000000..cd66da1 --- /dev/null +++ b/epp-client/test/resources/response/domain/transfer_cancel.xml @@ -0,0 +1,12 @@ + + + + + Command completed successfully + + + cltrid:1626454866 + RO-6879-1627224678242975 + + + \ No newline at end of file diff --git a/epp-client/test/resources/response/domain/transfer_query.xml b/epp-client/test/resources/response/domain/transfer_query.xml new file mode 100644 index 0000000..bd71cfb --- /dev/null +++ b/epp-client/test/resources/response/domain/transfer_query.xml @@ -0,0 +1,23 @@ + + + + + Command completed successfully + + + + eppdev-transfer.com + pending + eppdev + 2021-07-23T15:31:21.0Z + ClientY + 2021-07-28T15:31:21.0Z + 2022-07-02T14:53:19.0Z + + + + cltrid:1626454866 + RO-6879-1627224678242975 + + + \ No newline at end of file diff --git a/epp-client/test/resources/response/domain/transfer_reject.xml b/epp-client/test/resources/response/domain/transfer_reject.xml new file mode 100644 index 0000000..cd66da1 --- /dev/null +++ b/epp-client/test/resources/response/domain/transfer_reject.xml @@ -0,0 +1,12 @@ + + + + + Command completed successfully + + + cltrid:1626454866 + RO-6879-1627224678242975 + + + \ No newline at end of file diff --git a/epp-client/test/resources/response/domain/transfer_request.xml b/epp-client/test/resources/response/domain/transfer_request.xml new file mode 100644 index 0000000..5240947 --- /dev/null +++ b/epp-client/test/resources/response/domain/transfer_request.xml @@ -0,0 +1,23 @@ + + + + + Command completed successfully; action pending + + + + eppdev-transfer.com + pending + eppdev + 2021-07-23T15:31:21.0Z + ClientY + 2021-07-28T15:31:21.0Z + 2022-07-02T14:53:19.0Z + + + + cltrid:1626454866 + RO-6879-1627224678242975 + + + \ No newline at end of file diff --git a/epp-client/test/resources/response/domain/update.xml b/epp-client/test/resources/response/domain/update.xml new file mode 100644 index 0000000..2c631a2 --- /dev/null +++ b/epp-client/test/resources/response/domain/update.xml @@ -0,0 +1,18 @@ + + + + + Command completed successfully + + + + + 200 Command completed successfully + + + + cltrid:1626454866 + RO-6879-1627224678242975 + + + \ No newline at end of file diff --git a/epp-client/test/resources/response/host/check.xml b/epp-client/test/resources/response/host/check.xml new file mode 100644 index 0000000..b36a2d6 --- /dev/null +++ b/epp-client/test/resources/response/host/check.xml @@ -0,0 +1,22 @@ + + + + + Command completed successfully + + + + + host1.eppdev-1.com + + + ns1.testing.com + + + + + cltrid:1626454866 + RO-6879-1627224678242975 + + + \ No newline at end of file diff --git a/epp-client/test/resources/response/host/create.xml b/epp-client/test/resources/response/host/create.xml new file mode 100644 index 0000000..74ff630 --- /dev/null +++ b/epp-client/test/resources/response/host/create.xml @@ -0,0 +1,18 @@ + + + + + Command completed successfully + + + + host2.eppdev-1.com + 2021-07-26T05:28:55.0Z + + + + cltrid:1626454866 + RO-6879-1627224678242975 + + + \ No newline at end of file diff --git a/epp-client/test/resources/response/host/delete.xml b/epp-client/test/resources/response/host/delete.xml new file mode 100644 index 0000000..cd66da1 --- /dev/null +++ b/epp-client/test/resources/response/host/delete.xml @@ -0,0 +1,12 @@ + + + + + Command completed successfully + + + cltrid:1626454866 + RO-6879-1627224678242975 + + + \ No newline at end of file diff --git a/epp-client/test/resources/response/host/info.xml b/epp-client/test/resources/response/host/info.xml new file mode 100644 index 0000000..5f41e5d --- /dev/null +++ b/epp-client/test/resources/response/host/info.xml @@ -0,0 +1,26 @@ + + + + + Command completed successfully + + + + host2.eppdev-1.com + UNDEF-ROID + + 29.245.122.14 + 2404:6800:4001:0801:0000:0000:0000:200e + eppdev + creator + 2021-07-26T05:28:55.0Z + creator + 2021-07-26T05:28:55.0Z + + + + cltrid:1626454866 + RO-6879-1627224678242975 + + + \ No newline at end of file diff --git a/epp-client/test/resources/response/host/update.xml b/epp-client/test/resources/response/host/update.xml new file mode 100644 index 0000000..cd66da1 --- /dev/null +++ b/epp-client/test/resources/response/host/update.xml @@ -0,0 +1,12 @@ + + + + + Command completed successfully + + + cltrid:1626454866 + RO-6879-1627224678242975 + + + \ No newline at end of file diff --git a/epp-client/test/resources/response/message/ack.xml b/epp-client/test/resources/response/message/ack.xml new file mode 100644 index 0000000..a440ad7 --- /dev/null +++ b/epp-client/test/resources/response/message/ack.xml @@ -0,0 +1,13 @@ + + + + + Command completed successfully + + + + cltrid:1626454866 + RO-6879-1627224678242975 + + + \ No newline at end of file diff --git a/epp-client/test/resources/response/message/poll.xml b/epp-client/test/resources/response/message/poll.xml new file mode 100644 index 0000000..56877c1 --- /dev/null +++ b/epp-client/test/resources/response/message/poll.xml @@ -0,0 +1,27 @@ + + + + + Command completed successfully; ack to dequeue + + + 2021-07-23T19:12:43.0Z + Transfer requested. + + + + eppdev-transfer.com + pending + eppdev + 2021-07-23T15:31:21.0Z + ClientY + 2021-07-28T15:31:21.0Z + 2022-07-02T14:53:19.0Z + + + + cltrid:1626454866 + RO-6879-1627224678242975 + + + \ No newline at end of file