Skip to content

Commit 45316af

Browse files
authored
Merge pull request #453 from w4nderlust/fix/presign-tests-missing-ignore
Fix presign tests: use fake credentials instead of minio env vars
2 parents 57525a4 + 181664d commit 45316af

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

s3/src/bucket.rs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3229,6 +3229,28 @@ mod test {
32293229
.with_path_style()
32303230
}
32313231

3232+
/// Bucket with hardcoded fake credentials for tests that only exercise
3233+
/// local signing logic and never hit the network.
3234+
fn test_presign_bucket() -> Box<Bucket> {
3235+
Bucket::new(
3236+
"rust-s3",
3237+
Region::Custom {
3238+
region: "us-east-1".to_owned(),
3239+
endpoint: "http://localhost:9000".to_owned(),
3240+
},
3241+
Credentials::new(
3242+
Some("test_access_key"),
3243+
Some("test_secret_key"),
3244+
None,
3245+
None,
3246+
None,
3247+
)
3248+
.unwrap(),
3249+
)
3250+
.unwrap()
3251+
.with_path_style()
3252+
}
3253+
32323254
#[allow(dead_code)]
32333255
fn test_digital_ocean_bucket() -> Box<Bucket> {
32343256
Bucket::new("rust-s3", Region::DoFra1, test_digital_ocean_credentials()).unwrap()
@@ -3939,7 +3961,7 @@ mod test {
39393961
)]
39403962
async fn test_presign_put() {
39413963
let s3_path = "/test/test.file";
3942-
let bucket = test_minio_bucket();
3964+
let bucket = test_presign_bucket();
39433965

39443966
let mut custom_headers = HeaderMap::new();
39453967
custom_headers.insert(
@@ -3967,7 +3989,7 @@ mod test {
39673989
async fn test_presign_post() {
39683990
use std::borrow::Cow;
39693991

3970-
let bucket = test_minio_bucket();
3992+
let bucket = test_presign_bucket();
39713993

39723994
// Policy from sample
39733995
let policy = PostPolicy::new(86400)
@@ -3994,7 +4016,7 @@ mod test {
39944016
)]
39954017
async fn test_presign_get() {
39964018
let s3_path = "/test/test.file";
3997-
let bucket = test_minio_bucket();
4019+
let bucket = test_presign_bucket();
39984020

39994021
let url = bucket.presign_get(s3_path, 86400, None).await.unwrap();
40004022
assert!(url.contains("/test/test.file?"))
@@ -4010,7 +4032,7 @@ mod test {
40104032
)]
40114033
async fn test_presign_delete() {
40124034
let s3_path = "/test/test.file";
4013-
let bucket = test_minio_bucket();
4035+
let bucket = test_presign_bucket();
40144036

40154037
let url = bucket.presign_delete(s3_path, 86400).await.unwrap();
40164038
assert!(url.contains("/test/test.file?"))

0 commit comments

Comments
 (0)