diff --git a/epp-client/src/domain/info.rs b/epp-client/src/domain/info.rs index 5b43a54..f8e9898 100644 --- a/epp-client/src/domain/info.rs +++ b/epp-client/src/domain/info.rs @@ -62,7 +62,7 @@ impl EppRequest for DomainInfo { /// client.transact(login, "transaction-id").await.unwrap(); /// /// // Create an DomainInfo instance -/// let domain_info = DomainInfo::::new("eppdev-100.com"); +/// let domain_info = DomainInfo::::new("eppdev-100.com", None); /// /// // send it to the registry and receive a response of type DomainInfoResponse /// let response = client.transact(domain_info, "transaction-id").await.unwrap(); @@ -74,7 +74,7 @@ impl EppRequest for DomainInfo { /// } /// ``` impl DomainInfo { - pub fn new(name: &str) -> DomainInfo { + pub fn new(name: &str, auth_password: Option<&str>) -> DomainInfo { DomainInfo { request: DomainInfoRequest { info: DomainInfoRequestData { @@ -83,6 +83,9 @@ impl DomainInfo { hosts: "all".to_string(), name: name.to_string(), }, + auth_info: auth_password.map(|password| DomainAuthInfo { + password: password.into(), + }), }, }, extension: None, @@ -118,6 +121,9 @@ pub struct DomainInfoRequestData { /// The data for the domain to be queried #[serde(rename = "domain:name", alias = "name")] domain: Domain, + /// The auth info for the domain + #[serde(rename = "domain:authInfo", alias = "authInfo")] + auth_info: Option, } #[derive(Serialize, Deserialize, Debug, ElementName)] @@ -154,12 +160,12 @@ pub struct DomainInfoResponseData { pub roid: StringValue, /// The list of domain statuses #[serde(rename = "status")] - pub statuses: Vec, + pub statuses: Option>, /// The domain registrant - pub registrant: StringValue, + pub registrant: Option, /// The list of domain contacts #[serde(rename = "contact")] - pub contacts: Vec, + pub contacts: Option>, /// The list of domain nameservers #[serde(rename = "ns")] pub ns: Option, @@ -171,19 +177,19 @@ pub struct DomainInfoResponseData { pub client_id: StringValue, /// The epp user who created the domain #[serde(rename = "crID")] - pub creator_id: StringValue, + pub creator_id: Option, /// The domain creation date #[serde(rename = "crDate")] - pub created_at: StringValue, - /// The epp user who last updated the domain - #[serde(rename = "upID")] - pub updater_id: StringValue, - /// The domain last updated date - #[serde(rename = "upDate")] - pub updated_at: StringValue, + pub created_at: Option, /// The domain expiry date #[serde(rename = "exDate")] - pub expiring_at: StringValue, + pub expiring_at: Option, + /// The epp user who last updated the domain + #[serde(rename = "upID")] + pub updater_id: Option, + /// The domain last updated date + #[serde(rename = "upDate")] + pub updated_at: Option, /// The domain transfer date #[serde(rename = "trDate")] pub transferred_at: Option, diff --git a/epp-client/src/tests/de.rs b/epp-client/src/tests/de.rs index 7ac73cf..d97da61 100644 --- a/epp-client/src/tests/de.rs +++ b/epp-client/src/tests/de.rs @@ -299,52 +299,46 @@ mod response { 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!(result.info_data.statuses[0].status, "ok".to_string()); - assert_eq!( - result.info_data.statuses[1].status, - "clientTransferProhibited".to_string() - ); - assert_eq!(result.info_data.registrant, "eppdev-contact-2".into()); - assert_eq!( - result.info_data.contacts[0].id, - "eppdev-contact-2".to_string() - ); - assert_eq!( - result.info_data.contacts[0].contact_type, - "admin".to_string() - ); - assert_eq!( - result.info_data.contacts[1].id, - "eppdev-contact-2".to_string() - ); - assert_eq!( - result.info_data.contacts[1].contact_type, - "tech".to_string() - ); - assert_eq!( - result.info_data.contacts[2].id, - "eppdev-contact-2".to_string() - ); - assert_eq!( - result.info_data.contacts[2].contact_type, - "billing".to_string() - ); + assert_eq!(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, "SYSTEM".into()); - assert_eq!(result.info_data.created_at, "2021-07-23T15:31:20.0Z".into()); - assert_eq!(result.info_data.updater_id, "SYSTEM".into()); - assert_eq!(result.info_data.updated_at, "2021-07-23T15:31:21.0Z".into()); assert_eq!( - result.info_data.expiring_at, + *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()); @@ -352,6 +346,12 @@ mod response { 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::::deserialize_response(xml.as_str()).unwrap(); + } + #[test] fn domain_renew() { let xml = get_xml("response/domain/renew.xml").unwrap(); diff --git a/epp-client/src/tests/se.rs b/epp-client/src/tests/se.rs index 47b6da8..f199b55 100644 --- a/epp-client/src/tests/se.rs +++ b/epp-client/src/tests/se.rs @@ -298,7 +298,7 @@ mod request { fn domain_info() { let xml = get_xml("request/domain/info.xml").unwrap(); - let object = DomainInfo::::new("eppdev.com"); + let object = DomainInfo::::new("eppdev.com", Some("2fooBAR")); let serialized = object.serialize_request(CLTRID).unwrap(); diff --git a/epp-client/test/resources/request/domain/info.xml b/epp-client/test/resources/request/domain/info.xml index 2702983..9e2eb0a 100644 --- a/epp-client/test/resources/request/domain/info.xml +++ b/epp-client/test/resources/request/domain/info.xml @@ -4,6 +4,9 @@ eppdev.com + + 2fooBAR + cltrid:1626454866 diff --git a/epp-client/test/resources/response/domain/info_alt.xml b/epp-client/test/resources/response/domain/info_alt.xml new file mode 100644 index 0000000..f11be62 --- /dev/null +++ b/epp-client/test/resources/response/domain/info_alt.xml @@ -0,0 +1,37 @@ + + + + + Command completed successfully + + + + eppdev-1.com + 128410211_DOMAIN_COM-VRSN + + + + + + ONE.NS.IDSTEST111.COM + TWO.NS.IDSTEST111.COM + + TWO.NS.IDSTEST111.COM + ONE.NS.IDSTEST111.COM + 29000333 + insdom1 + 2021-12-01T23:41:40Z + insdom1 + 2021-12-01T23:41:40Z + 2023-12-01T23:41:40Z + + epP4uthd#v + + + + + insdom1:1638402100 + 1123110370-1638402100935 + + + \ No newline at end of file