Clippy fixes (#118)

This commit is contained in:
Dirkjan Ochtman 2022-10-11 16:12:04 +02:00 committed by GitHub
parent 87ecfe7c01
commit c033514814
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 41 deletions

View File

@ -5,6 +5,8 @@ on:
branches:
- master
pull_request: {}
schedule:
- cron: "33 4 * * 5"
jobs:
check:

View File

@ -129,8 +129,6 @@ async fn stream_good() -> io::Result<()> {
io::copy(&mut Cursor::new(FILE), &mut server.writer())?;
server.send_close_notify();
let mut server = Connection::from(server);
{
let mut good = Good(&mut server);
let mut stream = Stream::new(&mut good, &mut client);

View File

@ -401,11 +401,11 @@ impl<T> TlsStream<T> {
match self {
Client(io) => {
let (io, session) = io.get_ref();
(io, &*session)
(io, session)
}
Server(io) => {
let (io, session) = io.get_ref();
(io, &*session)
(io, session)
}
}
}

View File

@ -111,19 +111,16 @@ async fn pass() -> io::Result<()> {
tokio::time::sleep(Duration::from_secs(1)).await;
let chain = certs(&mut std::io::Cursor::new(*chain)).unwrap();
let trust_anchors = chain
.iter()
.map(|cert| {
let mut root_store = rustls::RootCertStore::empty();
root_store.add_server_trust_anchors(chain.iter().map(|cert| {
let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap();
OwnedTrustAnchor::from_subject_spki_name_constraints(
ta.subject,
ta.spki,
ta.name_constraints,
)
})
.collect::<Vec<_>>();
let mut root_store = rustls::RootCertStore::empty();
root_store.add_server_trust_anchors(trust_anchors.into_iter());
}));
let config = rustls::ClientConfig::builder()
.with_safe_defaults()
.with_root_certificates(root_store)
@ -140,19 +137,16 @@ async fn fail() -> io::Result<()> {
let (addr, domain, chain) = start_server();
let chain = certs(&mut std::io::Cursor::new(*chain)).unwrap();
let trust_anchors = chain
.iter()
.map(|cert| {
let mut root_store = rustls::RootCertStore::empty();
root_store.add_server_trust_anchors(chain.iter().map(|cert| {
let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap();
OwnedTrustAnchor::from_subject_spki_name_constraints(
ta.subject,
ta.spki,
ta.name_constraints,
)
})
.collect::<Vec<_>>();
let mut root_store = rustls::RootCertStore::empty();
root_store.add_server_trust_anchors(trust_anchors.into_iter());
}));
let config = rustls::ClientConfig::builder()
.with_safe_defaults()
.with_root_certificates(root_store)
@ -190,7 +184,7 @@ async fn test_lazy_config_acceptor() -> io::Result<()> {
assert_eq!(
ch.alpn()
.map(|protos| protos.collect::<Vec<_>>())
.unwrap_or(Vec::new()),
.unwrap_or_default(),
Vec::<&[u8]>::new()
);

View File

@ -27,18 +27,15 @@ mod utils {
let mut client_root_cert_store = RootCertStore::empty();
let mut chain = BufReader::new(Cursor::new(CHAIN));
let certs = certs(&mut chain).unwrap();
let trust_anchors = certs
.iter()
.map(|cert| {
client_root_cert_store.add_server_trust_anchors(certs.iter().map(|cert| {
let ta = webpki::TrustAnchor::try_from_cert_der(&cert[..]).unwrap();
OwnedTrustAnchor::from_subject_spki_name_constraints(
ta.subject,
ta.spki,
ta.name_constraints,
)
})
.collect::<Vec<_>>();
client_root_cert_store.add_server_trust_anchors(trust_anchors.into_iter());
}));
let cconfig = ClientConfig::builder()
.with_safe_defaults()
.with_root_certificates(client_root_cert_store)