forked from NationTech/harmony
Merge branch 'master' into feat/settingUpNDC
This commit is contained in:
@@ -4,13 +4,6 @@ use yaserde::MaybeString;
|
||||
|
||||
use super::opnsense::{NumberOption, Range, StaticMap};
|
||||
|
||||
// #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
// #[yaserde(rename = "dhcpd")]
|
||||
// pub struct Dhcpd {
|
||||
// #[yaserde(rename = "lan")]
|
||||
// pub lan: DhcpInterface,
|
||||
// }
|
||||
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
pub struct DhcpInterface {
|
||||
pub enable: Option<MaybeString>,
|
||||
@@ -44,77 +37,3 @@ pub struct DhcpRange {
|
||||
#[yaserde(rename = "to")]
|
||||
pub to: String,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::xml_utils::to_xml_str;
|
||||
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn dhcpd_should_deserialize_serialize_identical() {
|
||||
let dhcpd: Dhcpd =
|
||||
yaserde::de::from_str(SERIALIZED_DHCPD).expect("Deserialize Dhcpd failed");
|
||||
|
||||
assert_eq!(
|
||||
to_xml_str(&dhcpd).expect("Serialize Dhcpd failed"),
|
||||
SERIALIZED_DHCPD
|
||||
);
|
||||
}
|
||||
|
||||
const SERIALIZED_DHCPD: &str = "<?xml version=\"1.0\"?>
|
||||
<dhcpd>
|
||||
<lan>
|
||||
<enable>1</enable>
|
||||
<gateway>192.168.20.1</gateway>
|
||||
<domain>somedomain.yourlocal.mcd</domain>
|
||||
<ddnsdomainalgorithm>hmac-md5</ddnsdomainalgorithm>
|
||||
<numberoptions>
|
||||
<item/>
|
||||
</numberoptions>
|
||||
<range>
|
||||
<from>192.168.20.50</from>
|
||||
<to>192.168.20.200</to>
|
||||
</range>
|
||||
<winsserver/>
|
||||
<dnsserver>192.168.20.1</dnsserver>
|
||||
<ntpserver/>
|
||||
<staticmap>
|
||||
<mac>55:55:55:55:55:1c</mac>
|
||||
<ipaddr>192.168.20.160</ipaddr>
|
||||
<hostname>somehost983</hostname>
|
||||
<descr>someservire8</descr>
|
||||
<winsserver/>
|
||||
<dnsserver/>
|
||||
<ntpserver/>
|
||||
</staticmap>
|
||||
<staticmap>
|
||||
<mac>55:55:55:55:55:1c</mac>
|
||||
<ipaddr>192.168.20.155</ipaddr>
|
||||
<hostname>somehost893</hostname>
|
||||
<winsserver/>
|
||||
<dnsserver/>
|
||||
<ntpserver/>
|
||||
</staticmap>
|
||||
<staticmap>
|
||||
<mac>55:55:55:55:55:1c</mac>
|
||||
<ipaddr>192.168.20.165</ipaddr>
|
||||
<hostname>somehost893</hostname>
|
||||
<descr/>
|
||||
<winsserver/>
|
||||
<dnsserver/>
|
||||
<ntpserver/>
|
||||
</staticmap>
|
||||
<staticmap>
|
||||
<mac>55:55:55:55:55:1c</mac>
|
||||
<ipaddr>192.168.20.50</ipaddr>
|
||||
<hostname>hostswitch2</hostname>
|
||||
<descr>switch-2 (bottom)</descr>
|
||||
<winsserver/>
|
||||
<dnsserver/>
|
||||
<ntpserver/>
|
||||
</staticmap>
|
||||
<pool/>
|
||||
</lan>
|
||||
</dhcpd>\n";
|
||||
}
|
||||
|
||||
@@ -132,22 +132,18 @@ mod test {
|
||||
<interfaces>
|
||||
<paul>
|
||||
<if></if>
|
||||
<descr></descr>
|
||||
<enable/>
|
||||
</paul>
|
||||
<anotherpaul>
|
||||
<if></if>
|
||||
<descr></descr>
|
||||
<enable/>
|
||||
</anotherpaul>
|
||||
<thirdone>
|
||||
<if></if>
|
||||
<descr></descr>
|
||||
<enable/>
|
||||
</thirdone>
|
||||
<andgofor4>
|
||||
<if></if>
|
||||
<descr></descr>
|
||||
<enable/>
|
||||
</andgofor4>
|
||||
</interfaces>
|
||||
|
||||
Reference in New Issue
Block a user