Compare commits

..

3 commits

Author SHA1 Message Date
6124a4097b
chore(deps): lock file maintenance
All checks were successful
/ build (push) Successful in 25s
/ check (clippy) (push) Successful in 15s
/ check (module-ipv4-only-test) (push) Successful in 30s
/ check (module-ipv4-test) (push) Successful in 29s
/ check (module-ipv6-only-test) (push) Successful in 29s
/ check (module-ipv6-test) (push) Successful in 29s
/ check (module-nginx-test) (push) Successful in 29s
/ check (nextest) (push) Successful in 3s
/ check (treefmt) (push) Successful in 3s
/ report-size (push) Successful in 7s
2025-01-31 21:40:19 +01:00
70ed898f1d
fix(tests): add case for when query has empty string
All checks were successful
/ build (push) Successful in 1s
/ check (clippy) (push) Successful in 2s
/ check (module-ipv4-only-test) (push) Successful in 7s
/ check (module-ipv4-test) (push) Successful in 7s
/ check (module-ipv6-only-test) (push) Successful in 7s
/ check (module-ipv6-test) (push) Successful in 7s
/ check (module-nginx-test) (push) Successful in 7s
/ check (nextest) (push) Successful in 2s
/ check (treefmt) (push) Successful in 2s
/ report-size (push) Successful in 1s
This is produced by the FRITZ!Box DDNS client.
2025-01-31 21:25:41 +01:00
2f97008475
fix(webnsupdate): make IP none when query is empty
This happens when one of the IPs hasn't changed (but the other has) in
the FRITZ!Box DDNS client.
2025-01-31 21:25:41 +01:00

View file

@ -425,8 +425,8 @@ where
{ {
use serde::Deserialize; use serde::Deserialize;
let opt = Option::<&'de str>::deserialize(de)?; let opt = Option::<std::borrow::Cow<'de, str>>::deserialize(de)?;
match opt { match opt.as_deref() {
None | Some("") => Ok(None), None | Some("") => Ok(None),
Some(s) => s.parse::<T>().map_err(serde::de::Error::custom).map(Some), Some(s) => s.parse::<T>().map_err(serde::de::Error::custom).map(Some),
} }
@ -671,4 +671,48 @@ mod parse_query_params {
) )
"#); "#);
} }
#[test]
fn ipv4_and_empty_ipv6() {
let uri = http::Uri::builder()
.path_and_query("/update?ipv4=1.2.3.4&ipv6=")
.build()
.unwrap();
let query: Query<FritzBoxUpdateParams> = Query::try_from_uri(&uri).unwrap();
insta::assert_debug_snapshot!(query, @r#"
Query(
FritzBoxUpdateParams {
domain: None,
ipv4: Some(
1.2.3.4,
),
ipv6: None,
ipv6prefix: None,
dualstack: None,
},
)
"#);
}
#[test]
fn empty_ipv4_and_ipv6() {
let uri = http::Uri::builder()
.path_and_query("/update?ipv4=&ipv6=%3A%3A1234")
.build()
.unwrap();
let query: Query<FritzBoxUpdateParams> = Query::try_from_uri(&uri).unwrap();
insta::assert_debug_snapshot!(query, @r#"
Query(
FritzBoxUpdateParams {
domain: None,
ipv4: None,
ipv6: Some(
::1234,
),
ipv6prefix: None,
dualstack: None,
},
)
"#);
}
} }