aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/x509/tests.rs
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2016-05-05 13:32:41 -0700
committerSteven Fackler <[email protected]>2016-05-05 13:32:41 -0700
commit4294511f2ba9fe7ec6860f0c783498d93ea68fd9 (patch)
treedf813ae00076c59fd6cb4b7d61bc5f5e76b4f680 /openssl/src/x509/tests.rs
parentMerge branch 'release-v0.7.10' into release (diff)
parentRelease v0.7.11 (diff)
downloadrust-openssl-0.7.11.tar.xz
rust-openssl-0.7.11.zip
Merge branch 'release-v0.7.11' into releasev0.7.11
Diffstat (limited to 'openssl/src/x509/tests.rs')
-rw-r--r--openssl/src/x509/tests.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/openssl/src/x509/tests.rs b/openssl/src/x509/tests.rs
index 69ad37f8..0032d108 100644
--- a/openssl/src/x509/tests.rs
+++ b/openssl/src/x509/tests.rs
@@ -157,3 +157,30 @@ fn test_nid_uid_value() {
};
assert_eq!(&cn as &str, "this is the userId");
}
+
+#[test]
+fn test_subject_alt_name() {
+ let mut file = File::open("test/alt_name_cert.pem").unwrap();
+ let cert = X509::from_pem(&mut file).unwrap();
+
+ let subject_alt_names = cert.subject_alt_names().unwrap();
+ assert_eq!(3, subject_alt_names.len());
+ assert_eq!(Some("foobar.com"), subject_alt_names.get(0).dnsname());
+ assert_eq!(subject_alt_names.get(1).ipaddress(), Some(&[127, 0, 0, 1][..]));
+ assert_eq!(subject_alt_names.get(2).ipaddress(),
+ Some(&b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01"[..]));
+}
+
+#[test]
+fn test_subject_alt_name_iter() {
+ let mut file = File::open("test/alt_name_cert.pem").unwrap();
+ let cert = X509::from_pem(&mut file).unwrap();
+
+ let subject_alt_names = cert.subject_alt_names().unwrap();
+ let mut subject_alt_names_iter = subject_alt_names.iter();
+ assert_eq!(subject_alt_names_iter.next().unwrap().dnsname(), Some("foobar.com"));
+ assert_eq!(subject_alt_names_iter.next().unwrap().ipaddress(), Some(&[127, 0, 0, 1][..]));
+ assert_eq!(subject_alt_names_iter.next().unwrap().ipaddress(),
+ Some(&b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01"[..]));
+ assert!(subject_alt_names_iter.next().is_none());
+}