fix deserialize test for contact info

This commit is contained in:
Ritesh Chitlangi 2021-11-10 04:00:36 +08:00
parent 59fcbdc701
commit 6e84640f0d
8 changed files with 12 additions and 14 deletions

View File

@ -12,9 +12,6 @@ use std::fmt;
pub struct Extension { pub struct Extension {
/// The XML namespace for the Neustar <extension> tag /// The XML namespace for the Neustar <extension> tag
pub xmlns: String, pub xmlns: String,
/// XML schema location for the Neulevel extension
#[serde(rename = "xsi:schemaLocation")]
pub schema_location: String,
/// The string under the <unspec> tag /// The string under the <unspec> tag
pub unspec: StringValue, pub unspec: StringValue,
} }

View File

@ -2,7 +2,7 @@
use crate::epp::ext::neustar::object::data::ContactExtension; use crate::epp::ext::neustar::object::data::ContactExtension;
use crate::epp::ext::neustar::object::data::Extension as NeustarExtension; use crate::epp::ext::neustar::object::data::Extension as NeustarExtension;
use crate::epp::ext::neustar::xml::{EPP_NEULEVEL_XMLNS, EPP_XSI_NEULEVEL_SCHEMA_LOCATION}; use crate::epp::ext::neustar::xml::EPP_NEULEVEL_XMLNS;
use crate::epp::object::data::{Phone, PostalInfo}; use crate::epp::object::data::{Phone, PostalInfo};
use crate::epp::object::{EppObject, Extension, StringValueTrait}; use crate::epp::object::{EppObject, Extension, StringValueTrait};
use crate::epp::request::contact::create::ContactCreate; use crate::epp::request::contact::create::ContactCreate;
@ -77,7 +77,6 @@ impl EppNeustarContactCreate {
let ext = NeustarExtension { let ext = NeustarExtension {
xmlns: EPP_NEULEVEL_XMLNS.to_string(), xmlns: EPP_NEULEVEL_XMLNS.to_string(),
schema_location: EPP_XSI_NEULEVEL_SCHEMA_LOCATION.to_string(),
unspec: extension.to_string().to_string_value(), unspec: extension.to_string().to_string_value(),
}; };

View File

@ -2,7 +2,7 @@
use crate::epp::ext::neustar::object::data::ContactExtension; use crate::epp::ext::neustar::object::data::ContactExtension;
use crate::epp::ext::neustar::object::data::Extension as NeustarExtension; use crate::epp::ext::neustar::object::data::Extension as NeustarExtension;
use crate::epp::ext::neustar::xml::{EPP_NEULEVEL_XMLNS, EPP_XSI_NEULEVEL_SCHEMA_LOCATION}; use crate::epp::ext::neustar::xml::EPP_NEULEVEL_XMLNS;
use crate::epp::object::data::{ContactStatus, Phone, PostalInfo}; use crate::epp::object::data::{ContactStatus, Phone, PostalInfo};
use crate::epp::object::{EppObject, Extension, StringValueTrait}; use crate::epp::object::{EppObject, Extension, StringValueTrait};
use crate::epp::request::contact::update::ContactUpdate; use crate::epp::request::contact::update::ContactUpdate;
@ -74,7 +74,6 @@ impl EppNeustarContactUpdate {
self.data.extension = Some(Extension { self.data.extension = Some(Extension {
data: NeustarExtension { data: NeustarExtension {
xmlns: EPP_NEULEVEL_XMLNS.to_string(), xmlns: EPP_NEULEVEL_XMLNS.to_string(),
schema_location: EPP_XSI_NEULEVEL_SCHEMA_LOCATION.to_string(),
unspec: extension.to_string().to_string_value(), unspec: extension.to_string().to_string_value(),
}, },
}); });

View File

@ -1,5 +1,3 @@
//! Neustar specific EPP XML types and data //! Neustar specific EPP XML types and data
pub const EPP_NEULEVEL_XMLNS: &str = "urn:ietf:params:xml:ns:neulevel-1.0"; pub const EPP_NEULEVEL_XMLNS: &str = "urn:ietf:params:xml:ns:neulevel-1.0";
pub const EPP_XSI_NEULEVEL_SCHEMA_LOCATION: &str =
"urn:ietf:params:xml:ns:neulevel-1.0 neulevel-1.0.xsd";

View File

@ -12,13 +12,12 @@ mod response {
let xml = get_xml("ext/neustar/response/contact/info.xml").unwrap(); let xml = get_xml("ext/neustar/response/contact/info.xml").unwrap();
let object = EppNeustarContactInfoResponse::deserialize(xml.as_str()).unwrap(); let object = EppNeustarContactInfoResponse::deserialize(xml.as_str()).unwrap();
println!("{:?}", object);
let result = object.data.res_data().unwrap(); let result = object.data.res_data().unwrap();
let fax = result.info_data.fax.as_ref().unwrap(); let fax = result.info_data.fax.as_ref().unwrap();
let voice_ext = result.info_data.voice.extension.as_ref().unwrap(); let voice_ext = result.info_data.voice.extension.as_ref().unwrap();
let fax_ext = fax.extension.as_ref().unwrap(); let fax_ext = fax.extension.as_ref().unwrap();
let auth_info = result.info_data.auth_info.as_ref().unwrap(); let auth_info = result.info_data.auth_info.as_ref().unwrap();
let ext = object.data.extension.as_ref().unwrap();
assert_eq!(object.data.result.code, 1000); assert_eq!(object.data.result.code, 1000);
assert_eq!(object.data.result.message, SUCCESS_MSG.to_string_value()); assert_eq!(object.data.result.message, SUCCESS_MSG.to_string_value());
@ -85,6 +84,12 @@ mod response {
object.data.tr_ids.client_tr_id.unwrap(), object.data.tr_ids.client_tr_id.unwrap(),
CLTRID.to_string_value() CLTRID.to_string_value()
); );
assert_eq!(
(*ext).data.unspec,
"appPurpose=P2 nexusCategory=C31/DE".to_string_value()
);
assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.to_string_value()); assert_eq!(object.data.tr_ids.server_tr_id, SVTRID.to_string_value());
} }
} }

