diff options
author | Alex Auvolat <alex@adnab.me> | 2022-12-12 15:47:10 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-12-12 15:47:55 +0100 |
commit | 0e61e3b6fbe00e518225d851b04b47f6f1ba07a6 (patch) | |
tree | 1ee78730b1f7cb9d9c3fc4e93edfb7292e6a92f6 /src/garage/tests/bucket.rs | |
parent | 2ac75018a14a22b61cfc68bc66b4f82a981a4838 (diff) | |
download | garage-0e61e3b6fbe00e518225d851b04b47f6f1ba07a6.tar.gz garage-0e61e3b6fbe00e518225d851b04b47f6f1ba07a6.zip |
Fix bucket creation tests to take permissions into account
Diffstat (limited to 'src/garage/tests/bucket.rs')
-rw-r--r-- | src/garage/tests/bucket.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/garage/tests/bucket.rs b/src/garage/tests/bucket.rs index b32af068..9c363013 100644 --- a/src/garage/tests/bucket.rs +++ b/src/garage/tests/bucket.rs @@ -1,4 +1,5 @@ use crate::common; +use crate::common::ext::CommandExt; use aws_sdk_s3::model::BucketLocationConstraint; use aws_sdk_s3::output::DeleteBucketOutput; @@ -8,6 +9,27 @@ async fn test_bucket_all() { let bucket_name = "hello"; { + // Check bucket cannot be created if not authorized + ctx.garage + .command() + .args(["key", "deny"]) + .args(["--create-bucket", &ctx.garage.key.id]) + .quiet() + .expect_success_output("Could not deny key to create buckets"); + + // Try create bucket, should fail + let r = ctx.client.create_bucket().bucket(bucket_name).send().await; + assert!(r.is_err()); + } + { + // Now allow key to create bucket + ctx.garage + .command() + .args(["key", "allow"]) + .args(["--create-bucket", &ctx.garage.key.id]) + .quiet() + .expect_success_output("Could not deny key to create buckets"); + // Create bucket //@TODO check with an invalid bucket name + with an already existing bucket let r = ctx |