Skip to content

Commit

Permalink
style(auth): rename inner method
Browse files Browse the repository at this point in the history
  • Loading branch information
tu6ge committed Aug 16, 2023
1 parent 1cffbe4 commit 075f55e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl InnerAuth<'_> {

let oss_header = self.to_oss_header();
let sign_string = SignString::from_auth(self, oss_header);
map.append_sign(sign_string.to_sign().map_err(AuthError::from)?)?;
map.append_sign(sign_string.into_sign().map_err(AuthError::from)?)?;

Ok(map)
}
Expand All @@ -207,7 +207,7 @@ impl InnerAuth<'_> {
headers.append_auth(&self)?;
let oss_header = self.to_oss_header();
let sign_string = SignString::from_auth(self, oss_header);
headers.append_sign(sign_string.to_sign().map_err(AuthError::from)?)?;
headers.append_sign(sign_string.into_sign().map_err(AuthError::from)?)?;

Ok(())
}
Expand Down Expand Up @@ -383,7 +383,7 @@ impl<'a> SignString<'a> {
}

// 转化成签名
fn to_sign(self) -> Result<Sign<'a>, hmac::digest::crypto_common::InvalidLength> {
fn into_sign(self) -> Result<Sign<'a>, hmac::digest::crypto_common::InvalidLength> {
Ok(Sign {
data: self.secret.encryption(self.data.as_bytes())?,
key: self.key,
Expand Down
4 changes: 2 additions & 2 deletions src/auth/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,12 @@ mod sign_string_struct {
};

#[test]
fn test_to_sign() {
fn test_into_sign() {
let key = KeyId::from("foo1");
let secret = KeySecret::from("foo2");
let sign_string = SignString::new("bar", key, secret);

let res = sign_string.to_sign();
let res = sign_string.into_sign();
assert!(res.is_ok());
let sign = res.unwrap();
assert_eq!(sign.data(), "gTzwiN1fRQV90YcecTvo1pH+kI8=");
Expand Down

0 comments on commit 075f55e

Please sign in to comment.