View File

@ -25,7 +25,7 @@
</create> </create>
</create> </create>
<extension> <extension>
<extension xmlns="urn:ietf:params:xml:ns:neulevel-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:neulevel-1.0 neulevel-1.0.xsd"> <extension xmlns="urn:ietf:params:xml:ns:neulevel-1.0">
<unspec>appPurpose=P2 nexusCategory=C31/DE</unspec> <unspec>appPurpose=P2 nexusCategory=C31/DE</unspec>
</extension> </extension>
</extension> </extension>

View File

@ -32,7 +32,7 @@
</update> </update>
</update> </update>
<extension> <extension>
<extension xmlns="urn:ietf:params:xml:ns:neulevel-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:neulevel-1.0 neulevel-1.0.xsd"> <extension xmlns="urn:ietf:params:xml:ns:neulevel-1.0">
<unspec>nexusCategory=C31/DE</unspec> <unspec>nexusCategory=C31/DE</unspec>
</extension> </extension>
</extension> </extension>

View File

@ -35,7 +35,7 @@
</contact:infData> </contact:infData>
</resData> </resData>
<extension> <extension>
<extension xmlns="urn:ietf:params:xml:ns:neulevel-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:neulevel-1.0 neulevel-1.0.xsd"> <extension xmlns="urn:ietf:params:xml:ns:neulevel-1.0">
<unspec>appPurpose=P2 nexusCategory=C31/DE</unspec> <unspec>appPurpose=P2 nexusCategory=C31/DE</unspec>
</extension> </extension>
</extension> </extension>