Clippy
This commit is contained in:
parent
96b7d5ff21
commit
d322d3a380
@ -722,7 +722,7 @@ fn ensure_err_lib_enum_is_named(source_code: &mut Vec<u8>) {
|
||||
let src = String::from_utf8_lossy(source_code);
|
||||
let enum_type = src
|
||||
.split_once("ERR_LIB_SSL:")
|
||||
.and_then(|(_, def)| Some(def.split_once("=")?.0))
|
||||
.and_then(|(_, def)| Some(def.split_once('=')?.0))
|
||||
.unwrap_or("_bindgen_ty_1");
|
||||
|
||||
source_code.extend_from_slice(
|
||||
|
||||
@ -300,7 +300,7 @@ mod test {
|
||||
let mut ctx = BigNumContext::new().unwrap();
|
||||
let mut calc = BigNum::new().unwrap();
|
||||
calc.mod_exp(g, priv_key, p, &mut ctx).unwrap();
|
||||
assert_eq!(&calc, pub_key)
|
||||
assert_eq!(&calc, pub_key);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@ -79,6 +79,7 @@ impl ErrorCode {
|
||||
}
|
||||
|
||||
#[corresponds(SSL_error_description)]
|
||||
#[must_use]
|
||||
pub fn description(self) -> Option<&'static str> {
|
||||
unsafe {
|
||||
let msg = ffi::SSL_error_description(self.0);
|
||||
|
||||
@ -1658,7 +1658,7 @@ impl SslContextBuilder {
|
||||
C: CertificateCompressor,
|
||||
{
|
||||
const {
|
||||
assert!(C::CAN_COMPRESS || C::CAN_DECOMPRESS, "Either compression or decompression must be supported for algorithm to be registered")
|
||||
assert!(C::CAN_COMPRESS || C::CAN_DECOMPRESS, "Either compression or decompression must be supported for algorithm to be registered");
|
||||
};
|
||||
let success = unsafe {
|
||||
ffi::SSL_CTX_add_cert_compression_alg(
|
||||
@ -1705,7 +1705,7 @@ impl SslContextBuilder {
|
||||
decrypt: Some(callbacks::raw_decrypt::<M>),
|
||||
complete: Some(callbacks::raw_complete::<M>),
|
||||
},
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2327,6 +2327,7 @@ impl SslContextRef {
|
||||
}
|
||||
|
||||
/// Returns `true` if context is configured for X.509 certificates.
|
||||
#[must_use]
|
||||
pub fn has_x509_support(&self) -> bool {
|
||||
self.ex_data(*X509_FLAG_INDEX).copied().unwrap_or_default()
|
||||
}
|
||||
@ -2351,6 +2352,7 @@ impl SslContextRef {
|
||||
/// Returns the list of server certificate types.
|
||||
#[corresponds(SSL_CTX_get0_server_certificate_types)]
|
||||
#[cfg(feature = "rpk")]
|
||||
#[must_use]
|
||||
pub fn server_certificate_types(&self) -> Option<&[CertificateType]> {
|
||||
let mut types = ptr::null();
|
||||
let mut types_len = 0;
|
||||
@ -4644,6 +4646,7 @@ impl SslCredentialBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn build(self) -> SslCredential {
|
||||
self.0
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ fn ech() {
|
||||
let (_server, client) = bootstrap_ech(ECH_CONFIG, ECH_KEY, ECH_CONFIG_LIST);
|
||||
|
||||
let ssl_stream = client.connect();
|
||||
assert!(ssl_stream.ssl().ech_accepted())
|
||||
assert!(ssl_stream.ssl().ech_accepted());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -57,7 +57,7 @@ fn ech_rejection() {
|
||||
Some(b"ech.com".to_vec().as_ref())
|
||||
);
|
||||
assert!(failed_ssl_stream.ssl().get_ech_retry_configs().is_some());
|
||||
assert!(!failed_ssl_stream.ssl().ech_accepted())
|
||||
assert!(!failed_ssl_stream.ssl().ech_accepted());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -69,5 +69,5 @@ fn ech_grease() {
|
||||
client.ssl().set_enable_ech_grease(true);
|
||||
|
||||
let ssl_stream = client.connect();
|
||||
assert!(!ssl_stream.ssl().ech_accepted())
|
||||
assert!(!ssl_stream.ssl().ech_accepted());
|
||||
}
|
||||
|
||||
@ -1010,7 +1010,7 @@ fn test_set_compliance() {
|
||||
assert_eq!(ciphers.len(), FIPS_CIPHERS.len());
|
||||
|
||||
for cipher in ciphers.into_iter().zip(FIPS_CIPHERS) {
|
||||
assert_eq!(cipher.0.name(), cipher.1)
|
||||
assert_eq!(cipher.0.name(), cipher.1);
|
||||
}
|
||||
|
||||
let mut ctx = SslContext::builder(SslMethod::tls()).unwrap();
|
||||
@ -1029,7 +1029,7 @@ fn test_set_compliance() {
|
||||
assert_eq!(ciphers.len(), WPA3_192_CIPHERS.len());
|
||||
|
||||
for cipher in ciphers.into_iter().zip(WPA3_192_CIPHERS) {
|
||||
assert_eq!(cipher.0.name(), cipher.1)
|
||||
assert_eq!(cipher.0.name(), cipher.1);
|
||||
}
|
||||
|
||||
ctx.set_compliance_policy(CompliancePolicy::NONE)
|
||||
@ -1092,7 +1092,7 @@ fn test_ssl_set_compliance() {
|
||||
assert_eq!(ciphers.len(), FIPS_CIPHERS.len());
|
||||
|
||||
for cipher in ciphers.into_iter().zip(FIPS_CIPHERS) {
|
||||
assert_eq!(cipher.0.name(), cipher.1)
|
||||
assert_eq!(cipher.0.name(), cipher.1);
|
||||
}
|
||||
|
||||
let ctx = SslContext::builder(SslMethod::tls()).unwrap().build();
|
||||
@ -1112,7 +1112,7 @@ fn test_ssl_set_compliance() {
|
||||
assert_eq!(ciphers.len(), WPA3_192_CIPHERS.len());
|
||||
|
||||
for cipher in ciphers.into_iter().zip(WPA3_192_CIPHERS) {
|
||||
assert_eq!(cipher.0.name(), cipher.1)
|
||||
assert_eq!(cipher.0.name(), cipher.1);
|
||||
}
|
||||
|
||||
ssl.set_compliance_policy(CompliancePolicy::NONE)
|
||||
|
||||
@ -49,7 +49,7 @@ fn new_get_session_callback() {
|
||||
.ctx()
|
||||
.set_session_cache_mode(SslSessionCacheMode::SERVER | SslSessionCacheMode::NO_INTERNAL);
|
||||
server.ctx().set_new_session_callback(|_, session| {
|
||||
SERVER_SESSION_DER.set(session.to_der().unwrap()).unwrap()
|
||||
SERVER_SESSION_DER.set(session.to_der().unwrap()).unwrap();
|
||||
});
|
||||
unsafe {
|
||||
server.ctx().set_get_session_callback(|_, id| {
|
||||
@ -76,7 +76,7 @@ fn new_get_session_callback() {
|
||||
.ctx()
|
||||
.set_session_cache_mode(SslSessionCacheMode::CLIENT);
|
||||
client.ctx().set_new_session_callback(|_, session| {
|
||||
CLIENT_SESSION_DER.set(session.to_der().unwrap()).unwrap()
|
||||
CLIENT_SESSION_DER.set(session.to_der().unwrap()).unwrap();
|
||||
});
|
||||
|
||||
let client = client.build();
|
||||
|
||||
@ -61,7 +61,7 @@ fn custom_callback_success() {
|
||||
unsafe {
|
||||
server
|
||||
.ctx()
|
||||
.set_ticket_key_callback(test_success_tickey_key_callback)
|
||||
.set_ticket_key_callback(test_success_tickey_key_callback);
|
||||
};
|
||||
let server = server.build();
|
||||
|
||||
@ -106,7 +106,7 @@ fn custom_callback_unrecognized_decryption_ticket() {
|
||||
unsafe {
|
||||
server
|
||||
.ctx()
|
||||
.set_ticket_key_callback(test_noop_tickey_key_callback)
|
||||
.set_ticket_key_callback(test_noop_tickey_key_callback);
|
||||
};
|
||||
let server = server.build();
|
||||
|
||||
|
||||
@ -177,6 +177,7 @@ impl X509StoreRef {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(clippy::redundant_clone)]
|
||||
#[should_panic = "Shared X509Store can't be mutated"]
|
||||
fn set_cert_store_pevents_mutability() {
|
||||
use crate::ssl::*;
|
||||
|
||||
@ -73,7 +73,7 @@ fn test_subject_read_cn() {
|
||||
let cert = X509::from_pem(cert).unwrap();
|
||||
let subject = cert.subject_name();
|
||||
let cn = subject.entries_by_nid(Nid::COMMONNAME).next().unwrap();
|
||||
assert_eq!(cn.data().as_slice(), b"foobar.com")
|
||||
assert_eq!(cn.data().as_slice(), b"foobar.com");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@ -60,7 +60,7 @@ fn test_verify_cert() {
|
||||
assert_eq!(
|
||||
Ok(()),
|
||||
verify(&leaf, &[&root1], &[&intermediate, &root1_cross], |param| {
|
||||
param.clear_flags(X509VerifyFlags::TRUSTED_FIRST)
|
||||
param.clear_flags(X509VerifyFlags::TRUSTED_FIRST);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@ -86,9 +86,8 @@ impl SessionCache {
|
||||
}
|
||||
|
||||
pub fn remove(&mut self, session: &SslSessionRef) {
|
||||
let key = match self.reverse.remove(session.id()) {
|
||||
Some(key) => key,
|
||||
None => return,
|
||||
let Some(key) = self.reverse.remove(session.id()) else {
|
||||
return;
|
||||
};
|
||||
|
||||
if let Entry::Occupied(mut sessions) = self.sessions.entry(key) {
|
||||
|
||||
@ -113,7 +113,7 @@ impl HttpsLayer {
|
||||
///
|
||||
/// The session cache configuration of `ssl` will be overwritten.
|
||||
pub fn with_connector(ssl: SslConnectorBuilder) -> Result<HttpsLayer, ErrorStack> {
|
||||
Self::with_connector_and_settings(ssl, Default::default())
|
||||
Self::with_connector_and_settings(ssl, HttpsLayerSettings::default())
|
||||
}
|
||||
|
||||
/// Creates a new `HttpsLayer` with settings
|
||||
@ -243,9 +243,8 @@ where
|
||||
let f = async {
|
||||
let conn = connect.await.map_err(Into::into)?.into_inner();
|
||||
|
||||
let (inner, uri) = match tls_setup {
|
||||
Some((inner, uri)) => (inner, uri),
|
||||
None => return Ok(MaybeHttpsStream::Http(conn)),
|
||||
let Some((inner, uri)) = tls_setup else {
|
||||
return Ok(MaybeHttpsStream::Http(conn));
|
||||
};
|
||||
|
||||
let mut host = uri.host().ok_or("URI missing host")?;
|
||||
|
||||
@ -78,7 +78,7 @@ async fn localhost() {
|
||||
|
||||
let file = File::create("../target/keyfile.log").unwrap();
|
||||
ssl.set_keylog_callback(move |_, line| {
|
||||
let _ = writeln!(&file, "{}", line);
|
||||
let _ = writeln!(&file, "{line}");
|
||||
});
|
||||
|
||||
let ssl = HttpsConnector::with_connector(connector, ssl).unwrap();
|
||||
@ -86,7 +86,7 @@ async fn localhost() {
|
||||
|
||||
for _ in 0..3 {
|
||||
let resp = client
|
||||
.get(format!("https://foobar.com:{}", port).parse().unwrap())
|
||||
.get(format!("https://foobar.com:{port}").parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(resp.status().is_success(), "{}", resp.status());
|
||||
@ -149,7 +149,7 @@ async fn alpn_h2() {
|
||||
let client = Client::builder(TokioExecutor::new()).build::<_, Empty<Bytes>>(ssl);
|
||||
|
||||
let resp = client
|
||||
.get(format!("https://foobar.com:{}", port).parse().unwrap())
|
||||
.get(format!("https://foobar.com:{port}").parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(resp.status().is_success(), "{}", resp.status());
|
||||
|
||||
@ -26,7 +26,7 @@ async fn test() {
|
||||
builder
|
||||
.set_session_cache_mode(SslSessionCacheMode::SERVER | SslSessionCacheMode::NO_INTERNAL);
|
||||
builder.set_new_session_callback(|_, session| {
|
||||
SERVER_SESSION_DER.set(session.to_der().unwrap()).unwrap()
|
||||
SERVER_SESSION_DER.set(session.to_der().unwrap()).unwrap();
|
||||
});
|
||||
|
||||
unsafe {
|
||||
@ -49,7 +49,7 @@ async fn test() {
|
||||
let connector = create_connector(|builder| {
|
||||
builder.set_session_cache_mode(SslSessionCacheMode::CLIENT);
|
||||
builder.set_new_session_callback(|_, session| {
|
||||
CLIENT_SESSION_DER.set(session.to_der().unwrap()).unwrap()
|
||||
CLIENT_SESSION_DER.set(session.to_der().unwrap()).unwrap();
|
||||
});
|
||||
|
||||
builder.set_ca_file("tests/cert.pem")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user