mirror of
https://git.deuxfleurs.fr/Deuxfleurs/garage.git
synced 2024-11-21 15:41:02 +00:00
Functional tests for admin commands
This commit is contained in:
parent
8df1e186de
commit
c00b2c9948
3 changed files with 75 additions and 15 deletions
|
@ -143,21 +143,6 @@ fi
|
|||
|
||||
rm /tmp/garage.{1..3}.{rnd,b64}
|
||||
|
||||
if [ -z "$SKIP_AWS" ]; then
|
||||
echo "🪣 Test bucket logic "
|
||||
AWS_ACCESS_KEY_ID=`cat /tmp/garage.s3 |cut -d' ' -f1`
|
||||
[ $(aws s3 ls | wc -l) == 1 ]
|
||||
garage -c /tmp/config.1.toml bucket create seau
|
||||
garage -c /tmp/config.1.toml bucket allow --read seau --key $AWS_ACCESS_KEY_ID
|
||||
[ $(aws s3 ls | wc -l) == 2 ]
|
||||
garage -c /tmp/config.1.toml bucket deny --read seau --key $AWS_ACCESS_KEY_ID
|
||||
[ $(aws s3 ls | wc -l) == 1 ]
|
||||
garage -c /tmp/config.1.toml bucket allow --read seau --key $AWS_ACCESS_KEY_ID
|
||||
[ $(aws s3 ls | wc -l) == 2 ]
|
||||
garage -c /tmp/config.1.toml bucket delete --yes seau
|
||||
[ $(aws s3 ls | wc -l) == 1 ]
|
||||
fi
|
||||
|
||||
echo "🏁 Teardown"
|
||||
AWS_ACCESS_KEY_ID=`cat /tmp/garage.s3 |cut -d' ' -f1`
|
||||
AWS_SECRET_ACCESS_KEY=`cat /tmp/garage.s3 |cut -d' ' -f2`
|
||||
|
|
74
src/garage/tests/admin.rs
Normal file
74
src/garage/tests/admin.rs
Normal file
|
@ -0,0 +1,74 @@
|
|||
use crate::common;
|
||||
use crate::common::ext::*;
|
||||
|
||||
const BCKT_NAME: &str = "seau";
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_admin_bucket_perms() {
|
||||
let ctx = common::context();
|
||||
|
||||
let hb = || ctx.client.head_bucket().bucket(BCKT_NAME).send();
|
||||
|
||||
assert!(hb().await.is_err());
|
||||
|
||||
ctx.garage
|
||||
.command()
|
||||
.args(["bucket", "create", BCKT_NAME])
|
||||
.quiet()
|
||||
.expect_success_status("Could not create bucket");
|
||||
|
||||
assert!(hb().await.is_err());
|
||||
|
||||
ctx.garage
|
||||
.command()
|
||||
.args([
|
||||
"bucket",
|
||||
"allow",
|
||||
"--read",
|
||||
"--key",
|
||||
&ctx.garage.key.id,
|
||||
BCKT_NAME,
|
||||
])
|
||||
.quiet()
|
||||
.expect_success_status("Could not create bucket");
|
||||
|
||||
assert!(hb().await.is_ok());
|
||||
|
||||
ctx.garage
|
||||
.command()
|
||||
.args([
|
||||
"bucket",
|
||||
"deny",
|
||||
"--read",
|
||||
"--key",
|
||||
&ctx.garage.key.name,
|
||||
BCKT_NAME,
|
||||
])
|
||||
.quiet()
|
||||
.expect_success_status("Could not create bucket");
|
||||
|
||||
assert!(hb().await.is_err());
|
||||
|
||||
ctx.garage
|
||||
.command()
|
||||
.args([
|
||||
"bucket",
|
||||
"allow",
|
||||
"--read",
|
||||
"--key",
|
||||
&ctx.garage.key.name,
|
||||
BCKT_NAME,
|
||||
])
|
||||
.quiet()
|
||||
.expect_success_status("Could not create bucket");
|
||||
|
||||
assert!(hb().await.is_ok());
|
||||
|
||||
ctx.garage
|
||||
.command()
|
||||
.args(["bucket", "delete", "--yes", BCKT_NAME])
|
||||
.quiet()
|
||||
.expect_success_status("Could not delete bucket");
|
||||
|
||||
assert!(hb().await.is_err());
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
#[macro_use]
|
||||
mod common;
|
||||
|
||||
mod admin;
|
||||
mod bucket;
|
||||
mod list;
|
||||
mod multipart;
|
||||
|
|
Loading…
Reference in a new issue