Add sync namestore composite extension

This commit is contained in:
Nick Rempel 2021-12-09 14:51:58 -08:00 committed by masalachai
parent 17d5bd90e9
commit 6445b63c62
2 changed files with 73 additions and 1 deletions

View File

@ -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<Update> for DomainUpdate<'a> {}
@ -17,6 +19,12 @@ impl Extension for Update {
type Response = NoExtension;
}
impl Transaction<UpdateWithNameStore> 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 &lt;consolidate&gt; 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 = <DomainUpdate as Transaction<UpdateWithNameStore>>::serialize_request(
&object,
Some(&consolidate_ext),
CLTRID,
)
.unwrap();
assert_eq!(xml, serialized);
}
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<update>
<domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>eppdev.com</domain:name>
<domain:chg/>
</domain:update>
</update>
<extension>
<sync:update xmlns:sync="http://www.verisign.com/epp/sync-1.0">
<sync:expMonthDay>--05-31</sync:expMonthDay>
</sync:update>
<namestoreExt:namestoreExt xmlns:namestoreExt="http://www.verisign-grs.com/epp/namestoreExt-1.1">
<namestoreExt:subProduct>com</namestoreExt:subProduct>
</namestoreExt:namestoreExt>
</extension>
<clTRID>cltrid:1626454866</clTRID>
</command>
</epp>