Skip to content

Commit

Permalink
Delete asset bucket test file after access checks pass
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Detjens <[email protected]>
  • Loading branch information
detjensrobert committed Nov 18, 2024
1 parent 0464f1e commit 6cfd4bd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/access_handlers/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ pub async fn check(profile_name: &str) -> Result<()> {
bucket
.put_object_with_content_type(test_file.0, test_file.1.as_bytes(), "text/plain")
.await
.with_context(|| format!("could not upload to bucket {:?}", profile.s3.bucket_name))?;
.with_context(|| {
format!(
"could not upload to asset bucket {:?}",
profile.s3.bucket_name
)
})?;

// download it to check
debug!("downloading test file");
Expand All @@ -42,14 +47,17 @@ pub async fn check(profile_name: &str) -> Result<()> {
.await
.with_context(|| {
anyhow!(
"public download from qbucket {:?} failed",
"public download from asset bucket {:?} failed",
profile.s3.bucket_name
)
})?;
if from_public.bytes() != test_file.1 {
bail!("contents of public bucket do not match uploaded file");
}

// clean up test file after checks
bucket.delete_object(test_file.0).await?;

Ok(())
}

Expand Down

0 comments on commit 6cfd4bd

Please sign in to comment.