aboutsummaryrefslogtreecommitdiff
path: root/src/garage/tests/admin.rs
blob: 37aefe38e7a89d9cbcfb613cda7ccb55c37e0ab4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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());
}