Skip to content

Commit

Permalink
Merge pull request #2 from paulgb/paulgb/satisfy-lint
Browse files Browse the repository at this point in the history
Satisfy clippy
  • Loading branch information
paulgb authored Mar 9, 2024
2 parents 6aa3ffd + a67fa2f commit 116c9b2
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 21 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# - name: Lint
# run: |
# cargo clippy --all-targets --locked --release -- -D clippy::all
- name: Lint
run: |
cargo clippy --all-targets --locked --release -- -D clippy::all
- name: Build
run: cargo build --verbose
- name: Run tests
Expand Down
13 changes: 5 additions & 8 deletions src/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ impl DirectoryBuilder {
fields(url = %self.url, custom_http_client = self.http_client.is_some(), dir = field::Empty)
)]
pub async fn build(&mut self) -> Result<Arc<Directory>, Error> {
let http_client = self
.http_client
.clone()
.unwrap_or_else(reqwest::Client::new);
let http_client = self.http_client.clone().unwrap_or_default();

let resp = http_client.get(&self.url).send().await?;

Expand Down Expand Up @@ -132,10 +129,10 @@ impl Directory {
pub(crate) async fn get_nonce(&self) -> Result<String, Error> {
let maybe_nonce = {
let mut guard = self.nonce.lock().unwrap();
std::mem::replace(&mut *guard, None)
(*guard).take()
};
let span = Span::current();
span.record("cached", &maybe_nonce.is_some());
span.record("cached", maybe_nonce.is_some());
if let Some(nonce) = maybe_nonce {
return Ok(nonce);
}
Expand All @@ -156,7 +153,7 @@ impl Directory {
account_id: &Option<String>,
) -> Result<reqwest::Response, Error> {
let nonce = self.get_nonce().await?;
let body = jws(url, Some(nonce), &payload, pkey, account_id.clone())?;
let body = jws(url, Some(nonce), payload, pkey, account_id.clone())?;
let body = serde_json::to_vec(&body)?;
let resp = self
.http_client
Expand Down Expand Up @@ -194,7 +191,7 @@ impl Directory {
attempt += 1;

let resp = self
.authenticated_request_raw(url, &payload, &pkey, &account_id)
.authenticated_request_raw(url, payload, pkey, account_id)
.await?;

let headers = resp.headers().clone();
Expand Down
4 changes: 2 additions & 2 deletions src/jws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub(crate) fn jws(
pkey: &PKey<Private>,
account_id: Option<String>,
) -> Result<JwsResult, Error> {
let payload_b64 = b64(&payload.as_bytes());
let payload_b64 = b64(payload.as_bytes());

let alg: String = match pkey.id() {
Id::RSA => "RS256".into(),
Expand All @@ -69,7 +69,7 @@ pub(crate) fn jws(
if let Some(kid) = account_id {
header.kid = kid.into();
} else {
header.jwk = Some(Jwk::new(&pkey));
header.jwk = Some(Jwk::new(pkey));
}

let protected_b64 = b64(&serde_json::to_string(&header)?.into_bytes());
Expand Down
4 changes: 2 additions & 2 deletions src/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ fn gen_csr(pkey: &PKey<openssl::pkey::Private>, domains: Vec<String>) -> Result<
stack.push(san_extension)?;
builder.add_extensions(&stack)?;

builder.set_pubkey(&pkey)?;
builder.set_pubkey(pkey)?;
builder.sign(pkey, MessageDigest::sha256())?;

Ok(builder.build())
Expand Down Expand Up @@ -241,7 +241,7 @@ impl Order {
/// state for this to complete.
#[instrument(level = Level::INFO, name = "acme2::Order::certificate", err, skip(self), fields(order_url = %self.url, has_certificate = field::Empty))]
pub async fn certificate(&self) -> Result<Option<Vec<X509>>, Error> {
Span::current().record("has_certificate", &self.certificate_url.is_some());
Span::current().record("has_certificate", self.certificate_url.is_some());
let certificate_url = match self.certificate_url.clone() {
Some(certificate_url) => certificate_url,
None => return Ok(None),
Expand Down
7 changes: 2 additions & 5 deletions tests/common/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,8 @@ impl Container {

while let Some(next) = stream.next().await {
let chunk = next?;
match chunk {
LogOutput::StdOut { message } => {
stdout_buffer.extend(message);
}
_ => {}
if let LogOutput::StdOut { message } = chunk {
stdout_buffer.extend(message);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async fn test_account_creation_pebble_eab() {
let eab_key = {
let value_b64 = private_key;
let value = base64::engine::general_purpose::STANDARD
.decode(&value_b64)
.decode(value_b64)
.unwrap();
PKey::hmac(&value).unwrap()
};
Expand Down

0 comments on commit 116c9b2

Please sign in to comment.