Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Theil <[email protected]>
  • Loading branch information
thillux committed Oct 12, 2023
1 parent e93ab39 commit cc555a8
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions openssl/src/x509/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ use crate::rsa::Rsa;
use crate::ssl::SslFiletype;
use crate::stack::Stack;
use crate::x509::extension::{
AuthorityKeyIdentifier, BasicConstraints, ExtendedKeyUsage, KeyUsage, SubjectAlternativeName,
SubjectKeyIdentifier, SbgpAsIdentifier, SbgpIpAddressIdentifier
AuthorityKeyIdentifier, BasicConstraints, ExtendedKeyUsage, KeyUsage, SbgpAsIdentifier,
SbgpIpAddressIdentifier, SubjectAlternativeName, SubjectKeyIdentifier,
};
use crate::x509::sbgp::ExtractSBGPInfo;
#[cfg(not(boringssl))]
use crate::x509::store::X509Lookup;
use crate::x509::store::X509StoreBuilder;
Expand All @@ -29,7 +30,6 @@ use crate::x509::{CrlReason, X509Builder};
use crate::x509::{
CrlStatus, X509Crl, X509Extension, X509Name, X509Req, X509StoreContext, X509VerifyResult, X509,
};
use crate::x509::sbgp::ExtractSBGPInfo;

#[cfg(ossl110)]
use foreign_types::ForeignType;
Expand Down Expand Up @@ -1187,16 +1187,19 @@ fn test_sbgp_extensions_parsing() {
let cert = X509::from_pem(cert).unwrap();

let asn_ranges = cert.asn().unwrap().ranges().unwrap();
assert_eq!(asn_ranges[0], (10,18));
assert_eq!(asn_ranges[1], (20,20));
assert_eq!(asn_ranges[0], (10, 18));
assert_eq!(asn_ranges[1], (20, 20));

let families = cert.ip_addresses().unwrap();
for family in families {
let ranges = family.range().unwrap();
for (ip_min, ip_max) in ranges {
if let (IpAddr::V6(a_v6_min), IpAddr::V6(a_v6_max)) = (ip_min, ip_max) {
assert_eq!(a_v6_min, Ipv6Addr::from_str("fd00::").unwrap());
assert_eq!(a_v6_max, Ipv6Addr::from_str("fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff").unwrap());
assert_eq!(
a_v6_max,
Ipv6Addr::from_str("fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff").unwrap()
);
}
if let (IpAddr::V4(a_v4_min), IpAddr::V4(a_v4_max)) = (ip_min, ip_max) {
assert_eq!(a_v4_min, Ipv4Addr::from_str("10.0.0.0").unwrap());
Expand All @@ -1212,14 +1215,23 @@ fn test_sbgp_extensions_builder() {
let asn_ext = SbgpAsIdentifier::new()
.critical()
.add_asn(32)
.add_asn_range(10,20)
.build(&builder.x509v3_context(None, None)).unwrap();
.add_asn_range(10, 20)
.build(&builder.x509v3_context(None, None))
.unwrap();
builder.append_extension(asn_ext).unwrap();

let mut ip_addr_ext = SbgpIpAddressIdentifier::new();
ip_addr_ext.critical();
ip_addr_ext.add_ipv6_addr_range(Ipv6Addr::from_str("fd00::").unwrap(), Ipv6Addr::from_str("fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff").unwrap());
ip_addr_ext.add_ipv4_addr_range(Ipv4Addr::from_str("10.0.0.0").unwrap(), Ipv4Addr::from_str("10.0.0.255").unwrap());
let build_ext = ip_addr_ext.build(&builder.x509v3_context(None, None)).unwrap();
ip_addr_ext.add_ipv6_addr_range(
Ipv6Addr::from_str("fd00::").unwrap(),
Ipv6Addr::from_str("fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff").unwrap(),
);
ip_addr_ext.add_ipv4_addr_range(
Ipv4Addr::from_str("10.0.0.0").unwrap(),
Ipv4Addr::from_str("10.0.0.255").unwrap(),
);
let build_ext = ip_addr_ext
.build(&builder.x509v3_context(None, None))
.unwrap();
builder.append_extension(build_ext).unwrap();
}
}

0 comments on commit cc555a8

Please sign in to comment.