Skip to content

Commit 290bdac

Browse files
committed
Apply clippy suggestions for test targets
1 parent 0d6fb06 commit 290bdac

3 files changed

Lines changed: 8 additions & 12 deletions

File tree

.github/workflows/rust.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ jobs:
167167
uses: dtolnay/rust-toolchain@stable
168168
with:
169169
components: clippy
170-
- run: cargo clippy --locked --all-features -- --deny warnings
170+
- run: cargo clippy --locked --all-features --all-targets -- --deny warnings
171171

172172
clippy-nightly:
173173
name: Clippy (Nightly)
@@ -181,5 +181,4 @@ jobs:
181181
uses: dtolnay/rust-toolchain@nightly
182182
with:
183183
components: clippy
184-
- run: cargo clippy --locked --all-features -- --deny warnings
185-
184+
- run: cargo clippy --locked --all-features --all-targets -- --deny warnings

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ mod tests {
404404
fn from_env_bad_dir_perms() {
405405
// Create a temp dir that we can't read from.
406406
let temp_dir = tempfile::TempDir::new().unwrap();
407-
fs::set_permissions(temp_dir.path(), Permissions::from_mode(0)).unwrap();
407+
fs::set_permissions(temp_dir.path(), Permissions::from_mode(0o000)).unwrap();
408408

409409
test_cert_paths_bad_perms(CertPaths {
410410
file: None,
@@ -420,7 +420,7 @@ mod tests {
420420
let file_path = temp_dir.path().join("unreadable.pem");
421421
let cert_file = File::create(&file_path).unwrap();
422422
cert_file
423-
.set_permissions(Permissions::from_mode(0))
423+
.set_permissions(Permissions::from_mode(0o000))
424424
.unwrap();
425425

426426
test_cert_paths_bad_perms(CertPaths {

tests/compare_mozilla.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn test_does_not_have_many_roots_unknown_by_mozilla() {
6767
let mut missing_in_moz_roots = 0;
6868

6969
for cert in &native {
70-
let cert = anchor_from_trusted_cert(&cert).unwrap();
70+
let cert = anchor_from_trusted_cert(cert).unwrap();
7171
if let Some(moz) = mozilla.get(cert.subject_public_key_info.as_ref()) {
7272
assert_eq!(cert.subject, moz.subject, "subjects differ for public key");
7373
} else {
@@ -103,18 +103,15 @@ fn test_contains_most_roots_known_by_mozilla() {
103103

104104
let mut native_map = HashMap::new();
105105
for anchor in &native {
106-
let cert = anchor_from_trusted_cert(&anchor).unwrap();
106+
let cert = anchor_from_trusted_cert(anchor).unwrap();
107107
let spki = cert.subject_public_key_info.as_ref();
108108
native_map.insert(spki.to_owned(), anchor);
109109
}
110110

111111
let mut missing_in_native_roots = 0;
112112
let mozilla = webpki_roots::TLS_SERVER_ROOTS;
113113
for cert in mozilla {
114-
if native_map
115-
.get(cert.subject_public_key_info.as_ref())
116-
.is_none()
117-
{
114+
if !native_map.contains_key(cert.subject_public_key_info.as_ref()) {
118115
println!(
119116
"Mozilla anchor {:?} is missing from native set",
120117
stringify_x500name(&cert.subject)
@@ -152,7 +149,7 @@ fn util_list_certs() {
152149
let native = rustls_native_certs::load_native_certs().unwrap();
153150

154151
for (i, cert) in native.iter().enumerate() {
155-
let cert = anchor_from_trusted_cert(&cert).unwrap();
152+
let cert = anchor_from_trusted_cert(cert).unwrap();
156153
println!("cert[{i}] = {}", stringify_x500name(&cert.subject));
157154
}
158155
}

0 commit comments

Comments
 (0)