Do not emit empty `svcExtension` XML element (#12)
Co-authored-by: Kim Minh Kaplan <kimminh.kaplan+git@afnic.fr>
This commit is contained in:
parent
c5bc07b157
commit
6551749b77
|
@ -58,7 +58,7 @@ impl<'a> Options<'a> {
|
||||||
pub struct ServiceExtension<'a> {
|
pub struct ServiceExtension<'a> {
|
||||||
/// The service extension URIs being represented by `<extURI>` in EPP XML
|
/// The service extension URIs being represented by `<extURI>` in EPP XML
|
||||||
#[xml(rename = "extURI")]
|
#[xml(rename = "extURI")]
|
||||||
pub ext_uris: Option<Vec<Cow<'a, str>>>,
|
pub ext_uris: Vec<Cow<'a, str>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The `<svcs>` type in EPP XML
|
/// The `<svcs>` type in EPP XML
|
||||||
|
|
12
src/hello.rs
12
src/hello.rs
|
@ -341,17 +341,7 @@ mod tests {
|
||||||
assert_eq!(object.svc_menu.options.version, "1.0");
|
assert_eq!(object.svc_menu.options.version, "1.0");
|
||||||
assert_eq!(object.svc_menu.options.lang, "en");
|
assert_eq!(object.svc_menu.options.lang, "en");
|
||||||
assert_eq!(object.svc_menu.services.obj_uris.len(), 4);
|
assert_eq!(object.svc_menu.services.obj_uris.len(), 4);
|
||||||
assert_eq!(
|
assert_eq!(object.svc_menu.services.svc_ext.unwrap().ext_uris.len(), 5);
|
||||||
object
|
|
||||||
.svc_menu
|
|
||||||
.services
|
|
||||||
.svc_ext
|
|
||||||
.unwrap()
|
|
||||||
.ext_uris
|
|
||||||
.unwrap()
|
|
||||||
.len(),
|
|
||||||
5
|
|
||||||
);
|
|
||||||
assert_eq!(object.dcp.statement.len(), 2);
|
assert_eq!(object.dcp.statement.len(), 2);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
object.dcp.expiry.unwrap().inner,
|
object.dcp.expiry.unwrap().inner,
|
||||||
|
|
16
src/login.rs
16
src/login.rs
|
@ -37,8 +37,6 @@ impl<'a> Login<'a> {
|
||||||
new_password: Option<&'a str>,
|
new_password: Option<&'a str>,
|
||||||
ext_uris: Option<&'_ [&'a str]>,
|
ext_uris: Option<&'_ [&'a str]>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let ext_uris = ext_uris.map(|uris| uris.iter().map(|&u| u.into()).collect());
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
|
@ -53,7 +51,11 @@ impl<'a> Login<'a> {
|
||||||
contact::XMLNS.into(),
|
contact::XMLNS.into(),
|
||||||
domain::XMLNS.into(),
|
domain::XMLNS.into(),
|
||||||
],
|
],
|
||||||
svc_ext: Some(ServiceExtension { ext_uris }),
|
svc_ext: ext_uris.and_then(|uris| {
|
||||||
|
(!uris.is_empty()).then(|| ServiceExtension {
|
||||||
|
ext_uris: uris.iter().map(|&u| u.into()).collect(),
|
||||||
|
})
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,6 +89,14 @@ mod tests {
|
||||||
assert_serialized("request/login.xml", &object);
|
assert_serialized("request/login.xml", &object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn command_no_extension() {
|
||||||
|
let object = Login::new("username", "password", None, None);
|
||||||
|
assert_serialized("request/login_no_extension.xml", &object);
|
||||||
|
let object = Login::new("username", "password", None, Some(&[]));
|
||||||
|
assert_serialized("request/login_no_extension.xml", &object);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn response() {
|
fn response() {
|
||||||
let object = response_from_file::<Login>("response/login.xml");
|
let object = response_from_file::<Login>("response/login.xml");
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||||
|
<command>
|
||||||
|
<login>
|
||||||
|
<clID>username</clID>
|
||||||
|
<pw>password</pw>
|
||||||
|
<options>
|
||||||
|
<version>1.0</version>
|
||||||
|
<lang>en</lang>
|
||||||
|
</options>
|
||||||
|
<svcs>
|
||||||
|
<objURI>urn:ietf:params:xml:ns:host-1.0</objURI>
|
||||||
|
<objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>
|
||||||
|
<objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>
|
||||||
|
</svcs>
|
||||||
|
</login>
|
||||||
|
<clTRID>cltrid:1626454866</clTRID>
|
||||||
|
</command>
|
||||||
|
</epp>
|
Loading…
Reference in New Issue