Simplify response tests with a helper
This commit is contained in:
parent
5dce8501d5
commit
dd5fbc60ce
|
@ -55,10 +55,8 @@ pub struct ContactCheck<'a> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::ContactCheck;
|
use super::ContactCheck;
|
||||||
use crate::common::NoExtension;
|
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command() {
|
fn command() {
|
||||||
|
@ -70,10 +68,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let xml = get_xml("response/contact/check.xml").unwrap();
|
let object = response_from_file::<ContactCheck>("response/contact/check.xml");
|
||||||
let object =
|
|
||||||
<ContactCheck as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
let results = object.res_data().unwrap();
|
let results = object.res_data().unwrap();
|
||||||
|
|
||||||
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
||||||
|
|
|
@ -102,11 +102,9 @@ mod tests {
|
||||||
use chrono::{TimeZone, Utc};
|
use chrono::{TimeZone, Utc};
|
||||||
|
|
||||||
use super::{ContactCreate, Phone, PostalInfo};
|
use super::{ContactCreate, Phone, PostalInfo};
|
||||||
use crate::common::NoExtension;
|
|
||||||
use crate::contact::Address;
|
use crate::contact::Address;
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command() {
|
fn command() {
|
||||||
|
@ -132,11 +130,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let xml = get_xml("response/contact/create.xml").unwrap();
|
let object = response_from_file::<ContactCreate>("response/contact/create.xml");
|
||||||
let object =
|
|
||||||
<ContactCreate as Transaction<NoExtension>>::deserialize_response(xml.as_str())
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let results = object.res_data().unwrap();
|
let results = object.res_data().unwrap();
|
||||||
|
|
||||||
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
||||||
|
|
|
@ -45,10 +45,8 @@ impl<'a> ContactDelete<'a> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::ContactDelete;
|
use super::ContactDelete;
|
||||||
use crate::common::NoExtension;
|
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command() {
|
fn command() {
|
||||||
|
@ -58,11 +56,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let xml = get_xml("response/contact/delete.xml").unwrap();
|
let object = response_from_file::<ContactDelete>("response/contact/delete.xml");
|
||||||
let object =
|
|
||||||
<ContactDelete as Transaction<NoExtension>>::deserialize_response(xml.as_str())
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
||||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||||
|
|
|
@ -107,10 +107,8 @@ mod tests {
|
||||||
use chrono::{TimeZone, Utc};
|
use chrono::{TimeZone, Utc};
|
||||||
|
|
||||||
use super::ContactInfo;
|
use super::ContactInfo;
|
||||||
use crate::common::NoExtension;
|
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command() {
|
fn command() {
|
||||||
|
@ -120,9 +118,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let xml = get_xml("response/contact/info.xml").unwrap();
|
let object = response_from_file::<ContactInfo>("response/contact/info.xml");
|
||||||
let object =
|
|
||||||
<ContactInfo as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
let result = object.res_data().unwrap();
|
let result = object.res_data().unwrap();
|
||||||
let fax = result.info_data.fax.as_ref().unwrap();
|
let fax = result.info_data.fax.as_ref().unwrap();
|
||||||
|
|
|
@ -108,11 +108,10 @@ pub struct ContactUpdate<'a> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{ContactUpdate, Phone, PostalInfo};
|
use super::{ContactUpdate, Phone, PostalInfo};
|
||||||
use crate::common::{NoExtension, ObjectStatus};
|
use crate::common::ObjectStatus;
|
||||||
use crate::contact::Address;
|
use crate::contact::Address;
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command() {
|
fn command() {
|
||||||
|
@ -138,11 +137,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn contact_update() {
|
fn contact_update() {
|
||||||
let xml = get_xml("response/contact/update.xml").unwrap();
|
let object = response_from_file::<ContactUpdate>("response/contact/update.xml");
|
||||||
let object =
|
|
||||||
<ContactUpdate as Transaction<NoExtension>>::deserialize_response(xml.as_str())
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
||||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||||
|
|
|
@ -53,10 +53,8 @@ pub struct DomainCheck<'a> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::DomainCheck;
|
use super::DomainCheck;
|
||||||
use crate::common::NoExtension;
|
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command() {
|
fn command() {
|
||||||
|
@ -68,10 +66,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let xml = get_xml("response/domain/check.xml").unwrap();
|
let object = response_from_file::<DomainCheck>("response/domain/check.xml");
|
||||||
let object =
|
|
||||||
<DomainCheck as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
let result = object.res_data().unwrap();
|
let result = object.res_data().unwrap();
|
||||||
|
|
||||||
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
||||||
|
|
|
@ -109,11 +109,9 @@ mod tests {
|
||||||
use chrono::{TimeZone, Utc};
|
use chrono::{TimeZone, Utc};
|
||||||
|
|
||||||
use super::{DomainContact, DomainCreate, HostList, Period};
|
use super::{DomainContact, DomainCreate, HostList, Period};
|
||||||
use crate::common::NoExtension;
|
|
||||||
use crate::domain::{HostAttr, HostAttrList, HostObjList};
|
use crate::domain::{HostAttr, HostAttrList, HostObjList};
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command() {
|
fn command() {
|
||||||
|
@ -219,9 +217,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let xml = get_xml("response/domain/create.xml").unwrap();
|
let object = response_from_file::<DomainCreate>("response/domain/create.xml");
|
||||||
let object =
|
|
||||||
<DomainCreate as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
let result = object.res_data().unwrap();
|
let result = object.res_data().unwrap();
|
||||||
|
|
||||||
|
|
|
@ -45,10 +45,8 @@ pub struct DomainDelete<'a> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::DomainDelete;
|
use super::DomainDelete;
|
||||||
use crate::common::NoExtension;
|
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command() {
|
fn command() {
|
||||||
|
@ -58,9 +56,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let xml = get_xml("response/domain/delete.xml").unwrap();
|
let object = response_from_file::<DomainDelete>("response/domain/delete.xml");
|
||||||
let object =
|
|
||||||
<DomainDelete as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
||||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||||
|
|
|
@ -133,10 +133,8 @@ pub struct DomainInfoResponse {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::DomainInfo;
|
use super::DomainInfo;
|
||||||
use crate::common::NoExtension;
|
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
use chrono::{TimeZone, Utc};
|
use chrono::{TimeZone, Utc};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -147,9 +145,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let xml = get_xml("response/domain/info.xml").unwrap();
|
let object = response_from_file::<DomainInfo>("response/domain/info.xml");
|
||||||
let object =
|
|
||||||
<DomainInfo as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
let result = object.res_data().unwrap();
|
let result = object.res_data().unwrap();
|
||||||
let auth_info = result.info_data.auth_info.as_ref().unwrap();
|
let auth_info = result.info_data.auth_info.as_ref().unwrap();
|
||||||
|
@ -205,7 +201,6 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response_alt() {
|
fn response_alt() {
|
||||||
let xml = get_xml("response/domain/info_alt.xml").unwrap();
|
response_from_file::<DomainInfo>("response/domain/info_alt.xml");
|
||||||
<DomainInfo as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,10 +78,8 @@ pub struct DomainRenewResponse {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{DomainRenew, Period};
|
use super::{DomainRenew, Period};
|
||||||
use crate::common::NoExtension;
|
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
use chrono::{NaiveDate, TimeZone, Utc};
|
use chrono::{NaiveDate, TimeZone, Utc};
|
||||||
|
|
||||||
|
@ -94,9 +92,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let xml = get_xml("response/domain/renew.xml").unwrap();
|
let object = response_from_file::<DomainRenew>("response/domain/renew.xml");
|
||||||
let object =
|
|
||||||
<DomainRenew as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
let result = object.res_data().unwrap();
|
let result = object.res_data().unwrap();
|
||||||
|
|
||||||
|
|
|
@ -136,10 +136,8 @@ mod tests {
|
||||||
use chrono::{TimeZone, Utc};
|
use chrono::{TimeZone, Utc};
|
||||||
|
|
||||||
use super::{DomainTransfer, Period};
|
use super::{DomainTransfer, Period};
|
||||||
use crate::common::NoExtension;
|
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn request_command() {
|
fn request_command() {
|
||||||
|
@ -174,10 +172,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn request_response() {
|
fn request_response() {
|
||||||
let xml = get_xml("response/domain/transfer_request.xml").unwrap();
|
let object = response_from_file::<DomainTransfer>("response/domain/transfer_request.xml");
|
||||||
let object =
|
|
||||||
<DomainTransfer as Transaction<NoExtension>>::deserialize_response(xml.as_str())
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let result = object.res_data().unwrap();
|
let result = object.res_data().unwrap();
|
||||||
|
|
||||||
|
@ -211,10 +206,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn approve_response() {
|
fn approve_response() {
|
||||||
let xml = get_xml("response/domain/transfer_approve.xml").unwrap();
|
let object = response_from_file::<DomainTransfer>("response/domain/transfer_approve.xml");
|
||||||
let object =
|
|
||||||
<DomainTransfer as Transaction<NoExtension>>::deserialize_response(xml.as_str())
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
||||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||||
|
@ -224,10 +216,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn reject_response() {
|
fn reject_response() {
|
||||||
let xml = get_xml("response/domain/transfer_reject.xml").unwrap();
|
let object = response_from_file::<DomainTransfer>("response/domain/transfer_reject.xml");
|
||||||
let object =
|
|
||||||
<DomainTransfer as Transaction<NoExtension>>::deserialize_response(xml.as_str())
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
||||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||||
|
@ -237,10 +226,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cancel_response() {
|
fn cancel_response() {
|
||||||
let xml = get_xml("response/domain/transfer_cancel.xml").unwrap();
|
let object = response_from_file::<DomainTransfer>("response/domain/transfer_cancel.xml");
|
||||||
let object =
|
|
||||||
<DomainTransfer as Transaction<NoExtension>>::deserialize_response(xml.as_str())
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
||||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||||
|
@ -250,10 +236,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn query_response() {
|
fn query_response() {
|
||||||
let xml = get_xml("response/domain/transfer_query.xml").unwrap();
|
let object = response_from_file::<DomainTransfer>("response/domain/transfer_query.xml");
|
||||||
let object =
|
|
||||||
<DomainTransfer as Transaction<NoExtension>>::deserialize_response(xml.as_str())
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let result = object.res_data().unwrap();
|
let result = object.res_data().unwrap();
|
||||||
|
|
||||||
|
|
|
@ -102,10 +102,9 @@ pub struct DomainUpdate<'a> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{DomainAddRemove, DomainAuthInfo, DomainChangeInfo, DomainContact, DomainUpdate};
|
use super::{DomainAddRemove, DomainAuthInfo, DomainChangeInfo, DomainContact, DomainUpdate};
|
||||||
use crate::common::{NoExtension, ObjectStatus};
|
use crate::common::ObjectStatus;
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command() {
|
fn command() {
|
||||||
|
@ -145,9 +144,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let xml = get_xml("response/domain/update.xml").unwrap();
|
let object = response_from_file::<DomainUpdate>("response/domain/update.xml");
|
||||||
let object =
|
|
||||||
<DomainUpdate as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
||||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||||
|
|
|
@ -97,8 +97,7 @@ pub struct NameStoreData<'a> {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::NameStore;
|
use super::NameStore;
|
||||||
use crate::domain::check::DomainCheck;
|
use crate::domain::check::DomainCheck;
|
||||||
use crate::request::Transaction;
|
use crate::tests::{assert_serialized, response_from_file_with_ext};
|
||||||
use crate::tests::{assert_serialized, get_xml};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command() {
|
fn command() {
|
||||||
|
@ -116,13 +115,10 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let xml = get_xml("response/extensions/namestore.xml").unwrap();
|
let object = response_from_file_with_ext::<DomainCheck, NameStore>(
|
||||||
|
"response/extensions/namestore.xml",
|
||||||
let object =
|
);
|
||||||
<DomainCheck as Transaction<NameStore>>::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
let ext = object.extension.unwrap();
|
let ext = object.extension.unwrap();
|
||||||
|
|
||||||
assert_eq!(ext.data.subproduct, "com".into());
|
assert_eq!(ext.data.subproduct, "com".into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,9 +70,8 @@ mod tests {
|
||||||
use super::{RgpRestoreRequest, Update};
|
use super::{RgpRestoreRequest, Update};
|
||||||
use crate::domain::info::DomainInfo;
|
use crate::domain::info::DomainInfo;
|
||||||
use crate::domain::update::{DomainChangeInfo, DomainUpdate};
|
use crate::domain::update::{DomainChangeInfo, DomainUpdate};
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file_with_ext, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn request_command() {
|
fn request_command() {
|
||||||
|
@ -97,13 +96,9 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn request_response() {
|
fn request_response() {
|
||||||
let xml = get_xml("response/extensions/rgp_restore.xml").unwrap();
|
let object = response_from_file_with_ext::<DomainUpdate, Update<RgpRestoreRequest>>(
|
||||||
let object =
|
"response/extensions/rgp_restore.xml",
|
||||||
<DomainUpdate as Transaction<Update<RgpRestoreRequest>>>::deserialize_response(
|
);
|
||||||
xml.as_str(),
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let ext = object.extension.unwrap();
|
let ext = object.extension.unwrap();
|
||||||
|
|
||||||
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
||||||
|
@ -114,12 +109,9 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn domain_info_request_response() {
|
fn domain_info_request_response() {
|
||||||
let xml = get_xml("response/extensions/domain_info_rgp.xml").unwrap();
|
let object = response_from_file_with_ext::<DomainInfo, Update<RgpRestoreRequest>>(
|
||||||
let object = <DomainInfo as Transaction<Update<RgpRestoreRequest>>>::deserialize_response(
|
"response/extensions/domain_info_rgp.xml",
|
||||||
xml.as_str(),
|
);
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let ext = object.extension.unwrap();
|
let ext = object.extension.unwrap();
|
||||||
|
|
||||||
assert_eq!(ext.data.rgp_status[0].status, "addPeriod");
|
assert_eq!(ext.data.rgp_status[0].status, "addPeriod");
|
||||||
|
|
|
@ -57,10 +57,8 @@ pub struct HostCheck<'a> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::HostCheck;
|
use super::HostCheck;
|
||||||
use crate::common::NoExtension;
|
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command() {
|
fn command() {
|
||||||
|
@ -72,10 +70,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let xml = get_xml("response/host/check.xml").unwrap();
|
let object = response_from_file::<HostCheck>("response/host/check.xml");
|
||||||
let object =
|
|
||||||
<HostCheck as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
let result = object.res_data().unwrap();
|
let result = object.res_data().unwrap();
|
||||||
|
|
||||||
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
||||||
|
|
|
@ -77,10 +77,8 @@ mod tests {
|
||||||
use chrono::{TimeZone, Utc};
|
use chrono::{TimeZone, Utc};
|
||||||
|
|
||||||
use super::{HostCreate, IpAddr};
|
use super::{HostCreate, IpAddr};
|
||||||
use crate::common::NoExtension;
|
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command() {
|
fn command() {
|
||||||
|
@ -95,10 +93,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let xml = get_xml("response/host/create.xml").unwrap();
|
let object = response_from_file::<HostCreate>("response/host/create.xml");
|
||||||
let object =
|
|
||||||
<HostCreate as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
let result = object.res_data().unwrap();
|
let result = object.res_data().unwrap();
|
||||||
|
|
||||||
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
||||||
|
|
|
@ -45,10 +45,8 @@ pub struct HostDelete<'a> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::HostDelete;
|
use super::HostDelete;
|
||||||
use crate::common::NoExtension;
|
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command() {
|
fn command() {
|
||||||
|
@ -58,10 +56,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let xml = get_xml("response/host/delete.xml").unwrap();
|
let object = response_from_file::<HostDelete>("response/host/delete.xml");
|
||||||
let object =
|
|
||||||
<HostDelete as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
||||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||||
|
|
|
@ -109,10 +109,8 @@ mod tests {
|
||||||
use chrono::{TimeZone, Utc};
|
use chrono::{TimeZone, Utc};
|
||||||
|
|
||||||
use super::{HostInfo, IpAddr};
|
use super::{HostInfo, IpAddr};
|
||||||
use crate::common::NoExtension;
|
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command() {
|
fn command() {
|
||||||
|
@ -122,10 +120,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let xml = get_xml("response/host/info.xml").unwrap();
|
let object = response_from_file::<HostInfo>("response/host/info.xml");
|
||||||
let object =
|
|
||||||
<HostInfo as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
let result = object.res_data().unwrap();
|
let result = object.res_data().unwrap();
|
||||||
|
|
||||||
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
||||||
|
|
|
@ -94,10 +94,9 @@ pub struct HostUpdate<'a> {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::IpAddr;
|
use super::IpAddr;
|
||||||
use super::{HostAddRemove, HostChangeInfo, HostUpdate};
|
use super::{HostAddRemove, HostChangeInfo, HostUpdate};
|
||||||
use crate::common::{NoExtension, ObjectStatus};
|
use crate::common::ObjectStatus;
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command() {
|
fn command() {
|
||||||
|
@ -132,9 +131,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let xml = get_xml("response/host/update.xml").unwrap();
|
let object = response_from_file::<HostUpdate>("response/host/update.xml");
|
||||||
let object =
|
|
||||||
<HostUpdate as Transaction<NoExtension>>::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
||||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||||
|
|
|
@ -67,9 +67,8 @@ impl<'a> Command for Login<'a> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::Login;
|
use super::Login;
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command() {
|
fn command() {
|
||||||
|
@ -80,9 +79,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let xml = get_xml("response/login.xml").unwrap();
|
let object = response_from_file::<Login>("response/login.xml");
|
||||||
let object = Login::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
||||||
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
assert_eq!(object.result.message, SUCCESS_MSG.into());
|
||||||
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into());
|
||||||
|
|
|
@ -21,9 +21,8 @@ pub struct Logout;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::Logout;
|
use super::Logout;
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command() {
|
fn command() {
|
||||||
|
@ -33,8 +32,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let xml = get_xml("response/logout.xml").unwrap();
|
let object = response_from_file::<Logout>("response/logout.xml");
|
||||||
let object = Logout::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
object.result.code,
|
object.result.code,
|
||||||
|
|
|
@ -34,9 +34,8 @@ impl<'a> MessageAck<'a> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::MessageAck;
|
use super::MessageAck;
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, SUCCESS_MSG, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, SUCCESS_MSG, SVTRID};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn command() {
|
fn command() {
|
||||||
|
@ -46,9 +45,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let xml = get_xml("response/message/ack.xml").unwrap();
|
let object = response_from_file::<MessageAck>("response/message/ack.xml");
|
||||||
let object = MessageAck::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
let msg = object.message_queue().unwrap();
|
let msg = object.message_queue().unwrap();
|
||||||
|
|
||||||
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
assert_eq!(object.result.code, ResultCode::CommandCompletedSuccessfully);
|
||||||
|
|
|
@ -52,9 +52,8 @@ pub struct MessagePollResponse {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::MessagePoll;
|
use super::MessagePoll;
|
||||||
use crate::message::poll::MessageData;
|
use crate::message::poll::MessageData;
|
||||||
use crate::request::Transaction;
|
|
||||||
use crate::response::ResultCode;
|
use crate::response::ResultCode;
|
||||||
use crate::tests::{assert_serialized, get_xml, CLTRID, SVTRID};
|
use crate::tests::{assert_serialized, response_from_file, CLTRID, SVTRID};
|
||||||
|
|
||||||
use chrono::{TimeZone, Utc};
|
use chrono::{TimeZone, Utc};
|
||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
|
@ -67,9 +66,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn domain_transfer_response() {
|
fn domain_transfer_response() {
|
||||||
let xml = get_xml("response/message/poll_domain_transfer.xml").unwrap();
|
let object = response_from_file::<MessagePoll>("response/message/poll_domain_transfer.xml");
|
||||||
let object = MessagePoll::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
let result = object.res_data().unwrap();
|
let result = object.res_data().unwrap();
|
||||||
let msg = object.message_queue().unwrap();
|
let msg = object.message_queue().unwrap();
|
||||||
|
|
||||||
|
@ -110,9 +107,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn host_info_response() {
|
fn host_info_response() {
|
||||||
let xml = get_xml("response/message/poll_host_info.xml").unwrap();
|
let object = response_from_file::<MessagePoll>("response/message/poll_host_info.xml");
|
||||||
let object = MessagePoll::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
let result = object.res_data().unwrap();
|
let result = object.res_data().unwrap();
|
||||||
let msg = object.message_queue().unwrap();
|
let msg = object.message_queue().unwrap();
|
||||||
|
|
||||||
|
@ -159,9 +154,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn message_only_response() {
|
fn message_only_response() {
|
||||||
let xml = get_xml("response/message/poll_message_only.xml").unwrap();
|
let object = response_from_file::<MessagePoll>("response/message/poll_message_only.xml");
|
||||||
let object = MessagePoll::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
let msg = object.message_queue().unwrap();
|
let msg = object.message_queue().unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -187,8 +180,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn empty_queue_response() {
|
fn empty_queue_response() {
|
||||||
let xml = get_xml("response/message/poll_empty_queue.xml").unwrap();
|
let object = response_from_file::<MessagePoll>("response/message/poll_empty_queue.xml");
|
||||||
let object = MessagePoll::deserialize_response(xml.as_str()).unwrap();
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
object.result.code,
|
object.result.code,
|
||||||
|
|
|
@ -6,7 +6,9 @@ use regex::Regex;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
client::RequestData,
|
client::RequestData,
|
||||||
|
common::NoExtension,
|
||||||
request::{Command, CommandDocument, Extension, Transaction},
|
request::{Command, CommandDocument, Extension, Transaction},
|
||||||
|
response::{Response, ResponseDocument},
|
||||||
xml::EppXml,
|
xml::EppXml,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -48,3 +50,26 @@ pub(crate) fn assert_serialized<'c, 'e, Cmd, Ext>(
|
||||||
let actual = EppXml::serialize(&document).unwrap();
|
let actual = EppXml::serialize(&document).unwrap();
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn response_from_file<'c, Cmd>(
|
||||||
|
path: &str,
|
||||||
|
) -> Response<Cmd::Response, <NoExtension as Extension>::Response>
|
||||||
|
where
|
||||||
|
Cmd: Transaction<NoExtension> + Command + 'c,
|
||||||
|
{
|
||||||
|
response_from_file_with_ext::<Cmd, NoExtension>(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn response_from_file_with_ext<Cmd, Ext>(
|
||||||
|
path: &str,
|
||||||
|
) -> Response<Cmd::Response, Ext::Response>
|
||||||
|
where
|
||||||
|
Cmd: Transaction<NoExtension> + Command,
|
||||||
|
Ext: Extension,
|
||||||
|
{
|
||||||
|
let xml = get_xml(path).unwrap();
|
||||||
|
let rsp =
|
||||||
|
<ResponseDocument<Cmd::Response, Ext::Response> as EppXml>::deserialize(&xml).unwrap();
|
||||||
|
assert!(rsp.data.result.code.is_success());
|
||||||
|
rsp.data
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue