Skip to content

Commit 47e8fbb

Browse files
committed
Fix clippy warnings.
1 parent 6de2676 commit 47e8fbb

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/algorithm/rust_crypto.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ where
5454
}
5555

5656
fn sign(&self, header: &str, claims: &str) -> Result<String, Error> {
57-
let hmac = get_hmac_with_data(&self, header, claims);
57+
let hmac = get_hmac_with_data(self, header, claims);
5858
let mac_result = hmac.finalize();
5959
let code = mac_result.into_bytes();
6060
Ok(base64::encode_config(&code, base64::URL_SAFE_NO_PAD))
@@ -79,7 +79,7 @@ where
7979

8080
fn verify_bytes(&self, header: &str, claims: &str, signature: &[u8]) -> Result<bool, Error> {
8181
let hmac = get_hmac_with_data(self, header, claims);
82-
hmac.verify_slice(&signature)?;
82+
hmac.verify_slice(signature)?;
8383
Ok(true)
8484
}
8585
}
@@ -119,7 +119,7 @@ mod tests {
119119
let expected_signature = "TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ";
120120

121121
let signer: Hmac<Sha256> = Hmac::new_from_slice(b"secret")?;
122-
let computed_signature = SigningAlgorithm::sign(&signer, &header, &claims)?;
122+
let computed_signature = SigningAlgorithm::sign(&signer, header, claims)?;
123123

124124
assert_eq!(computed_signature, expected_signature);
125125
Ok(())
@@ -133,7 +133,7 @@ mod tests {
133133

134134
let verifier: Hmac<Sha256> = Hmac::new_from_slice(b"secret")?;
135135
assert!(VerifyingAlgorithm::verify(
136-
&verifier, &header, &claims, &signature
136+
&verifier, header, claims, signature
137137
)?);
138138
Ok(())
139139
}

src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ impl<H, C, S> Token<H, C, S> {
144144
}
145145
}
146146

147-
impl<H, C, S> Into<(H, C)> for Token<H, C, S> {
148-
fn into(self) -> (H, C) {
149-
(self.header, self.claims)
147+
impl<H, C, S> From<Token<H, C, S>> for (H, C) {
148+
fn from(token: Token<H, C, S>) -> Self {
149+
(token.header, token.claims)
150150
}
151151
}
152152

src/token/signed.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ impl<'a, H, C> Token<H, C, Signed> {
131131
}
132132
}
133133

134-
impl<H, C> Into<String> for Token<H, C, Signed> {
135-
fn into(self) -> String {
136-
self.signature.token_string
134+
impl<H, C> From<Token<H, C, Signed>> for String {
135+
fn from(token: Token<H, C, Signed>) -> Self {
136+
token.signature.token_string
137137
}
138138
}
139139

src/token/verified.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ mod tests {
247247

248248
// Header {"alg":"HS512","kid":"second_key"}
249249
// Claims {"name":"Jane Doe"}
250-
const JANE_DOE_SECOND_KEY_TOKEN: &'static str = "eyJhbGciOiJIUzUxMiIsImtpZCI6InNlY29uZF9rZXkifQ.eyJuYW1lIjoiSmFuZSBEb2UifQ.t2ON5s8DDb2hefBIWAe0jaEcp-T7b2Wevmj0kKJ8BFxKNQURHpdh4IA-wbmBmqtiCnqTGoRdqK45hhW0AOtz0A";
250+
const JANE_DOE_SECOND_KEY_TOKEN: &str = "eyJhbGciOiJIUzUxMiIsImtpZCI6InNlY29uZF9rZXkifQ.eyJuYW1lIjoiSmFuZSBEb2UifQ.t2ON5s8DDb2hefBIWAe0jaEcp-T7b2Wevmj0kKJ8BFxKNQURHpdh4IA-wbmBmqtiCnqTGoRdqK45hhW0AOtz0A";
251251

252252
#[test]
253253
pub fn verify_claims_with_b_tree_map() -> Result<(), Error> {

0 commit comments

Comments
 (0)