summaryrefslogtreecommitdiffstats
path: root/net/src/lib.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-02-27 11:22:43 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-02-27 11:50:59 +0100
commit5ea307c381f868f26f7486496eae565a9801e156 (patch)
tree2597c5a59ed616bd2a739fa2a9bee4b924cba2f5 /net/src/lib.rs
parentb877510b28d4c32eac894aaabed976ca2f07bed3 (diff)
net: If no protocol is given, assume hkps.
- Also, add a test. - Fixes #201.
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());
+ }
+}