summaryrefslogtreecommitdiffstats
path: root/net/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'net/src/lib.rs')
-rw-r--r--net/src/lib.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/net/src/lib.rs b/net/src/lib.rs
index 1aee2eb1..fc674df5 100644
--- a/net/src/lib.rs
+++ b/net/src/lib.rs
@@ -192,3 +192,27 @@ impl From<url::ParseError> for Error {
Error::UriError(e)
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn uris() {
+ let ctx = Context::configure("foo")
+ .network_policy(sequoia_core::NetworkPolicy::Insecure)
+ .build().unwrap();
+
+ assert!(KeyServer::new(&ctx, "keys.openpgp.org").is_ok());
+ assert!(KeyServer::new(&ctx, "hkp://keys.openpgp.org").is_ok());
+ assert!(KeyServer::new(&ctx, "hkps://keys.openpgp.org").is_ok());
+
+ let ctx = Context::configure("foo")
+ .network_policy(sequoia_core::NetworkPolicy::Encrypted)
+ .build().unwrap();
+
+ assert!(KeyServer::new(&ctx, "keys.openpgp.org").is_ok());
+ assert!(KeyServer::new(&ctx, "hkp://keys.openpgp.org").is_err());
+ assert!(KeyServer::new(&ctx, "hkps://keys.openpgp.org").is_ok());
+ }
+}