From 6445b63c628d2a68b8aac1bc8c0ccb98f7202c6b Mon Sep 17 00:00:00 2001 From: Nick Rempel Date: Thu, 9 Dec 2021 14:51:58 -0800 Subject: [PATCH] Add sync namestore composite extension --- src/extensions/consolidate.rs | 54 ++++++++++++++++++- .../extensions/consolidate_namestore.xml | 20 +++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 test/resources/request/extensions/consolidate_namestore.xml diff --git a/src/extensions/consolidate.rs b/src/extensions/consolidate.rs index a118686..d98961d 100644 --- a/src/extensions/consolidate.rs +++ b/src/extensions/consolidate.rs @@ -9,6 +9,8 @@ use crate::common::{NoExtension, StringValue}; use crate::domain::update::DomainUpdate; use crate::request::{Extension, Transaction}; +use super::namestore::{NameStore, NameStoreData}; + pub const XMLNS: &str = "http://www.verisign.com/epp/sync-1.0"; impl<'a> Transaction for DomainUpdate<'a> {} @@ -17,6 +19,12 @@ impl Extension for Update { type Response = NoExtension; } +impl Transaction for DomainUpdate {} + +impl Extension for UpdateWithNameStore { + type Response = NameStore; +} + #[derive(PartialEq, Debug)] pub struct GMonthDay { pub month: u8, @@ -59,7 +67,7 @@ impl fmt::Display for GMonthDay { } impl Update { - /// Create a new RGP restore report request + /// Create a new sync update request pub fn new(expiration: GMonthDay) -> Self { Self { data: UpdateData { @@ -70,12 +78,30 @@ impl Update { } } +impl UpdateWithNameStore { + /// Create a new sync update with namestore request + pub fn new(expiration: GMonthDay, subproduct: &str) -> Self { + Self { + sync: Update::new(expiration).data, + namestore: NameStore::new(subproduct).data, + } + } +} + #[derive(Debug, Serialize)] pub struct Update { #[serde(rename = "sync:update")] pub data: UpdateData, } +#[derive(Debug, Serialize)] +pub struct UpdateWithNameStore { + #[serde(rename = "sync:update")] + pub sync: UpdateData, + #[serde(rename = "namestoreExt:namestoreExt")] + pub namestore: NameStoreData, +} + #[derive(Serialize, Debug)] /// Type for EPP XML <consolidate> extension pub struct UpdateData { @@ -91,6 +117,7 @@ pub struct UpdateData { mod tests { use super::{GMonthDay, Update}; use crate::domain::update::{DomainChangeInfo, DomainUpdate}; + use crate::extensions::consolidate::UpdateWithNameStore; use crate::request::Transaction; use crate::tests::{get_xml, CLTRID}; @@ -118,4 +145,29 @@ mod tests { assert_eq!(xml, serialized); } + + #[test] + fn command_with_namestore() { + let xml = get_xml("request/extensions/consolidate_namestore.xml").unwrap(); + + let exp = GMonthDay::new(5, 31, None).unwrap(); + + let consolidate_ext = UpdateWithNameStore::new(exp, "com"); + + let mut object = DomainUpdate::new("eppdev.com"); + + object.info(DomainChangeInfo { + registrant: None, + auth_info: None, + }); + + let serialized = >::serialize_request( + &object, + Some(&consolidate_ext), + CLTRID, + ) + .unwrap(); + + assert_eq!(xml, serialized); + } } diff --git a/test/resources/request/extensions/consolidate_namestore.xml b/test/resources/request/extensions/consolidate_namestore.xml new file mode 100644 index 0000000..3291f94 --- /dev/null +++ b/test/resources/request/extensions/consolidate_namestore.xml @@ -0,0 +1,20 @@ + + + + + + eppdev.com + + + + + + --05-31 + + + com + + + cltrid:1626454866 + + \ No newline at end of file