Skip to content

Commit

Permalink
Fix query
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <github@xuanwo.io>
  • Loading branch information
Xuanwo committed Apr 8, 2024
1 parent f25ad2d commit 122dc12
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/tencent/cos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fn build_signature(
.map(|(k, v)| {
(
utf8_percent_encode(&k.to_lowercase(), &TENCENT_URI_ENCODE_SET).to_string(),
utf8_percent_encode(&v.to_lowercase(), &TENCENT_URI_ENCODE_SET).to_string(),
utf8_percent_encode(v, &TENCENT_URI_ENCODE_SET).to_string(),
)
})
.collect::<Vec<_>>();
Expand Down
35 changes: 35 additions & 0 deletions tests/tencent/cos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,38 @@ async fn test_list_bucket() -> Result<()> {
assert_eq!(StatusCode::OK, status);
Ok(())
}

#[tokio::test]
async fn test_list_bucket_with_upper_cases() -> Result<()> {
let signer = init_signer();
if signer.is_none() {
warn!("REQSIGN_TENCENT_COS_TEST is not set, skipped");
return Ok(());
}
let (loader, signer) = signer.unwrap();
let cred = loader.load().await?.unwrap();

let url = &env::var("REQSIGN_TENCENT_COS_URL").expect("env REQSIGN_TENCENT_COS_URL must set");

let mut req = Request::new("");
*req.method_mut() = http::Method::GET;
*req.uri_mut() = http::Uri::from_str(&format!("{url}?prefix=stage/1712557668-ZgPY8Ql4"))?;

signer
.sign(&mut req, &cred)
.expect("sign request must success");

debug!("signed request: {:?}", req);

let client = Client::new();
let resp = client
.execute(req.try_into()?)
.await
.expect("request must success");

let status = resp.status();
debug!("got response: {:?}", resp);
debug!("got response content: {}", resp.text().await?);
assert_eq!(StatusCode::OK, status);
Ok(())
}

0 comments on commit 122dc12

Please sign in to comment.