@@ 7,3 7,6 @@ license = "MIT"
[dependencies]
serde = { version = "1.0.160", features = ["derive"] }
+
+[dev-dependencies]
+serde_json = "1.0.96"
@@ 1,5 1,3 @@
-//! This is a WebFinger implementation
-
mod uri;
use serde::{Deserialize, Serialize};
@@ 30,3 28,38 @@ pub struct Link {
}
#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_resource_descriptor_deserialize() {
+ let payload = r#"{
+ "subject" : "acct:carol@example.com",
+ "links" :
+ [
+ {
+ "rel" : "http://openid.net/specs/connect/1.0/issuer",
+ "href" : "https://openid.example.com"
+ }
+ ]
+ }"#;
+
+ let rd: ResourceDescriptor = serde_json::from_str(payload).unwrap();
+
+ assert_eq!(
+ rd,
+ ResourceDescriptor {
+ subject: "acct:carol@example.com".into(),
+ aliases: vec![],
+ properties: HashMap::new(),
+ links: vec![Link {
+ rel: Uri::try_from("http://openid.net/specs/connect/1.0/issuer").unwrap(),
+ mime_type: None,
+ href: Some(Uri::try_from("https://openid.example.com").unwrap()),
+ titles: HashMap::new(),
+ properties: HashMap::new(),
+ }],
+ }
+ );
+ }
+}