-
Notifications
You must be signed in to change notification settings - Fork 139
Ensure CI covers examples and unit tests, fix clippy findings #191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
19c12e6
ci: remove unnecessary --all
cpu b57db73
ci: use --all-targets for cargo check and test
cpu 138293c
tests: silence clippy unusual_byte_groupings warn
cpu aec8f14
tests: fix unnecessary references
cpu b9e5db7
lib: switch single char string constant to char constant
cpu 9f15d8d
tests: prefer is_empty() to 0 equality check
cpu a843c74
tests: fix decimal constants
cpu df1b7a1
tests: fix unused, ellidable lifetimes
cpu da0e431
tests: use assert! instead of assert_eq!(x, true)
cpu 1256085
examples: avoid format collect
cpu 846ec85
examples: enable more clippy categories for examples
cpu ed27b3e
ci: run clippy with --all-targets
cpu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,15 +20,15 @@ fn verify_cert_basic(cert: &Certificate) { | |
| let cert_pem = cert.serialize_pem().unwrap(); | ||
| println!("{cert_pem}"); | ||
|
|
||
| let x509 = X509::from_pem(&cert_pem.as_bytes()).unwrap(); | ||
| let x509 = X509::from_pem(cert_pem.as_bytes()).unwrap(); | ||
| let mut builder = X509StoreBuilder::new().unwrap(); | ||
| builder.add_cert(x509.clone()).unwrap(); | ||
|
|
||
| let store: X509Store = builder.build(); | ||
| let mut ctx = X509StoreContext::new().unwrap(); | ||
| let mut stack = Stack::new().unwrap(); | ||
| stack.push(x509.clone()).unwrap(); | ||
| ctx.init(&store, &x509, &stack.as_ref(), |ctx| { | ||
| ctx.init(&store, &x509, stack.as_ref(), |ctx| { | ||
| ctx.verify_cert().unwrap(); | ||
| Ok(()) | ||
| }) | ||
|
|
@@ -79,7 +79,7 @@ impl Read for PipeEnd { | |
| fn read(&mut self, mut buf: &mut [u8]) -> ioResult<usize> { | ||
| let inner = self.inner.borrow_mut(); | ||
| let r_sl = &inner.0[1 - self.end_idx][self.read_pos..]; | ||
| if r_sl.len() == 0 { | ||
| if r_sl.is_empty() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is one of the clippy lints that I don't like :(. |
||
| return Err(Error::new(ErrorKind::WouldBlock, "oh no!")); | ||
| } | ||
| let r = buf.len().min(r_sl.len()); | ||
|
|
@@ -101,9 +101,9 @@ fn verify_cert_ca(cert_pem: &str, key: &[u8], ca_cert_pem: &str) { | |
| println!("{cert_pem}"); | ||
| println!("{ca_cert_pem}"); | ||
|
|
||
| let x509 = X509::from_pem(&cert_pem.as_bytes()).unwrap(); | ||
| let x509 = X509::from_pem(cert_pem.as_bytes()).unwrap(); | ||
|
|
||
| let ca_x509 = X509::from_pem(&ca_cert_pem.as_bytes()).unwrap(); | ||
| let ca_x509 = X509::from_pem(ca_cert_pem.as_bytes()).unwrap(); | ||
|
|
||
| let mut builder = X509StoreBuilder::new().unwrap(); | ||
| builder.add_cert(ca_x509).unwrap(); | ||
|
|
@@ -113,7 +113,7 @@ fn verify_cert_ca(cert_pem: &str, key: &[u8], ca_cert_pem: &str) { | |
| let srv = SslMethod::tls_server(); | ||
| let mut ssl_srv_ctx = SslAcceptor::mozilla_modern(srv).unwrap(); | ||
| //let key = cert.serialize_private_key_der(); | ||
| let pkey = PKey::private_key_from_der(&key).unwrap(); | ||
| let pkey = PKey::private_key_from_der(key).unwrap(); | ||
| ssl_srv_ctx.set_private_key(&pkey).unwrap(); | ||
|
|
||
| ssl_srv_ctx.set_certificate(&x509).unwrap(); | ||
|
|
@@ -168,7 +168,7 @@ fn verify_csr(cert: &Certificate) { | |
| let key = cert.serialize_private_key_der(); | ||
| let pkey = PKey::private_key_from_der(&key).unwrap(); | ||
|
|
||
| let req = X509Req::from_pem(&csr.as_bytes()).unwrap(); | ||
| let req = X509Req::from_pem(csr.as_bytes()).unwrap(); | ||
| req.verify(&pkey).unwrap(); | ||
| } | ||
|
|
||
|
|
@@ -241,6 +241,7 @@ fn test_openssl_25519_v1_given() { | |
| // Now verify the certificate as well as CSR, | ||
| // but only on OpenSSL >= 1.1.1 | ||
| // On prior versions, only do basic verification | ||
| #[allow(clippy::unusual_byte_groupings)] | ||
| if openssl::version::number() >= 0x1_01_01_00_f { | ||
| verify_cert(&cert); | ||
| verify_csr(&cert); | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.