Distribute deserialization tests over command modules
This commit is contained in:
parent
d34c94ee9f
commit
cf44a81991
|
@ -1,10 +1,9 @@
|
|||
use std::fmt::Debug;
|
||||
|
||||
/// Types for EPP contact check request
|
||||
|
||||
use super::XMLNS;
|
||||
use crate::common::{NoExtension, StringValue};
|
||||
use crate::request::{Transaction, Command};
|
||||
use crate::request::{Command, Transaction};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
impl Transaction<NoExtension> for ContactCheck {}
|
||||
|
@ -89,3 +88,33 @@ pub struct ContactCheckResponse {
|
|||
#[serde(rename = "chkData")]
|
||||
pub check_data: ContactCheckResponseData,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ContactCheck;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn contact_check() {
|
||||
let xml = get_xml("response/contact/check.xml").unwrap();
|
||||
let object = ContactCheck::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let results = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(
|
||||
results.check_data.contact_list[0].contact.id,
|
||||
"eppdev-contact-1".into()
|
||||
);
|
||||
assert_eq!(results.check_data.contact_list[0].contact.available, 0);
|
||||
assert_eq!(
|
||||
results.check_data.contact_list[1].contact.id,
|
||||
"eppdev-contact-2".into()
|
||||
);
|
||||
assert_eq!(results.check_data.contact_list[1].contact.available, 1);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use super::XMLNS;
|
||||
use crate::common::{ContactAuthInfo, NoExtension, Phone, PostalInfo, StringValue};
|
||||
use crate::request::{Transaction, Command};
|
||||
use crate::request::{Command, Transaction};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
impl Transaction<NoExtension> for ContactCreate {}
|
||||
|
@ -97,3 +97,28 @@ pub struct ContactCreateResponse {
|
|||
#[serde(rename = "creData")]
|
||||
pub create_data: ContactCreateData,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ContactCreate;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn contact_create() {
|
||||
let xml = get_xml("response/contact/create.xml").unwrap();
|
||||
let object = ContactCreate::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let results = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(results.create_data.id, "eppdev-contact-4".into());
|
||||
assert_eq!(
|
||||
results.create_data.created_at,
|
||||
"2021-07-25T16:05:32.0Z".into()
|
||||
);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,3 +41,21 @@ impl ContactDelete {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ContactDelete;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn contact_delete() {
|
||||
let xml = get_xml("response/contact/delete.xml").unwrap();
|
||||
let object = ContactDelete::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,3 +99,68 @@ pub struct ContactInfoResponse {
|
|||
#[serde(rename = "infData")]
|
||||
pub info_data: ContactInfoData,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ContactInfo;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn contact_info() {
|
||||
let xml = get_xml("response/contact/info.xml").unwrap();
|
||||
let object = ContactInfo::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.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();
|
||||
let auth_info = result.info_data.auth_info.as_ref().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(result.info_data.id, "eppdev-contact-3".into());
|
||||
assert_eq!(result.info_data.roid, "UNDEF-ROID".into());
|
||||
assert_eq!(result.info_data.statuses[0].status, "ok".to_string());
|
||||
assert_eq!(result.info_data.postal_info.info_type, "loc".to_string());
|
||||
assert_eq!(result.info_data.postal_info.name, "John Doe".into());
|
||||
assert_eq!(
|
||||
result.info_data.postal_info.organization,
|
||||
"Acme Widgets".into()
|
||||
);
|
||||
assert_eq!(result.info_data.postal_info.address.street[0], "58".into());
|
||||
assert_eq!(
|
||||
result.info_data.postal_info.address.street[1],
|
||||
"Orchid Road".into()
|
||||
);
|
||||
assert_eq!(result.info_data.postal_info.address.city, "Paris".into());
|
||||
assert_eq!(
|
||||
result.info_data.postal_info.address.province,
|
||||
"Paris".into()
|
||||
);
|
||||
assert_eq!(
|
||||
result.info_data.postal_info.address.postal_code,
|
||||
"392374".into()
|
||||
);
|
||||
assert_eq!(result.info_data.postal_info.address.country.alpha2, "FR");
|
||||
assert_eq!(result.info_data.voice.number, "+33.47237942".to_string());
|
||||
assert_eq!(*voice_ext, "123".to_string());
|
||||
assert_eq!(fax.number, "+33.86698799".to_string());
|
||||
assert_eq!(*fax_ext, "243".to_string());
|
||||
assert_eq!(result.info_data.email, "contact@eppdev.net".into());
|
||||
assert_eq!(result.info_data.client_id, "eppdev".into());
|
||||
assert_eq!(result.info_data.creator_id, "SYSTEM".into());
|
||||
assert_eq!(result.info_data.created_at, "2021-07-23T13:09:09.0Z".into());
|
||||
assert_eq!(
|
||||
*(result.info_data.updater_id.as_ref().unwrap()),
|
||||
"SYSTEM".into()
|
||||
);
|
||||
assert_eq!(
|
||||
*(result.info_data.updated_at.as_ref().unwrap()),
|
||||
"2021-07-23T13:09:09.0Z".into()
|
||||
);
|
||||
assert_eq!((*auth_info).password, "eppdev-387323".into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,3 +104,21 @@ pub struct ContactUpdate {
|
|||
#[serde(rename = "contact:update", alias = "update")]
|
||||
contact: ContactUpdateRequestData,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ContactUpdate;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn contact_update() {
|
||||
let xml = get_xml("response/contact/update.xml").unwrap();
|
||||
let object = ContactUpdate::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,3 +85,35 @@ pub struct DomainCheckResponse {
|
|||
#[serde(rename = "chkData")]
|
||||
pub check_data: DomainCheckResponseData,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::DomainCheck;
|
||||
use crate::common::NoExtension;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn domain_check() {
|
||||
let xml = get_xml("response/domain/check.xml").unwrap();
|
||||
let object =
|
||||
<DomainCheck as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(
|
||||
result.check_data.domain_list[0].domain.name,
|
||||
"eppdev.com".into()
|
||||
);
|
||||
assert_eq!(result.check_data.domain_list[0].domain.available, 1);
|
||||
assert_eq!(
|
||||
result.check_data.domain_list[1].domain.name,
|
||||
"eppdev.net".into()
|
||||
);
|
||||
assert_eq!(result.check_data.domain_list[1].domain.available, 0);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,3 +99,32 @@ pub struct DomainCreateResponse {
|
|||
#[serde(rename = "creData")]
|
||||
pub create_data: DomainCreateResponseData,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::DomainCreate;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn domain_create() {
|
||||
let xml = get_xml("response/domain/create.xml").unwrap();
|
||||
let object = DomainCreate::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(result.create_data.name, "eppdev-2.com".into());
|
||||
assert_eq!(
|
||||
result.create_data.created_at,
|
||||
"2021-07-25T18:11:35.0Z".into()
|
||||
);
|
||||
assert_eq!(
|
||||
result.create_data.expiring_at,
|
||||
"2022-07-25T18:11:34.0Z".into()
|
||||
);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,3 +41,21 @@ pub struct DomainDelete {
|
|||
#[serde(rename = "domain:delete", alias = "delete")]
|
||||
domain: DomainDeleteRequestData,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::DomainDelete;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn domain_delete() {
|
||||
let xml = get_xml("response/domain/delete.xml").unwrap();
|
||||
let object = DomainDelete::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,3 +132,75 @@ pub struct DomainInfoResponse {
|
|||
#[serde(rename = "infData")]
|
||||
pub info_data: DomainInfoResponseData,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::DomainInfo;
|
||||
use crate::common::NoExtension;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn domain_info() {
|
||||
let xml = get_xml("response/domain/info.xml").unwrap();
|
||||
let object =
|
||||
<DomainInfo as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
let auth_info = result.info_data.auth_info.as_ref().unwrap();
|
||||
let ns_list = result.info_data.ns.as_ref().unwrap();
|
||||
let ns = (*ns_list).host_obj.as_ref().unwrap();
|
||||
let hosts = result.info_data.hosts.as_ref().unwrap();
|
||||
let statuses = result.info_data.statuses.as_ref().unwrap();
|
||||
let registrant = result.info_data.registrant.as_ref().unwrap();
|
||||
let contacts = result.info_data.contacts.as_ref().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(result.info_data.name, "eppdev-1.com".into());
|
||||
assert_eq!(result.info_data.roid, "125899511_DOMAIN_COM-VRSN".into());
|
||||
assert_eq!(statuses[0].status, "ok".to_string());
|
||||
assert_eq!(statuses[1].status, "clientTransferProhibited".to_string());
|
||||
assert_eq!(*registrant, "eppdev-contact-2".into());
|
||||
assert_eq!(contacts[0].id, "eppdev-contact-2".to_string());
|
||||
assert_eq!(contacts[0].contact_type, "admin".to_string());
|
||||
assert_eq!(contacts[1].id, "eppdev-contact-2".to_string());
|
||||
assert_eq!(contacts[1].contact_type, "tech".to_string());
|
||||
assert_eq!(contacts[2].id, "eppdev-contact-2".to_string());
|
||||
assert_eq!(contacts[2].contact_type, "billing".to_string());
|
||||
assert_eq!((*ns)[0], "ns1.eppdev-1.com".into());
|
||||
assert_eq!((*ns)[1], "ns2.eppdev-1.com".into());
|
||||
assert_eq!((*hosts)[0], "ns1.eppdev-1.com".into());
|
||||
assert_eq!((*hosts)[1], "ns2.eppdev-1.com".into());
|
||||
assert_eq!(result.info_data.client_id, "eppdev".into());
|
||||
assert_eq!(
|
||||
*result.info_data.creator_id.as_ref().unwrap(),
|
||||
"SYSTEM".into()
|
||||
);
|
||||
assert_eq!(
|
||||
*result.info_data.created_at.as_ref().unwrap(),
|
||||
"2021-07-23T15:31:20.0Z".into()
|
||||
);
|
||||
assert_eq!(
|
||||
*result.info_data.updater_id.as_ref().unwrap(),
|
||||
"SYSTEM".into()
|
||||
);
|
||||
assert_eq!(
|
||||
*result.info_data.updated_at.as_ref().unwrap(),
|
||||
"2021-07-23T15:31:21.0Z".into()
|
||||
);
|
||||
assert_eq!(
|
||||
*result.info_data.expiring_at.as_ref().unwrap(),
|
||||
"2023-07-23T15:31:20.0Z".into()
|
||||
);
|
||||
assert_eq!((*auth_info).password, "epP4uthd#v".into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn domain_info_alt() {
|
||||
let xml = get_xml("response/domain/info_alt.xml").unwrap();
|
||||
<DomainInfo as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,3 +73,28 @@ pub struct DomainRenewResponse {
|
|||
#[serde(rename = "renData")]
|
||||
pub renew_data: DomainRenewResponseData,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::DomainRenew;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn domain_renew() {
|
||||
let xml = get_xml("response/domain/renew.xml").unwrap();
|
||||
let object = DomainRenew::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(result.renew_data.name, "eppdev-1.com".into());
|
||||
assert_eq!(
|
||||
result.renew_data.expiring_at,
|
||||
"2024-07-23T15:31:20.0Z".into()
|
||||
);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,3 +141,98 @@ pub struct DomainTransferResponse {
|
|||
#[serde(rename = "trnData")]
|
||||
pub transfer_data: DomainTransferResponseData,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::DomainTransfer;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn domain_transfer_request() {
|
||||
let xml = get_xml("response/domain/transfer_request.xml").unwrap();
|
||||
let object = DomainTransfer::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1001);
|
||||
assert_eq!(
|
||||
object.result.message,
|
||||
"Command completed successfully; action pending".into()
|
||||
);
|
||||
assert_eq!(result.transfer_data.name, "eppdev-transfer.com".into());
|
||||
assert_eq!(result.transfer_data.transfer_status, "pending".into());
|
||||
assert_eq!(result.transfer_data.requester_id, "eppdev".into());
|
||||
assert_eq!(
|
||||
result.transfer_data.requested_at,
|
||||
"2021-07-23T15:31:21.0Z".into()
|
||||
);
|
||||
assert_eq!(result.transfer_data.ack_id, "ClientY".into());
|
||||
assert_eq!(result.transfer_data.ack_by, "2021-07-28T15:31:21.0Z".into());
|
||||
assert_eq!(
|
||||
*result.transfer_data.expiring_at.as_ref().unwrap(),
|
||||
"2022-07-02T14:53:19.0Z".into()
|
||||
);
|
||||
assert_eq!(*object.tr_ids.client_tr_id.as_ref().unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn domain_transfer_approve() {
|
||||
let xml = get_xml("response/domain/transfer_approve.xml").unwrap();
|
||||
let object = DomainTransfer::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn domain_transfer_reject() {
|
||||
let xml = get_xml("response/domain/transfer_reject.xml").unwrap();
|
||||
let object = DomainTransfer::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn domain_transfer_cancel() {
|
||||
let xml = get_xml("response/domain/transfer_cancel.xml").unwrap();
|
||||
let object = DomainTransfer::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn domain_transfer_query() {
|
||||
let xml = get_xml("response/domain/transfer_query.xml").unwrap();
|
||||
let object = DomainTransfer::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(result.transfer_data.name, "eppdev-transfer.com".into());
|
||||
assert_eq!(result.transfer_data.transfer_status, "pending".into());
|
||||
assert_eq!(result.transfer_data.requester_id, "eppdev".into());
|
||||
assert_eq!(
|
||||
result.transfer_data.requested_at,
|
||||
"2021-07-23T15:31:21.0Z".into()
|
||||
);
|
||||
assert_eq!(result.transfer_data.ack_id, "ClientY".into());
|
||||
assert_eq!(result.transfer_data.ack_by, "2021-07-28T15:31:21.0Z".into());
|
||||
assert_eq!(
|
||||
*result.transfer_data.expiring_at.as_ref().unwrap(),
|
||||
"2022-07-02T14:53:19.0Z".into()
|
||||
);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,3 +99,23 @@ pub struct DomainUpdate {
|
|||
#[serde(rename = "domain:update", alias = "update")]
|
||||
pub domain: DomainUpdateRequestData,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::DomainUpdate;
|
||||
use crate::common::NoExtension;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn domain_update() {
|
||||
let xml = get_xml("response/domain/update.xml").unwrap();
|
||||
let object =
|
||||
<DomainUpdate as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,3 +43,23 @@ pub struct NameStoreData {
|
|||
#[serde(rename = "namestoreExt:subProduct", alias = "subProduct")]
|
||||
pub subproduct: StringValue,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::NameStore;
|
||||
use crate::domain::check::DomainCheck;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::get_xml;
|
||||
|
||||
#[test]
|
||||
fn namestore() {
|
||||
let xml = get_xml("response/extensions/namestore.xml").unwrap();
|
||||
|
||||
let object =
|
||||
<DomainCheck as Transaction<NameStore>>::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let ext = object.extension.unwrap();
|
||||
|
||||
assert_eq!(ext.data.subproduct, "com".into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,3 +66,43 @@ pub struct RgpRequestResponse {
|
|||
#[serde(rename = "rgpStatus")]
|
||||
pub rgp_status: Vec<RgpStatus>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{RgpRestoreRequest, Update};
|
||||
use crate::domain::info::DomainInfo;
|
||||
use crate::domain::update::DomainUpdate;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn rgp_restore_request() {
|
||||
let xml = get_xml("response/extensions/rgp_restore.xml").unwrap();
|
||||
let object =
|
||||
<DomainUpdate as Transaction<Update<RgpRestoreRequest>>>::deserialize_response(
|
||||
xml.as_str(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let ext = object.extension.unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(ext.data.rgp_status[0].status, "pendingRestore".to_string());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rgp_restore_domain_info_response() {
|
||||
let xml = get_xml("response/extensions/domain_info_rgp.xml").unwrap();
|
||||
let object = <DomainInfo as Transaction<Update<RgpRestoreRequest>>>::deserialize_response(
|
||||
xml.as_str(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let ext = object.extension.unwrap();
|
||||
|
||||
assert_eq!(ext.data.rgp_status[0].status, "addPeriod");
|
||||
assert_eq!(ext.data.rgp_status[1].status, "renewPeriod");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -302,3 +302,41 @@ pub struct GreetingDocument {
|
|||
}
|
||||
|
||||
impl EppXml for GreetingDocument {}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{ExpiryType, GreetingDocument, Relative};
|
||||
use crate::tests::get_xml;
|
||||
use crate::xml::EppXml;
|
||||
|
||||
#[test]
|
||||
fn greeting() {
|
||||
let xml = get_xml("response/greeting.xml").unwrap();
|
||||
let object = GreetingDocument::deserialize(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.data.service_id, "ISPAPI EPP Server");
|
||||
assert_eq!(object.data.service_date, "2021-07-25T14:51:17.0Z");
|
||||
assert_eq!(object.data.svc_menu.options.version, "1.0".into());
|
||||
assert_eq!(object.data.svc_menu.options.lang, "en".into());
|
||||
assert_eq!(object.data.svc_menu.services.obj_uris.len(), 4);
|
||||
assert_eq!(
|
||||
object
|
||||
.data
|
||||
.svc_menu
|
||||
.services
|
||||
.svc_ext
|
||||
.unwrap()
|
||||
.ext_uris
|
||||
.unwrap()
|
||||
.len(),
|
||||
5
|
||||
);
|
||||
assert_eq!(object.data.dcp.statement.len(), 2);
|
||||
assert_eq!(
|
||||
object.data.dcp.expiry.unwrap().ty,
|
||||
ExpiryType::Relative(Relative {
|
||||
relative: "P1M".into()
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,3 +86,33 @@ pub struct HostCheckResponse {
|
|||
#[serde(rename = "chkData")]
|
||||
pub check_data: HostCheckData,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::HostCheck;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn host_check() {
|
||||
let xml = get_xml("response/host/check.xml").unwrap();
|
||||
let object = HostCheck::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(
|
||||
result.check_data.host_list[0].host.name,
|
||||
"host1.eppdev-1.com".into()
|
||||
);
|
||||
assert_eq!(result.check_data.host_list[0].host.available, 1);
|
||||
assert_eq!(
|
||||
result.check_data.host_list[1].host.name,
|
||||
"ns1.testing.com".into()
|
||||
);
|
||||
assert_eq!(result.check_data.host_list[1].host.available, 0);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,3 +67,28 @@ pub struct HostCreateResponse {
|
|||
#[serde(rename = "creData")]
|
||||
pub create_data: HostCreateData,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::HostCreate;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn host_create() {
|
||||
let xml = get_xml("response/host/create.xml").unwrap();
|
||||
let object = HostCreate::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(result.create_data.name, "host2.eppdev-1.com".into());
|
||||
assert_eq!(
|
||||
result.create_data.created_at,
|
||||
"2021-07-26T05:28:55.0Z".into()
|
||||
);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,3 +41,21 @@ pub struct HostDelete {
|
|||
#[serde(rename = "host:delete", alias = "delete")]
|
||||
host: HostDeleteRequestData,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::HostDelete;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn host_delete() {
|
||||
let xml = get_xml("response/host/delete.xml").unwrap();
|
||||
let object = HostDelete::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,3 +86,53 @@ pub struct HostInfoResponse {
|
|||
#[serde(rename = "infData")]
|
||||
pub info_data: HostInfoResponseData,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::HostInfo;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn host_info() {
|
||||
let xml = get_xml("response/host/info.xml").unwrap();
|
||||
let object = HostInfo::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(result.info_data.name, "host2.eppdev-1.com".into());
|
||||
assert_eq!(result.info_data.roid, "UNDEF-ROID".into());
|
||||
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".into());
|
||||
assert_eq!(result.info_data.creator_id, "creator".into());
|
||||
assert_eq!(result.info_data.created_at, "2021-07-26T05:28:55.0Z".into());
|
||||
assert_eq!(
|
||||
*(result.info_data.updater_id.as_ref().unwrap()),
|
||||
"creator".into()
|
||||
);
|
||||
assert_eq!(
|
||||
*(result.info_data.updated_at.as_ref().unwrap()),
|
||||
"2021-07-26T05:28:55.0Z".into()
|
||||
);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,3 +87,21 @@ pub struct HostUpdate {
|
|||
#[serde(rename = "host:update", alias = "update")]
|
||||
host: HostUpdateRequestData,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::HostUpdate;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn host_update() {
|
||||
let xml = get_xml("response/host/update.xml").unwrap();
|
||||
let object = HostUpdate::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,3 +63,21 @@ impl Command for Login {
|
|||
type Response = ();
|
||||
const COMMAND: &'static str = "login";
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Login;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn login() {
|
||||
let xml = get_xml("response/login.xml").unwrap();
|
||||
let object = Login::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,3 +17,24 @@ impl Command for Logout {
|
|||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
/// Type corresponding to the <logout> tag in an EPP XML logout request
|
||||
pub struct Logout;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Logout;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn logout() {
|
||||
let xml = get_xml("response/logout.xml").unwrap();
|
||||
let object = Logout::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1500);
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,3 +30,24 @@ impl MessageAck {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::MessageAck;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, SUCCESS_MSG, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn message_ack() {
|
||||
let xml = get_xml("response/message/ack.xml").unwrap();
|
||||
let object = MessageAck::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let msg = object.message_queue().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(msg.count, 4);
|
||||
assert_eq!(msg.id, "12345".to_string());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,3 +62,50 @@ pub struct MessagePollResponse {
|
|||
#[serde(rename = "domain:trnData", alias = "trnData")]
|
||||
pub message_data: MessageDomainTransferData,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::MessagePoll;
|
||||
use crate::request::Transaction;
|
||||
use crate::tests::{get_xml, CLTRID, SVTRID};
|
||||
|
||||
#[test]
|
||||
fn message_poll() {
|
||||
let xml = get_xml("response/message/poll.xml").unwrap();
|
||||
let object = MessagePoll::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
let msg = object.message_queue().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1301);
|
||||
assert_eq!(
|
||||
object.result.message,
|
||||
"Command completed successfully; ack to dequeue".into()
|
||||
);
|
||||
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".into()
|
||||
);
|
||||
assert_eq!(
|
||||
*(msg.message.as_ref().unwrap()),
|
||||
"Transfer requested.".into()
|
||||
);
|
||||
assert_eq!(result.message_data.name, "eppdev-transfer.com".into());
|
||||
assert_eq!(result.message_data.transfer_status, "pending".into());
|
||||
assert_eq!(result.message_data.requester_id, "eppdev".into());
|
||||
assert_eq!(
|
||||
result.message_data.requested_at,
|
||||
"2021-07-23T15:31:21.0Z".into()
|
||||
);
|
||||
assert_eq!(result.message_data.ack_id, "ClientY".into());
|
||||
assert_eq!(result.message_data.ack_by, "2021-07-28T15:31:21.0Z".into());
|
||||
assert_eq!(
|
||||
result.message_data.expiring_at,
|
||||
"2022-07-02T14:53:19.0Z".into()
|
||||
);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,3 +132,25 @@ impl<T, E> Response<T, E> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ResultDocument;
|
||||
use crate::tests::{get_xml, CLTRID, SVTRID};
|
||||
use crate::xml::EppXml;
|
||||
|
||||
#[test]
|
||||
fn error() {
|
||||
let xml = get_xml("response/error.xml").unwrap();
|
||||
let object = ResultDocument::deserialize(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.data.result.code, 2303);
|
||||
assert_eq!(object.data.result.message, "Object does not exist".into());
|
||||
assert_eq!(
|
||||
object.data.result.ext_value.unwrap().reason,
|
||||
"545 Object not found".into()
|
||||
);
|
||||
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,674 +0,0 @@
|
|||
//! EPP XML to `EppObject` deserialization tests
|
||||
|
||||
mod response {
|
||||
use super::super::get_xml;
|
||||
use super::super::CLTRID;
|
||||
use crate::common::NoExtension;
|
||||
use crate::contact::check::ContactCheck;
|
||||
use crate::contact::create::ContactCreate;
|
||||
use crate::contact::delete::ContactDelete;
|
||||
use crate::contact::info::ContactInfo;
|
||||
use crate::contact::update::ContactUpdate;
|
||||
use crate::domain::check::DomainCheck;
|
||||
use crate::domain::create::DomainCreate;
|
||||
use crate::domain::delete::DomainDelete;
|
||||
use crate::domain::info::DomainInfo;
|
||||
use crate::domain::renew::DomainRenew;
|
||||
use crate::domain::transfer::DomainTransfer;
|
||||
use crate::domain::update::DomainUpdate;
|
||||
use crate::extensions::namestore::NameStore;
|
||||
use crate::extensions::rgp;
|
||||
use crate::hello::ExpiryType;
|
||||
use crate::hello::GreetingDocument;
|
||||
use crate::hello::Relative;
|
||||
use crate::host::check::HostCheck;
|
||||
use crate::host::create::HostCreate;
|
||||
use crate::host::delete::HostDelete;
|
||||
use crate::host::info::HostInfo;
|
||||
use crate::host::update::HostUpdate;
|
||||
use crate::login::Login;
|
||||
use crate::logout::Logout;
|
||||
use crate::message::ack::MessageAck;
|
||||
use crate::message::poll::MessagePoll;
|
||||
use crate::request::Transaction;
|
||||
use crate::response::ResultDocument;
|
||||
use crate::xml::EppXml;
|
||||
|
||||
const SVTRID: &str = "RO-6879-1627224678242975";
|
||||
const SUCCESS_MSG: &str = "Command completed successfully";
|
||||
|
||||
#[test]
|
||||
fn greeting() {
|
||||
let xml = get_xml("response/greeting.xml").unwrap();
|
||||
let object = GreetingDocument::deserialize(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.data.service_id, "ISPAPI EPP Server");
|
||||
assert_eq!(object.data.service_date, "2021-07-25T14:51:17.0Z");
|
||||
assert_eq!(object.data.svc_menu.options.version, "1.0".into());
|
||||
assert_eq!(object.data.svc_menu.options.lang, "en".into());
|
||||
assert_eq!(object.data.svc_menu.services.obj_uris.len(), 4);
|
||||
assert_eq!(
|
||||
object
|
||||
.data
|
||||
.svc_menu
|
||||
.services
|
||||
.svc_ext
|
||||
.unwrap()
|
||||
.ext_uris
|
||||
.unwrap()
|
||||
.len(),
|
||||
5
|
||||
);
|
||||
assert_eq!(object.data.dcp.statement.len(), 2);
|
||||
assert_eq!(
|
||||
object.data.dcp.expiry.unwrap().ty,
|
||||
ExpiryType::Relative(Relative {
|
||||
relative: "P1M".into()
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn error() {
|
||||
let xml = get_xml("response/error.xml").unwrap();
|
||||
let object = ResultDocument::deserialize(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.data.result.code, 2303);
|
||||
assert_eq!(object.data.result.message, "Object does not exist".into());
|
||||
assert_eq!(
|
||||
object.data.result.ext_value.unwrap().reason,
|
||||
"545 Object not found".into()
|
||||
);
|
||||
assert_eq!(object.data.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn login() {
|
||||
let xml = get_xml("response/login.xml").unwrap();
|
||||
let object = Login::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn logout() {
|
||||
let xml = get_xml("response/logout.xml").unwrap();
|
||||
let object = Logout::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1500);
|
||||
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());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn contact_check() {
|
||||
let xml = get_xml("response/contact/check.xml").unwrap();
|
||||
let object = ContactCheck::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let results = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(
|
||||
results.check_data.contact_list[0].contact.id,
|
||||
"eppdev-contact-1".into()
|
||||
);
|
||||
assert_eq!(results.check_data.contact_list[0].contact.available, 0);
|
||||
assert_eq!(
|
||||
results.check_data.contact_list[1].contact.id,
|
||||
"eppdev-contact-2".into()
|
||||
);
|
||||
assert_eq!(results.check_data.contact_list[1].contact.available, 1);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn contact_create() {
|
||||
let xml = get_xml("response/contact/create.xml").unwrap();
|
||||
let object = ContactCreate::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let results = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(results.create_data.id, "eppdev-contact-4".into());
|
||||
assert_eq!(
|
||||
results.create_data.created_at,
|
||||
"2021-07-25T16:05:32.0Z".into()
|
||||
);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn contact_delete() {
|
||||
let xml = get_xml("response/contact/delete.xml").unwrap();
|
||||
let object = ContactDelete::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn contact_info() {
|
||||
let xml = get_xml("response/contact/info.xml").unwrap();
|
||||
let object = ContactInfo::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.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();
|
||||
let auth_info = result.info_data.auth_info.as_ref().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(result.info_data.id, "eppdev-contact-3".into());
|
||||
assert_eq!(result.info_data.roid, "UNDEF-ROID".into());
|
||||
assert_eq!(result.info_data.statuses[0].status, "ok".to_string());
|
||||
assert_eq!(result.info_data.postal_info.info_type, "loc".to_string());
|
||||
assert_eq!(result.info_data.postal_info.name, "John Doe".into());
|
||||
assert_eq!(
|
||||
result.info_data.postal_info.organization,
|
||||
"Acme Widgets".into()
|
||||
);
|
||||
assert_eq!(result.info_data.postal_info.address.street[0], "58".into());
|
||||
assert_eq!(
|
||||
result.info_data.postal_info.address.street[1],
|
||||
"Orchid Road".into()
|
||||
);
|
||||
assert_eq!(result.info_data.postal_info.address.city, "Paris".into());
|
||||
assert_eq!(
|
||||
result.info_data.postal_info.address.province,
|
||||
"Paris".into()
|
||||
);
|
||||
assert_eq!(
|
||||
result.info_data.postal_info.address.postal_code,
|
||||
"392374".into()
|
||||
);
|
||||
assert_eq!(result.info_data.postal_info.address.country.alpha2, "FR");
|
||||
assert_eq!(result.info_data.voice.number, "+33.47237942".to_string());
|
||||
assert_eq!(*voice_ext, "123".to_string());
|
||||
assert_eq!(fax.number, "+33.86698799".to_string());
|
||||
assert_eq!(*fax_ext, "243".to_string());
|
||||
assert_eq!(result.info_data.email, "contact@eppdev.net".into());
|
||||
assert_eq!(result.info_data.client_id, "eppdev".into());
|
||||
assert_eq!(result.info_data.creator_id, "SYSTEM".into());
|
||||
assert_eq!(result.info_data.created_at, "2021-07-23T13:09:09.0Z".into());
|
||||
assert_eq!(
|
||||
*(result.info_data.updater_id.as_ref().unwrap()),
|
||||
"SYSTEM".into()
|
||||
);
|
||||
assert_eq!(
|
||||
*(result.info_data.updated_at.as_ref().unwrap()),
|
||||
"2021-07-23T13:09:09.0Z".into()
|
||||
);
|
||||
assert_eq!((*auth_info).password, "eppdev-387323".into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn contact_update() {
|
||||
let xml = get_xml("response/contact/update.xml").unwrap();
|
||||
let object = ContactUpdate::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn domain_check() {
|
||||
let xml = get_xml("response/domain/check.xml").unwrap();
|
||||
let object =
|
||||
<DomainCheck as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(
|
||||
result.check_data.domain_list[0].domain.name,
|
||||
"eppdev.com".into()
|
||||
);
|
||||
assert_eq!(result.check_data.domain_list[0].domain.available, 1);
|
||||
assert_eq!(
|
||||
result.check_data.domain_list[1].domain.name,
|
||||
"eppdev.net".into()
|
||||
);
|
||||
assert_eq!(result.check_data.domain_list[1].domain.available, 0);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn domain_create() {
|
||||
let xml = get_xml("response/domain/create.xml").unwrap();
|
||||
let object = DomainCreate::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(result.create_data.name, "eppdev-2.com".into());
|
||||
assert_eq!(
|
||||
result.create_data.created_at,
|
||||
"2021-07-25T18:11:35.0Z".into()
|
||||
);
|
||||
assert_eq!(
|
||||
result.create_data.expiring_at,
|
||||
"2022-07-25T18:11:34.0Z".into()
|
||||
);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn domain_delete() {
|
||||
let xml = get_xml("response/domain/delete.xml").unwrap();
|
||||
let object = DomainDelete::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn domain_info() {
|
||||
let xml = get_xml("response/domain/info.xml").unwrap();
|
||||
let object =
|
||||
<DomainInfo as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
let auth_info = result.info_data.auth_info.as_ref().unwrap();
|
||||
let ns_list = result.info_data.ns.as_ref().unwrap();
|
||||
let ns = (*ns_list).host_obj.as_ref().unwrap();
|
||||
let hosts = result.info_data.hosts.as_ref().unwrap();
|
||||
let statuses = result.info_data.statuses.as_ref().unwrap();
|
||||
let registrant = result.info_data.registrant.as_ref().unwrap();
|
||||
let contacts = result.info_data.contacts.as_ref().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(result.info_data.name, "eppdev-1.com".into());
|
||||
assert_eq!(result.info_data.roid, "125899511_DOMAIN_COM-VRSN".into());
|
||||
assert_eq!(statuses[0].status, "ok".to_string());
|
||||
assert_eq!(statuses[1].status, "clientTransferProhibited".to_string());
|
||||
assert_eq!(*registrant, "eppdev-contact-2".into());
|
||||
assert_eq!(contacts[0].id, "eppdev-contact-2".to_string());
|
||||
assert_eq!(contacts[0].contact_type, "admin".to_string());
|
||||
assert_eq!(contacts[1].id, "eppdev-contact-2".to_string());
|
||||
assert_eq!(contacts[1].contact_type, "tech".to_string());
|
||||
assert_eq!(contacts[2].id, "eppdev-contact-2".to_string());
|
||||
assert_eq!(contacts[2].contact_type, "billing".to_string());
|
||||
assert_eq!((*ns)[0], "ns1.eppdev-1.com".into());
|
||||
assert_eq!((*ns)[1], "ns2.eppdev-1.com".into());
|
||||
assert_eq!((*hosts)[0], "ns1.eppdev-1.com".into());
|
||||
assert_eq!((*hosts)[1], "ns2.eppdev-1.com".into());
|
||||
assert_eq!(result.info_data.client_id, "eppdev".into());
|
||||
assert_eq!(
|
||||
*result.info_data.creator_id.as_ref().unwrap(),
|
||||
"SYSTEM".into()
|
||||
);
|
||||
assert_eq!(
|
||||
*result.info_data.created_at.as_ref().unwrap(),
|
||||
"2021-07-23T15:31:20.0Z".into()
|
||||
);
|
||||
assert_eq!(
|
||||
*result.info_data.updater_id.as_ref().unwrap(),
|
||||
"SYSTEM".into()
|
||||
);
|
||||
assert_eq!(
|
||||
*result.info_data.updated_at.as_ref().unwrap(),
|
||||
"2021-07-23T15:31:21.0Z".into()
|
||||
);
|
||||
assert_eq!(
|
||||
*result.info_data.expiring_at.as_ref().unwrap(),
|
||||
"2023-07-23T15:31:20.0Z".into()
|
||||
);
|
||||
assert_eq!((*auth_info).password, "epP4uthd#v".into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn domain_info_alt() {
|
||||
let xml = get_xml("response/domain/info_alt.xml").unwrap();
|
||||
<DomainInfo as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn domain_renew() {
|
||||
let xml = get_xml("response/domain/renew.xml").unwrap();
|
||||
let object = DomainRenew::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(result.renew_data.name, "eppdev-1.com".into());
|
||||
assert_eq!(
|
||||
result.renew_data.expiring_at,
|
||||
"2024-07-23T15:31:20.0Z".into()
|
||||
);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn domain_transfer_request() {
|
||||
let xml = get_xml("response/domain/transfer_request.xml").unwrap();
|
||||
let object = DomainTransfer::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1001);
|
||||
assert_eq!(
|
||||
object.result.message,
|
||||
"Command completed successfully; action pending".into()
|
||||
);
|
||||
assert_eq!(result.transfer_data.name, "eppdev-transfer.com".into());
|
||||
assert_eq!(result.transfer_data.transfer_status, "pending".into());
|
||||
assert_eq!(result.transfer_data.requester_id, "eppdev".into());
|
||||
assert_eq!(
|
||||
result.transfer_data.requested_at,
|
||||
"2021-07-23T15:31:21.0Z".into()
|
||||
);
|
||||
assert_eq!(result.transfer_data.ack_id, "ClientY".into());
|
||||
assert_eq!(result.transfer_data.ack_by, "2021-07-28T15:31:21.0Z".into());
|
||||
assert_eq!(
|
||||
*result.transfer_data.expiring_at.as_ref().unwrap(),
|
||||
"2022-07-02T14:53:19.0Z".into()
|
||||
);
|
||||
assert_eq!(*object.tr_ids.client_tr_id.as_ref().unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn domain_transfer_approve() {
|
||||
let xml = get_xml("response/domain/transfer_approve.xml").unwrap();
|
||||
let object = DomainTransfer::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn domain_transfer_reject() {
|
||||
let xml = get_xml("response/domain/transfer_reject.xml").unwrap();
|
||||
let object = DomainTransfer::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn domain_transfer_cancel() {
|
||||
let xml = get_xml("response/domain/transfer_cancel.xml").unwrap();
|
||||
let object = DomainTransfer::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn domain_transfer_query() {
|
||||
let xml = get_xml("response/domain/transfer_query.xml").unwrap();
|
||||
let object = DomainTransfer::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(result.transfer_data.name, "eppdev-transfer.com".into());
|
||||
assert_eq!(result.transfer_data.transfer_status, "pending".into());
|
||||
assert_eq!(result.transfer_data.requester_id, "eppdev".into());
|
||||
assert_eq!(
|
||||
result.transfer_data.requested_at,
|
||||
"2021-07-23T15:31:21.0Z".into()
|
||||
);
|
||||
assert_eq!(result.transfer_data.ack_id, "ClientY".into());
|
||||
assert_eq!(result.transfer_data.ack_by, "2021-07-28T15:31:21.0Z".into());
|
||||
assert_eq!(
|
||||
*result.transfer_data.expiring_at.as_ref().unwrap(),
|
||||
"2022-07-02T14:53:19.0Z".into()
|
||||
);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn domain_update() {
|
||||
let xml = get_xml("response/domain/update.xml").unwrap();
|
||||
let object =
|
||||
<DomainUpdate as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn host_check() {
|
||||
let xml = get_xml("response/host/check.xml").unwrap();
|
||||
let object = HostCheck::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(
|
||||
result.check_data.host_list[0].host.name,
|
||||
"host1.eppdev-1.com".into()
|
||||
);
|
||||
assert_eq!(result.check_data.host_list[0].host.available, 1);
|
||||
assert_eq!(
|
||||
result.check_data.host_list[1].host.name,
|
||||
"ns1.testing.com".into()
|
||||
);
|
||||
assert_eq!(result.check_data.host_list[1].host.available, 0);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn host_create() {
|
||||
let xml = get_xml("response/host/create.xml").unwrap();
|
||||
let object = HostCreate::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(result.create_data.name, "host2.eppdev-1.com".into());
|
||||
assert_eq!(
|
||||
result.create_data.created_at,
|
||||
"2021-07-26T05:28:55.0Z".into()
|
||||
);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn host_info() {
|
||||
let xml = get_xml("response/host/info.xml").unwrap();
|
||||
let object = HostInfo::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(result.info_data.name, "host2.eppdev-1.com".into());
|
||||
assert_eq!(result.info_data.roid, "UNDEF-ROID".into());
|
||||
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".into());
|
||||
assert_eq!(result.info_data.creator_id, "creator".into());
|
||||
assert_eq!(result.info_data.created_at, "2021-07-26T05:28:55.0Z".into());
|
||||
assert_eq!(
|
||||
*(result.info_data.updater_id.as_ref().unwrap()),
|
||||
"creator".into()
|
||||
);
|
||||
assert_eq!(
|
||||
*(result.info_data.updated_at.as_ref().unwrap()),
|
||||
"2021-07-26T05:28:55.0Z".into()
|
||||
);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn host_update() {
|
||||
let xml = get_xml("response/host/update.xml").unwrap();
|
||||
let object = HostUpdate::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn host_delete() {
|
||||
let xml = get_xml("response/host/delete.xml").unwrap();
|
||||
let object = HostDelete::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn message_poll() {
|
||||
let xml = get_xml("response/message/poll.xml").unwrap();
|
||||
let object = MessagePoll::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let result = object.res_data().unwrap();
|
||||
let msg = object.message_queue().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1301);
|
||||
assert_eq!(
|
||||
object.result.message,
|
||||
"Command completed successfully; ack to dequeue".into()
|
||||
);
|
||||
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".into()
|
||||
);
|
||||
assert_eq!(
|
||||
*(msg.message.as_ref().unwrap()),
|
||||
"Transfer requested.".into()
|
||||
);
|
||||
assert_eq!(result.message_data.name, "eppdev-transfer.com".into());
|
||||
assert_eq!(result.message_data.transfer_status, "pending".into());
|
||||
assert_eq!(result.message_data.requester_id, "eppdev".into());
|
||||
assert_eq!(
|
||||
result.message_data.requested_at,
|
||||
"2021-07-23T15:31:21.0Z".into()
|
||||
);
|
||||
assert_eq!(result.message_data.ack_id, "ClientY".into());
|
||||
assert_eq!(result.message_data.ack_by, "2021-07-28T15:31:21.0Z".into());
|
||||
assert_eq!(
|
||||
result.message_data.expiring_at,
|
||||
"2022-07-02T14:53:19.0Z".into()
|
||||
);
|
||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn message_ack() {
|
||||
let xml = get_xml("response/message/ack.xml").unwrap();
|
||||
let object = MessageAck::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let msg = object.message_queue().unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(msg.count, 4);
|
||||
assert_eq!(msg.id, "12345".to_string());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rgp_restore_response() {
|
||||
let xml = get_xml("response/extensions/rgp_restore.xml").unwrap();
|
||||
let object =
|
||||
<DomainUpdate as Transaction<rgp::Update<rgp::request::RgpRestoreRequest>>>::deserialize_response(
|
||||
xml.as_str(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let ext = object.extension.unwrap();
|
||||
|
||||
assert_eq!(object.result.code, 1000);
|
||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||
assert_eq!(ext.data.rgp_status[0].status, "pendingRestore".to_string());
|
||||
assert_eq!(object.tr_ids.server_tr_id, SVTRID.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rgp_restore_domain_info_response() {
|
||||
let xml = get_xml("response/extensions/domain_info_rgp.xml").unwrap();
|
||||
let object =
|
||||
<DomainInfo as Transaction<rgp::Update<rgp::request::RgpRestoreRequest>>>::deserialize_response(
|
||||
xml.as_str(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let ext = object.extension.unwrap();
|
||||
|
||||
assert_eq!(ext.data.rgp_status[0].status, "addPeriod");
|
||||
assert_eq!(ext.data.rgp_status[1].status, "renewPeriod");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn namestore() {
|
||||
let xml = get_xml("response/extensions/namestore.xml").unwrap();
|
||||
|
||||
let object =
|
||||
<DomainCheck as Transaction<NameStore>>::deserialize_response(xml.as_str()).unwrap();
|
||||
|
||||
let ext = object.extension.unwrap();
|
||||
|
||||
assert_eq!(ext.data.subproduct, "com".into());
|
||||
}
|
||||
}
|
|
@ -1,16 +1,17 @@
|
|||
//! Module for automated tests
|
||||
|
||||
pub mod de;
|
||||
pub mod se;
|
||||
|
||||
use regex::Regex;
|
||||
use std::{error::Error, fs::File, io::Read};
|
||||
|
||||
const RESOURCES_DIR: &str = "./test/resources";
|
||||
const CLTRID: &str = "cltrid:1626454866";
|
||||
pub(crate) const RESOURCES_DIR: &str = "./test/resources";
|
||||
pub(crate) const CLTRID: &str = "cltrid:1626454866";
|
||||
pub(crate) const SVTRID: &str = "RO-6879-1627224678242975";
|
||||
pub(crate) const SUCCESS_MSG: &str = "Command completed successfully";
|
||||
|
||||
/// Reads EPP XML requests and responses from the test/resources directory to run tests on
|
||||
fn get_xml(path: &str) -> Result<String, Box<dyn Error>> {
|
||||
pub(crate) fn get_xml(path: &str) -> Result<String, Box<dyn Error>> {
|
||||
let ws_regex = Regex::new(r"[\s]{2,}")?;
|
||||
|
||||
let mut f = File::open(format!("{}/{}", RESOURCES_DIR, path))?;
|
||||
|
|
Loading…
Reference in New Issue