Skip to content

Commit

Permalink
fix: Fix presign related unit tests (apache#1910)
Browse files Browse the repository at this point in the history
* fix: Fix presign related unit tests

Signed-off-by: Xuanwo <github@xuanwo.io>

* Fix typo

Signed-off-by: Xuanwo <github@xuanwo.io>

---------

Signed-off-by: Xuanwo <github@xuanwo.io>
  • Loading branch information
Xuanwo authored and wcy-fdu committed Apr 12, 2023
1 parent 169094d commit 15f985e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions core/src/services/s3/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ impl S3Core {
self.signer.sign(req, &cred).map_err(new_request_sign_error)
}

pub async fn sign_query<T>(&self, req: &mut Request<T>, durtion: Duration) -> Result<()> {
pub async fn sign_query<T>(&self, req: &mut Request<T>, duration: Duration) -> Result<()> {
let cred = if let Some(cred) = self.load_credential().await? {
cred
} else {
return Ok(());
};

self.signer
.sign_query(req, durtion, &cred)
.sign_query(req, duration, &cred)
.map_err(new_request_sign_error)
}

Expand Down
20 changes: 10 additions & 10 deletions core/src/types/operator/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,11 +1061,11 @@ impl Operator {
/// use anyhow::Result;
/// use futures::io;
/// use opendal::Operator;
/// use time::Duration;
/// use std::time::Duration;
///
/// #[tokio::main]
/// async fn test(op: Operator) -> Result<()> {
/// let signed_req = op.presign_stat("test",Duration::hours(1)).await?;
/// let signed_req = op.presign_stat("test",Duration::from_secs(3600)).await?;
/// let req = http::Request::builder()
/// .method(signed_req.method())
/// .uri(signed_req.uri())
Expand All @@ -1091,11 +1091,11 @@ impl Operator {
/// use anyhow::Result;
/// use futures::io;
/// use opendal::Operator;
/// use time::Duration;
/// use std::time::Duration;
///
/// #[tokio::main]
/// async fn test(op: Operator) -> Result<()> {
/// let signed_req = op.presign_read("test.txt", Duration::hours(1)).await?;
/// let signed_req = op.presign_read("test.txt", Duration::from_secs(3600)).await?;
/// # Ok(())
/// # }
/// ```
Expand Down Expand Up @@ -1128,14 +1128,14 @@ impl Operator {
/// use anyhow::Result;
/// use futures::io;
/// use opendal::Operator;
/// use time::Duration;
/// use std::time::Duration;
/// use opendal::ops::OpRead;
///
/// #[tokio::main]
/// async fn test(op: Operator) -> Result<()> {
/// let args = OpRead::new()
/// .with_override_content_disposition("attachment; filename=\"othertext.txt\"");
/// let signed_req = op.presign_read_with("test.txt", args, Duration::hours(1)).await?;
/// let signed_req = op.presign_read_with("test.txt", args, Duration::from_secs(3600)).await?;
/// # Ok(())
/// # }
/// ```
Expand All @@ -1161,11 +1161,11 @@ impl Operator {
/// use anyhow::Result;
/// use futures::io;
/// use opendal::Operator;
/// use time::Duration;
/// use std::time::Duration;
///
/// #[tokio::main]
/// async fn test(op: Operator) -> Result<()> {
/// let signed_req = op.presign_write("test.txt", Duration::hours(1)).await?;
/// let signed_req = op.presign_write("test.txt", Duration::from_secs(3600)).await?;
/// # Ok(())
/// # }
/// ```
Expand Down Expand Up @@ -1194,12 +1194,12 @@ impl Operator {
/// use futures::io;
/// use opendal::ops::OpWrite;
/// use opendal::Operator;
/// use time::Duration;
/// use std::time::Duration;
///
/// #[tokio::main]
/// async fn test(op: Operator) -> Result<()> {
/// let args = OpWrite::new().with_content_type("text/csv");
/// let signed_req = op.presign_write_with("test", args, Duration::hours(1)).await?;
/// let signed_req = op.presign_write_with("test", args, Duration::from_secs(3600)).await?;
/// let req = http::Request::builder()
/// .method(signed_req.method())
/// .uri(signed_req.uri())
Expand Down

0 comments on commit 15f985e

Please sign in to comment.