2022-02-02 14:35:52 +00:00
|
|
|
use aws_sdk_s3::{Client, Region};
|
|
|
|
use ext::*;
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
pub mod macros;
|
|
|
|
|
|
|
|
pub mod client;
|
|
|
|
pub mod ext;
|
|
|
|
pub mod garage;
|
|
|
|
|
|
|
|
const REGION: Region = Region::from_static("garage-integ-test");
|
|
|
|
|
|
|
|
pub struct Context {
|
|
|
|
pub garage: &'static garage::Instance,
|
|
|
|
pub client: Client,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Context {
|
|
|
|
fn new() -> Self {
|
|
|
|
let garage = garage::instance();
|
|
|
|
let client = client::build_client(garage);
|
|
|
|
|
|
|
|
Context { garage, client }
|
|
|
|
}
|
|
|
|
|
2022-02-04 16:55:54 +00:00
|
|
|
/// Create an unique bucket with a random suffix.
|
|
|
|
///
|
|
|
|
/// Return the created bucket full name.
|
|
|
|
pub fn create_bucket(&self, name: &str) -> String {
|
2022-02-07 16:00:03 +00:00
|
|
|
let bucket_name = name.to_owned();
|
2022-02-04 16:55:54 +00:00
|
|
|
|
2022-02-02 14:35:52 +00:00
|
|
|
self.garage
|
|
|
|
.command()
|
2022-02-04 16:55:54 +00:00
|
|
|
.args(["bucket", "create", &bucket_name])
|
2022-02-02 14:35:52 +00:00
|
|
|
.quiet()
|
|
|
|
.expect_success_status("Could not create bucket");
|
|
|
|
self.garage
|
|
|
|
.command()
|
|
|
|
.args(["bucket", "allow"])
|
|
|
|
.args(["--owner", "--read", "--write"])
|
2022-02-04 16:55:54 +00:00
|
|
|
.arg(&bucket_name)
|
2022-02-02 14:35:52 +00:00
|
|
|
.args(["--key", &self.garage.key.name])
|
|
|
|
.quiet()
|
|
|
|
.expect_success_status("Could not allow key for bucket");
|
2022-02-04 16:55:54 +00:00
|
|
|
|
|
|
|
bucket_name
|
2022-02-02 14:35:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn context() -> Context {
|
|
|
|
Context::new()
|
|
|
|
}
|