mirror of
https://github.com/rustfs/rustfs.git
synced 2026-11-16 04:52:36 +00:00
feat(gateway): serve core bucket configuration reads
Serve bucket acceleration, request payment, website, and logging configuration through shared persisted read paths. Keep each operation's existing authorization and legacy response projection. Append distinct metric labels without shifting existing indexes. The scoped RustFS, S3 operation, and metrics suite passed 283 tests on993464fbb. The integrated configuration and refusal suites passed 21 tests on292974baf. Both feature modes passed all-targets Clippy. Standalone checks compared 23 successful and 17 refused legacy requests againstcfdd4b268and exercised the gateway answers on the same data. Action, resource, anonymous, projection, default, missing-bucket, counter, and audit faults failed their original assertions. Metric registry tests also detected duplicate labels, changed index order, and an added event. Verification is scoped to these local suites and wire probes.
This commit is contained in:
@@ -83,6 +83,9 @@ pub enum S3Operation {
|
||||
SelectObjectContent,
|
||||
UploadPart,
|
||||
UploadPartCopy,
|
||||
GetBucketAccelerateConfiguration,
|
||||
GetBucketRequestPayment,
|
||||
GetBucketWebsite,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
@@ -126,7 +129,7 @@ impl EventMapping {
|
||||
}
|
||||
|
||||
impl S3Operation {
|
||||
pub const ALL: [Self; 66] = [
|
||||
pub const ALL: [Self; 69] = [
|
||||
Self::AbortMultipartUpload,
|
||||
Self::CompleteMultipartUpload,
|
||||
Self::CopyObject,
|
||||
@@ -193,6 +196,9 @@ impl S3Operation {
|
||||
Self::SelectObjectContent,
|
||||
Self::UploadPart,
|
||||
Self::UploadPartCopy,
|
||||
Self::GetBucketAccelerateConfiguration,
|
||||
Self::GetBucketRequestPayment,
|
||||
Self::GetBucketWebsite,
|
||||
];
|
||||
|
||||
#[inline]
|
||||
@@ -218,6 +224,7 @@ impl S3Operation {
|
||||
Self::DeleteObjectTagging => "s3:DeleteObjectTagging",
|
||||
Self::DeleteObjects => "s3:DeleteObjects",
|
||||
Self::DeletePublicAccessBlock => "s3:DeletePublicAccessBlock",
|
||||
Self::GetBucketAccelerateConfiguration => "s3:GetBucketAccelerateConfiguration",
|
||||
Self::GetBucketAcl => "s3:GetBucketAcl",
|
||||
Self::GetBucketCors => "s3:GetBucketCors",
|
||||
Self::GetBucketEncryption => "s3:GetBucketEncryption",
|
||||
@@ -228,8 +235,10 @@ impl S3Operation {
|
||||
Self::GetBucketPolicy => "s3:GetBucketPolicy",
|
||||
Self::GetBucketPolicyStatus => "s3:GetBucketPolicyStatus",
|
||||
Self::GetBucketReplication => "s3:GetBucketReplication",
|
||||
Self::GetBucketRequestPayment => "s3:GetBucketRequestPayment",
|
||||
Self::GetBucketTagging => "s3:GetBucketTagging",
|
||||
Self::GetBucketVersioning => "s3:GetBucketVersioning",
|
||||
Self::GetBucketWebsite => "s3:GetBucketWebsite",
|
||||
Self::GetObject => "s3:GetObject",
|
||||
Self::GetObjectAcl => "s3:GetObjectAcl",
|
||||
Self::GetObjectAttributes => "s3:GetObjectAttributes",
|
||||
@@ -302,6 +311,7 @@ impl S3Operation {
|
||||
| Self::DeleteBucketReplication
|
||||
| Self::DeleteBucketTagging
|
||||
| Self::DeletePublicAccessBlock
|
||||
| Self::GetBucketAccelerateConfiguration
|
||||
| Self::GetBucketAcl
|
||||
| Self::GetBucketCors
|
||||
| Self::GetBucketEncryption
|
||||
@@ -312,8 +322,10 @@ impl S3Operation {
|
||||
| Self::GetBucketPolicy
|
||||
| Self::GetBucketPolicyStatus
|
||||
| Self::GetBucketReplication
|
||||
| Self::GetBucketRequestPayment
|
||||
| Self::GetBucketTagging
|
||||
| Self::GetBucketVersioning
|
||||
| Self::GetBucketWebsite
|
||||
| Self::GetObjectAcl
|
||||
| Self::GetObjectLockConfiguration
|
||||
| Self::GetObjectTagging
|
||||
@@ -516,10 +528,23 @@ mod tests {
|
||||
assert_eq!(mask & EventName::ObjectRemovedDelete.mask(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn metric_indexes_and_labels_identify_each_operation() {
|
||||
let mut labels = std::collections::HashSet::new();
|
||||
for (index, op) in S3Operation::ALL.into_iter().enumerate() {
|
||||
assert_eq!(op.metric_index(), index, "metric index for {op:?}");
|
||||
assert!(labels.insert(op.as_str()), "repeated metric label for {op:?}");
|
||||
}
|
||||
assert_eq!(S3Operation::UploadPartCopy.metric_index(), 65);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_operations_without_event_mapping_remain_unmapped() {
|
||||
let unmapped = [
|
||||
S3Operation::GetBucketAccelerateConfiguration,
|
||||
S3Operation::GetBucketAcl,
|
||||
S3Operation::GetBucketRequestPayment,
|
||||
S3Operation::GetBucketWebsite,
|
||||
S3Operation::ListObjectsV2,
|
||||
S3Operation::PutBucketNotificationConfiguration,
|
||||
S3Operation::UploadPart,
|
||||
|
||||
@@ -12,4 +12,22 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Bucket accelerate configuration use-case operations (reserved for the next batch).
|
||||
//! Bucket accelerate configuration reads shared by the S3 edges.
|
||||
|
||||
use super::{ApiError, DefaultBucketUsecase, StorageError, metadata_sys};
|
||||
use rustfs_gateway_types::persistence::PersistedAccelerateConfiguration;
|
||||
use rustfs_s3_types::S3Result;
|
||||
|
||||
impl DefaultBucketUsecase {
|
||||
pub(crate) async fn execute_get_bucket_accelerate_configuration(
|
||||
&self,
|
||||
bucket: &str,
|
||||
) -> S3Result<PersistedAccelerateConfiguration> {
|
||||
self.ensure_config_read_bucket(bucket).await?;
|
||||
match metadata_sys::get_accelerate_config(bucket).await {
|
||||
Ok((config, _)) => Ok(config),
|
||||
Err(StorageError::ConfigNotFound) => Ok(PersistedAccelerateConfiguration::default()),
|
||||
Err(err) => Err(ApiError::from(err).into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,18 @@ pub(crate) fn requested_location_constraint(input: &gateway_dto::CreateBucketInp
|
||||
}
|
||||
|
||||
impl DefaultBucketUsecase {
|
||||
/// Checks that the bucket exists before a stored configuration read.
|
||||
pub(super) async fn ensure_config_read_bucket(&self, bucket: &str) -> rustfs_s3_types::S3Result<()> {
|
||||
let Some(store) = self.object_store() else {
|
||||
return Err(rustfs_s3_types::s3_error!(InternalError, "Not init"));
|
||||
};
|
||||
store
|
||||
.get_bucket_info(bucket, &BucketOptions::default())
|
||||
.await
|
||||
.map_err(ApiError::from)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn create_bucket_exists_result(&self) -> rustfs_s3_types::S3Result<gateway_dto::CreateBucketOutput> {
|
||||
let region = self
|
||||
.global_region()
|
||||
|
||||
@@ -12,4 +12,19 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Bucket logging configuration use-case operations (reserved for the next batch).
|
||||
//! Bucket logging configuration reads shared by the S3 edges.
|
||||
|
||||
use super::{ApiError, DefaultBucketUsecase, StorageError, metadata_sys};
|
||||
use rustfs_gateway_types::persistence::PersistedBucketLoggingStatus;
|
||||
use rustfs_s3_types::S3Result;
|
||||
|
||||
impl DefaultBucketUsecase {
|
||||
pub(crate) async fn execute_get_bucket_logging(&self, bucket: &str) -> S3Result<PersistedBucketLoggingStatus> {
|
||||
self.ensure_config_read_bucket(bucket).await?;
|
||||
match metadata_sys::get_logging_config(bucket).await {
|
||||
Ok((config, _)) => Ok(config),
|
||||
Err(StorageError::ConfigNotFound) => Ok(PersistedBucketLoggingStatus::default()),
|
||||
Err(err) => Err(ApiError::from(err).into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,4 +12,24 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Bucket request-payment configuration use-case operations (reserved for the next batch).
|
||||
//! Bucket request-payment configuration reads shared by the S3 edges.
|
||||
|
||||
use super::{ApiError, DefaultBucketUsecase, StorageError, metadata_sys};
|
||||
use rustfs_gateway_types::persistence::PersistedRequestPaymentConfiguration;
|
||||
use rustfs_s3_types::S3Result;
|
||||
|
||||
impl DefaultBucketUsecase {
|
||||
pub(crate) async fn execute_get_bucket_request_payment(
|
||||
&self,
|
||||
bucket: &str,
|
||||
) -> S3Result<PersistedRequestPaymentConfiguration> {
|
||||
self.ensure_config_read_bucket(bucket).await?;
|
||||
match metadata_sys::get_request_payment_config(bucket).await {
|
||||
Ok((config, _)) => Ok(config),
|
||||
Err(StorageError::ConfigNotFound) => Ok(PersistedRequestPaymentConfiguration {
|
||||
payer: "BucketOwner".to_owned(),
|
||||
}),
|
||||
Err(err) => Err(ApiError::from(err).into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,4 +12,22 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Bucket website configuration use-case operations (reserved for the next batch).
|
||||
//! Bucket website configuration reads shared by the S3 edges.
|
||||
|
||||
use super::{ApiError, DefaultBucketUsecase, StorageError, metadata_sys};
|
||||
use rustfs_gateway_types::persistence::PersistedWebsiteConfiguration;
|
||||
use rustfs_s3_types::S3Result;
|
||||
|
||||
impl DefaultBucketUsecase {
|
||||
pub(crate) async fn execute_get_bucket_website(&self, bucket: &str) -> S3Result<PersistedWebsiteConfiguration> {
|
||||
self.ensure_config_read_bucket(bucket).await?;
|
||||
match metadata_sys::get_website_config(bucket).await {
|
||||
Ok((config, _)) => Ok(config),
|
||||
Err(StorageError::ConfigNotFound) => Err(rustfs_s3_types::s3_error!(
|
||||
NoSuchWebsiteConfiguration,
|
||||
"The specified bucket does not have a website configuration."
|
||||
)),
|
||||
Err(err) => Err(ApiError::from(err).into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -963,6 +963,9 @@ pub(crate) mod bucket {
|
||||
}
|
||||
|
||||
pub(crate) mod metadata_sys {
|
||||
pub(crate) use crate::storage::storage_api::ecstore_bucket::metadata_sys::{
|
||||
get_accelerate_config, get_logging_config, get_request_payment_config, get_website_config,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
use rustfs_gateway_types::cors_tagging::{PersistedCorsConfiguration, PersistedTagging};
|
||||
|
||||
@@ -16,12 +16,13 @@
|
||||
//! head and location, website, accelerate, logging and request payment; and ListBuckets.
|
||||
|
||||
use super::{OpRow, Served, row};
|
||||
use crate::app::RequestEnvelope;
|
||||
use crate::app::bucket_usecase::{DefaultBucketUsecase, requested_location_constraint};
|
||||
use crate::app::{RequestEnvelope, dto_values};
|
||||
use crate::runtime_sources::AppContext;
|
||||
use crate::storage_api::server::http::access::access_owned::bucket_core::{authorize_create_bucket, authorize_delete_bucket};
|
||||
use crate::storage_api::server::http::access::authorize_bucket_request;
|
||||
use rustfs_gateway::{Req, Resp, dto};
|
||||
use rustfs_gateway_types::persistence::{parse_bucket_logging_dto, parse_website_dto};
|
||||
use rustfs_policy::policy::action::{Action, S3Action};
|
||||
use rustfs_s3_ops::S3Operation;
|
||||
use rustfs_s3_types::S3Result;
|
||||
@@ -33,6 +34,10 @@ pub(super) const ROWS: &[OpRow] = &[
|
||||
row::<dto::CreateBucket>(),
|
||||
row::<dto::DeleteBucket>(),
|
||||
row::<dto::GetBucketLocation>(),
|
||||
row::<dto::GetBucketAccelerateConfiguration>(),
|
||||
row::<dto::GetBucketRequestPayment>(),
|
||||
row::<dto::GetBucketWebsite>(),
|
||||
row::<dto::GetBucketLogging>(),
|
||||
];
|
||||
|
||||
impl Served for dto::ListBuckets {
|
||||
@@ -115,3 +120,81 @@ impl Served for dto::GetBucketLocation {
|
||||
Ok(Resp::new(output))
|
||||
}
|
||||
}
|
||||
|
||||
impl Served for dto::GetBucketAccelerateConfiguration {
|
||||
const METRIC: S3Operation = S3Operation::GetBucketAccelerateConfiguration;
|
||||
|
||||
async fn authorize(envelope: &mut RequestEnvelope, request: &Req<Self>) -> S3Result<()> {
|
||||
let action = Action::S3Action(S3Action::GetBucketPolicyAction);
|
||||
Ok(authorize_bucket_request(envelope, request.input().bucket.as_str(), action).await?)
|
||||
}
|
||||
|
||||
async fn execute(context: Option<Arc<AppContext>>, _envelope: RequestEnvelope, request: Req<Self>) -> S3Result<Resp<Self>> {
|
||||
let config = DefaultBucketUsecase::with_context(context)
|
||||
.execute_get_bucket_accelerate_configuration(request.input().bucket.as_str())
|
||||
.await?;
|
||||
Ok(Resp::new(dto::GetBucketAccelerateConfigurationOutput {
|
||||
status: config.status.map(dto::Status::custom),
|
||||
..Default::default()
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
impl Served for dto::GetBucketRequestPayment {
|
||||
const METRIC: S3Operation = S3Operation::GetBucketRequestPayment;
|
||||
|
||||
async fn authorize(envelope: &mut RequestEnvelope, request: &Req<Self>) -> S3Result<()> {
|
||||
let action = Action::S3Action(S3Action::GetBucketPolicyAction);
|
||||
Ok(authorize_bucket_request(envelope, request.input().bucket.as_str(), action).await?)
|
||||
}
|
||||
|
||||
async fn execute(context: Option<Arc<AppContext>>, _envelope: RequestEnvelope, request: Req<Self>) -> S3Result<Resp<Self>> {
|
||||
let config = DefaultBucketUsecase::with_context(context)
|
||||
.execute_get_bucket_request_payment(request.input().bucket.as_str())
|
||||
.await?;
|
||||
Ok(Resp::new(dto::GetBucketRequestPaymentOutput {
|
||||
payer: Some(dto::Payer::custom(config.payer)),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
impl Served for dto::GetBucketWebsite {
|
||||
const METRIC: S3Operation = S3Operation::GetBucketWebsite;
|
||||
|
||||
async fn authorize(envelope: &mut RequestEnvelope, request: &Req<Self>) -> S3Result<()> {
|
||||
let action = Action::S3Action(S3Action::GetBucketPolicyAction);
|
||||
Ok(authorize_bucket_request(envelope, request.input().bucket.as_str(), action).await?)
|
||||
}
|
||||
|
||||
async fn execute(context: Option<Arc<AppContext>>, _envelope: RequestEnvelope, request: Req<Self>) -> S3Result<Resp<Self>> {
|
||||
let config = DefaultBucketUsecase::with_context(context)
|
||||
.execute_get_bucket_website(request.input().bucket.as_str())
|
||||
.await?;
|
||||
let config = dto_values::stored_config(&config, parse_website_dto)?;
|
||||
Ok(Resp::new(dto::GetBucketWebsiteOutput {
|
||||
error_document: config.error_document,
|
||||
index_document: config.index_document,
|
||||
redirect_all_requests_to: config.redirect_all_requests_to,
|
||||
routing_rules: config.routing_rules,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
impl Served for dto::GetBucketLogging {
|
||||
const METRIC: S3Operation = S3Operation::GetBucketLogging;
|
||||
|
||||
async fn authorize(envelope: &mut RequestEnvelope, request: &Req<Self>) -> S3Result<()> {
|
||||
let action = Action::S3Action(S3Action::GetBucketLoggingAction);
|
||||
Ok(authorize_bucket_request(envelope, request.input().bucket.as_str(), action).await?)
|
||||
}
|
||||
|
||||
async fn execute(context: Option<Arc<AppContext>>, _envelope: RequestEnvelope, request: Req<Self>) -> S3Result<Resp<Self>> {
|
||||
let config = DefaultBucketUsecase::with_context(context)
|
||||
.execute_get_bucket_logging(request.input().bucket.as_str())
|
||||
.await?;
|
||||
let config = dto_values::stored_config(&config, parse_bucket_logging_dto)?;
|
||||
Ok(Resp::new(dto::GetBucketLoggingOutput {
|
||||
logging_enabled: config.logging_enabled,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3598,10 +3598,8 @@ impl S3Access for FS {
|
||||
&self,
|
||||
req: &mut S3Request<GetBucketAccelerateConfigurationInput>,
|
||||
) -> S3Result<()> {
|
||||
let req_info = ext_req_info_mut(&mut req.extensions)?;
|
||||
req_info.bucket = Some(req.input.bucket.clone());
|
||||
|
||||
authorize_request(req, Action::S3Action(S3Action::GetBucketPolicyAction)).await
|
||||
let bucket = req.input.bucket.clone();
|
||||
authorize_bucket_request(req, &bucket, Action::S3Action(S3Action::GetBucketPolicyAction)).await
|
||||
}
|
||||
|
||||
/// Checks whether the GetBucketAcl request has accesses to the resources.
|
||||
@@ -3681,10 +3679,8 @@ impl S3Access for FS {
|
||||
///
|
||||
/// This method returns `Ok(())` by default.
|
||||
async fn get_bucket_logging(&self, req: &mut S3Request<GetBucketLoggingInput>) -> S3Result<()> {
|
||||
let req_info = ext_req_info_mut(&mut req.extensions)?;
|
||||
req_info.bucket = Some(req.input.bucket.clone());
|
||||
|
||||
authorize_request(req, Action::S3Action(S3Action::GetBucketLoggingAction)).await
|
||||
let bucket = req.input.bucket.clone();
|
||||
authorize_bucket_request(req, &bucket, Action::S3Action(S3Action::GetBucketLoggingAction)).await
|
||||
}
|
||||
|
||||
/// Checks whether the GetBucketMetricsConfiguration request has accesses to the resources.
|
||||
@@ -3740,10 +3736,8 @@ impl S3Access for FS {
|
||||
///
|
||||
/// This method returns `Ok(())` by default.
|
||||
async fn get_bucket_request_payment(&self, req: &mut S3Request<GetBucketRequestPaymentInput>) -> S3Result<()> {
|
||||
let req_info = ext_req_info_mut(&mut req.extensions)?;
|
||||
req_info.bucket = Some(req.input.bucket.clone());
|
||||
|
||||
authorize_request(req, Action::S3Action(S3Action::GetBucketPolicyAction)).await
|
||||
let bucket = req.input.bucket.clone();
|
||||
authorize_bucket_request(req, &bucket, Action::S3Action(S3Action::GetBucketPolicyAction)).await
|
||||
}
|
||||
|
||||
/// Checks whether the GetBucketTagging request has accesses to the resources.
|
||||
@@ -3766,10 +3760,8 @@ impl S3Access for FS {
|
||||
///
|
||||
/// This method returns `Ok(())` by default.
|
||||
async fn get_bucket_website(&self, req: &mut S3Request<GetBucketWebsiteInput>) -> S3Result<()> {
|
||||
let req_info = ext_req_info_mut(&mut req.extensions)?;
|
||||
req_info.bucket = Some(req.input.bucket.clone());
|
||||
|
||||
authorize_request(req, Action::S3Action(S3Action::GetBucketPolicyAction)).await
|
||||
let bucket = req.input.bucket.clone();
|
||||
authorize_bucket_request(req, &bucket, Action::S3Action(S3Action::GetBucketPolicyAction)).await
|
||||
}
|
||||
|
||||
/// Checks whether the GetObject request has accesses to the resources.
|
||||
|
||||
@@ -28,9 +28,8 @@ use crate::storage::storage_api::ecfs_consumer::contract::bucket::{BucketOperati
|
||||
use crate::storage::storage_api::ecstore_bucket::utils::serialize as serialize_bucket_config;
|
||||
use crate::storage::validate_website_configuration;
|
||||
use crate::storage::{
|
||||
BUCKET_ACCELERATE_CONFIG, BUCKET_LOGGING_CONFIG, BUCKET_REQUEST_PAYMENT_CONFIG, BUCKET_WEBSITE_CONFIG, StorageError,
|
||||
delete_bucket_metadata_config_if_incarnation, get_bucket_accelerate_config, get_bucket_logging_config,
|
||||
get_bucket_request_payment_config, get_bucket_website_config, update_bucket_metadata_config_if_incarnation,
|
||||
BUCKET_ACCELERATE_CONFIG, BUCKET_LOGGING_CONFIG, BUCKET_REQUEST_PAYMENT_CONFIG, BUCKET_WEBSITE_CONFIG,
|
||||
delete_bucket_metadata_config_if_incarnation, update_bucket_metadata_config_if_incarnation,
|
||||
};
|
||||
use crate::storage::{persisted_from_s3s, persisted_to_s3s};
|
||||
use rustfs_gateway_types::compat::s3s_5761ddfe::generated::ops::{create_bucket, delete_bucket, head_bucket};
|
||||
@@ -138,23 +137,13 @@ impl FS {
|
||||
&self,
|
||||
req: S3Request<GetBucketAccelerateConfigurationInput>,
|
||||
) -> S3Result<S3Response<GetBucketAccelerateConfigurationOutput>> {
|
||||
let Some(store) = self.server_ctx.object_store() else {
|
||||
return Err(s3_error!(InternalError, "Not init"));
|
||||
};
|
||||
|
||||
store
|
||||
.get_bucket_info(&req.input.bucket, &BucketOptions::default())
|
||||
.await
|
||||
.map_err(crate::error::ApiError::from)?;
|
||||
|
||||
match get_bucket_accelerate_config(&req.input.bucket).await {
|
||||
Ok((accelerate, _)) => Ok(S3Response::new(GetBucketAccelerateConfigurationOutput {
|
||||
status: accelerate.status.map(BucketAccelerateStatus::from),
|
||||
..Default::default()
|
||||
})),
|
||||
Err(StorageError::ConfigNotFound) => Ok(S3Response::new(GetBucketAccelerateConfigurationOutput::default())),
|
||||
Err(err) => Err(crate::error::ApiError::from(err).into()),
|
||||
}
|
||||
let config = s3_api::bucket_usecase_for(self)
|
||||
.execute_get_bucket_accelerate_configuration(&req.input.bucket)
|
||||
.await?;
|
||||
Ok(S3Response::new(GetBucketAccelerateConfigurationOutput {
|
||||
status: config.status.map(BucketAccelerateStatus::from),
|
||||
..Default::default()
|
||||
}))
|
||||
}
|
||||
|
||||
/// Get bucket location
|
||||
@@ -178,52 +167,28 @@ impl FS {
|
||||
&self,
|
||||
req: S3Request<GetBucketRequestPaymentInput>,
|
||||
) -> S3Result<S3Response<GetBucketRequestPaymentOutput>> {
|
||||
let Some(store) = self.server_ctx.object_store() else {
|
||||
return Err(s3_error!(InternalError, "Not init"));
|
||||
};
|
||||
|
||||
store
|
||||
.get_bucket_info(&req.input.bucket, &BucketOptions::default())
|
||||
.await
|
||||
.map_err(crate::error::ApiError::from)?;
|
||||
|
||||
match get_bucket_request_payment_config(&req.input.bucket).await {
|
||||
Ok((payment, _)) => Ok(S3Response::new(GetBucketRequestPaymentOutput {
|
||||
payer: Some(Payer::from(payment.payer)),
|
||||
})),
|
||||
Err(StorageError::ConfigNotFound) => Ok(S3Response::new(GetBucketRequestPaymentOutput {
|
||||
payer: Some(Payer::from_static(Payer::BUCKET_OWNER)),
|
||||
})),
|
||||
Err(err) => Err(crate::error::ApiError::from(err).into()),
|
||||
}
|
||||
let config = s3_api::bucket_usecase_for(self)
|
||||
.execute_get_bucket_request_payment(&req.input.bucket)
|
||||
.await?;
|
||||
Ok(S3Response::new(GetBucketRequestPaymentOutput {
|
||||
payer: Some(Payer::from(config.payer)),
|
||||
}))
|
||||
}
|
||||
|
||||
pub(in crate::storage::ecfs) async fn get_bucket_website_edge(
|
||||
&self,
|
||||
req: S3Request<GetBucketWebsiteInput>,
|
||||
) -> S3Result<S3Response<GetBucketWebsiteOutput>> {
|
||||
let Some(store) = self.server_ctx.object_store() else {
|
||||
return Err(s3_error!(InternalError, "Not init"));
|
||||
};
|
||||
|
||||
store
|
||||
.get_bucket_info(&req.input.bucket, &BucketOptions::default())
|
||||
.await
|
||||
.map_err(crate::error::ApiError::from)?;
|
||||
|
||||
match get_bucket_website_config(&req.input.bucket).await {
|
||||
Ok((website, _)) => {
|
||||
let website: WebsiteConfiguration = persisted_to_s3s(&website)?;
|
||||
Ok(S3Response::new(GetBucketWebsiteOutput {
|
||||
error_document: website.error_document,
|
||||
index_document: website.index_document,
|
||||
redirect_all_requests_to: website.redirect_all_requests_to,
|
||||
routing_rules: website.routing_rules,
|
||||
}))
|
||||
}
|
||||
Err(StorageError::ConfigNotFound) => Err(s3_error!(NoSuchWebsiteConfiguration)),
|
||||
Err(err) => Err(crate::error::ApiError::from(err).into()),
|
||||
}
|
||||
let config = s3_api::bucket_usecase_for(self)
|
||||
.execute_get_bucket_website(&req.input.bucket)
|
||||
.await?;
|
||||
let config: WebsiteConfiguration = persisted_to_s3s(&config)?;
|
||||
Ok(S3Response::new(GetBucketWebsiteOutput {
|
||||
error_document: config.error_document,
|
||||
index_document: config.index_document,
|
||||
redirect_all_requests_to: config.redirect_all_requests_to,
|
||||
routing_rules: config.routing_rules,
|
||||
}))
|
||||
}
|
||||
|
||||
#[instrument(name = "head_bucket", level = "debug", skip(self, req))]
|
||||
@@ -287,24 +252,13 @@ impl FS {
|
||||
req: S3Request<GetBucketLoggingInput>,
|
||||
) -> S3Result<S3Response<GetBucketLoggingOutput>> {
|
||||
record_s3_op(S3Operation::GetBucketLogging);
|
||||
let Some(store) = self.server_ctx.object_store() else {
|
||||
return Err(s3_error!(InternalError, "Not init"));
|
||||
};
|
||||
store
|
||||
.get_bucket_info(&req.input.bucket, &BucketOptions::default())
|
||||
.await
|
||||
.map_err(crate::error::ApiError::from)?;
|
||||
|
||||
match get_bucket_logging_config(&req.input.bucket).await {
|
||||
Ok((logging, _)) => {
|
||||
let logging: BucketLoggingStatus = persisted_to_s3s(&logging)?;
|
||||
Ok(S3Response::new(GetBucketLoggingOutput {
|
||||
logging_enabled: logging.logging_enabled,
|
||||
}))
|
||||
}
|
||||
Err(StorageError::ConfigNotFound) => Ok(S3Response::new(GetBucketLoggingOutput::default())),
|
||||
Err(err) => Err(crate::error::ApiError::from(err).into()),
|
||||
}
|
||||
let config = s3_api::bucket_usecase_for(self)
|
||||
.execute_get_bucket_logging(&req.input.bucket)
|
||||
.await?;
|
||||
let config: BucketLoggingStatus = persisted_to_s3s(&config)?;
|
||||
Ok(S3Response::new(GetBucketLoggingOutput {
|
||||
logging_enabled: config.logging_enabled,
|
||||
}))
|
||||
}
|
||||
|
||||
pub(in crate::storage::ecfs) async fn put_bucket_logging_edge(
|
||||
|
||||
@@ -66,11 +66,10 @@ pub(crate) use storage_api::{
|
||||
ecstore_admin, ecstore_bucket, ecstore_capacity, ecstore_client, ecstore_cluster, ecstore_compression, ecstore_config,
|
||||
ecstore_data_usage, ecstore_disk, ecstore_error, ecstore_event, ecstore_layout, ecstore_metrics, ecstore_notification,
|
||||
ecstore_rebalance, ecstore_rio, ecstore_rpc, ecstore_set_disk, ecstore_storage, ecstore_tier, encode_tags,
|
||||
find_local_disk_by_ref, get_bucket_accelerate_config, get_bucket_cors_config, get_bucket_logging_config, get_bucket_metadata,
|
||||
get_bucket_notification_config, get_bucket_object_lock_config, get_bucket_request_payment_config, get_bucket_sse_config,
|
||||
get_bucket_website_config, get_bucket_website_config_for_store, get_local_server_property, get_lock_acquire_timeout,
|
||||
head_prefix_consumer, helper_consumer, init_background_replication, init_bucket_metadata_sys, init_ecstore_config,
|
||||
init_local_disks_with_instance_ctx, init_lock_clients, is_err_bucket_not_found, is_err_object_not_found,
|
||||
find_local_disk_by_ref, get_bucket_cors_config, get_bucket_metadata, get_bucket_notification_config,
|
||||
get_bucket_object_lock_config, get_bucket_sse_config, get_bucket_website_config_for_store, get_local_server_property,
|
||||
get_lock_acquire_timeout, head_prefix_consumer, helper_consumer, init_background_replication, init_bucket_metadata_sys,
|
||||
init_ecstore_config, init_local_disks_with_instance_ctx, init_lock_clients, is_err_bucket_not_found, is_err_object_not_found,
|
||||
is_err_version_not_found, is_valid_storage_class, options_consumer, prewarm_local_disk_id_map_with_instance_ctx, read_config,
|
||||
record_replication_proxy, rpc_consumer, runtime_sources_consumer, s3_api_consumer, table_catalog_path_hash, to_s3s_etag,
|
||||
topology_snapshot_from_endpoint_pools_with_capabilities, try_migrate_bucket_metadata, try_migrate_iam_config,
|
||||
|
||||
@@ -2084,24 +2084,12 @@ pub(crate) async fn get_bucket_metadata(bucket: &str) -> Result<Arc<BucketMetada
|
||||
ecstore_bucket::metadata_sys::get(bucket).await
|
||||
}
|
||||
|
||||
pub(crate) async fn get_bucket_accelerate_config(
|
||||
bucket: &str,
|
||||
) -> Result<(rustfs_gateway_types::persistence::PersistedAccelerateConfiguration, time::OffsetDateTime)> {
|
||||
ecstore_bucket::metadata_sys::get_accelerate_config(bucket).await
|
||||
}
|
||||
|
||||
pub(crate) async fn get_bucket_cors_config(
|
||||
bucket: &str,
|
||||
) -> Result<(rustfs_gateway_types::cors_tagging::PersistedCorsConfiguration, time::OffsetDateTime)> {
|
||||
ecstore_bucket::metadata_sys::get_cors_config(bucket).await
|
||||
}
|
||||
|
||||
pub(crate) async fn get_bucket_logging_config(
|
||||
bucket: &str,
|
||||
) -> Result<(rustfs_gateway_types::persistence::PersistedBucketLoggingStatus, time::OffsetDateTime)> {
|
||||
ecstore_bucket::metadata_sys::get_logging_config(bucket).await
|
||||
}
|
||||
|
||||
pub(crate) async fn get_bucket_object_lock_config(
|
||||
bucket: &str,
|
||||
) -> Result<(rustfs_gateway_types::persistence::PersistedObjectLockConfiguration, time::OffsetDateTime)> {
|
||||
@@ -2123,15 +2111,6 @@ pub(crate) async fn complete_force_delete_intent(api: Arc<ECStore>, operation_id
|
||||
ecstore_bucket::replication::complete_force_delete_intent(api, operation_id).await
|
||||
}
|
||||
|
||||
pub(crate) async fn get_bucket_request_payment_config(
|
||||
bucket: &str,
|
||||
) -> Result<(
|
||||
rustfs_gateway_types::persistence::PersistedRequestPaymentConfiguration,
|
||||
time::OffsetDateTime,
|
||||
)> {
|
||||
ecstore_bucket::metadata_sys::get_request_payment_config(bucket).await
|
||||
}
|
||||
|
||||
pub(crate) async fn get_bucket_sse_config(
|
||||
bucket: &str,
|
||||
) -> Result<(
|
||||
@@ -2141,12 +2120,6 @@ pub(crate) async fn get_bucket_sse_config(
|
||||
ecstore_bucket::metadata_sys::get_sse_config(bucket).await
|
||||
}
|
||||
|
||||
pub(crate) async fn get_bucket_website_config(
|
||||
bucket: &str,
|
||||
) -> Result<(rustfs_gateway_types::persistence::PersistedWebsiteConfiguration, time::OffsetDateTime)> {
|
||||
ecstore_bucket::metadata_sys::get_website_config(bucket).await
|
||||
}
|
||||
|
||||
pub(crate) async fn get_bucket_website_config_for_store(
|
||||
store: &ECStore,
|
||||
bucket: &str,
|
||||
|
||||
@@ -14,11 +14,18 @@
|
||||
|
||||
//! Refusal-matrix rows of migration batch A4 and of ListBuckets (rustfs/backlog#2765).
|
||||
|
||||
use super::{GATEWAY, LEGACY, MatrixRow, Outcome, outcome, s3_client, with_stack};
|
||||
use super::{
|
||||
GATEWAY, LEGACY, MatrixRow, Outcome, USER_SECRET_KEY, anonymous_client, create_bucket_in_the_store,
|
||||
create_user_allowed_on_one_bucket, outcome, refusal, s3_client, with_stack,
|
||||
};
|
||||
use aws_sdk_s3::Client;
|
||||
use aws_sdk_s3::types::{BucketLocationConstraint, CreateBucketConfiguration};
|
||||
use futures::future::BoxFuture;
|
||||
use rustfs::embedded::RustFSServer;
|
||||
use rustfs_ecstore::api::bucket::{
|
||||
metadata::{BUCKET_ACCELERATE_CONFIG, BUCKET_LOGGING_CONFIG, BUCKET_REQUEST_PAYMENT_CONFIG, BUCKET_WEBSITE_CONFIG},
|
||||
metadata_sys,
|
||||
};
|
||||
use rustfs_s3_ops::S3Operation;
|
||||
|
||||
pub(crate) const MATRIX: &[MatrixRow] = &[
|
||||
@@ -52,6 +59,30 @@ pub(crate) const MATRIX: &[MatrixRow] = &[
|
||||
has_error_body: true,
|
||||
call: get_bucket_location,
|
||||
},
|
||||
MatrixRow {
|
||||
operation: "GetBucketAccelerateConfiguration",
|
||||
metric: S3Operation::GetBucketAccelerateConfiguration,
|
||||
has_error_body: true,
|
||||
call: get_bucket_accelerate_configuration,
|
||||
},
|
||||
MatrixRow {
|
||||
operation: "GetBucketRequestPayment",
|
||||
metric: S3Operation::GetBucketRequestPayment,
|
||||
has_error_body: true,
|
||||
call: get_bucket_request_payment,
|
||||
},
|
||||
MatrixRow {
|
||||
operation: "GetBucketWebsite",
|
||||
metric: S3Operation::GetBucketWebsite,
|
||||
has_error_body: true,
|
||||
call: get_bucket_website,
|
||||
},
|
||||
MatrixRow {
|
||||
operation: "GetBucketLogging",
|
||||
metric: S3Operation::GetBucketLogging,
|
||||
has_error_body: true,
|
||||
call: get_bucket_logging,
|
||||
},
|
||||
];
|
||||
|
||||
fn list_buckets<'a>(client: &'a Client, _bucket: &'a str) -> BoxFuture<'a, Outcome> {
|
||||
@@ -66,6 +97,22 @@ fn get_bucket_location<'a>(client: &'a Client, bucket: &'a str) -> BoxFuture<'a,
|
||||
Box::pin(async move { outcome(client.get_bucket_location().bucket(bucket).send().await) })
|
||||
}
|
||||
|
||||
fn get_bucket_accelerate_configuration<'a>(client: &'a Client, bucket: &'a str) -> BoxFuture<'a, Outcome> {
|
||||
Box::pin(async move { outcome(client.get_bucket_accelerate_configuration().bucket(bucket).send().await) })
|
||||
}
|
||||
|
||||
fn get_bucket_request_payment<'a>(client: &'a Client, bucket: &'a str) -> BoxFuture<'a, Outcome> {
|
||||
Box::pin(async move { outcome(client.get_bucket_request_payment().bucket(bucket).send().await) })
|
||||
}
|
||||
|
||||
fn get_bucket_website<'a>(client: &'a Client, bucket: &'a str) -> BoxFuture<'a, Outcome> {
|
||||
Box::pin(async move { outcome(client.get_bucket_website().bucket(bucket).send().await) })
|
||||
}
|
||||
|
||||
fn get_bucket_logging<'a>(client: &'a Client, bucket: &'a str) -> BoxFuture<'a, Outcome> {
|
||||
Box::pin(async move { outcome(client.get_bucket_logging().bucket(bucket).send().await) })
|
||||
}
|
||||
|
||||
/// Re-creating the existing matrix bucket: the default region answers it `200`.
|
||||
fn create_bucket<'a>(client: &'a Client, bucket: &'a str) -> BoxFuture<'a, Outcome> {
|
||||
Box::pin(async move { outcome(client.create_bucket().bucket(bucket).send().await) })
|
||||
@@ -312,3 +359,132 @@ fn the_legacy_stack_orders_force_delete_headers() {
|
||||
fn the_gateway_stack_orders_force_delete_headers() {
|
||||
with_stack(GATEWAY, force_delete_header_order);
|
||||
}
|
||||
|
||||
const WEBSITE_CONFIG: &[u8] = br#"<WebsiteConfiguration><IndexDocument><Suffix>index.html</Suffix></IndexDocument><ErrorDocument><Key>error.html</Key></ErrorDocument><RoutingRules><RoutingRule><Condition><KeyPrefixEquals>old/</KeyPrefixEquals></Condition><Redirect><ReplaceKeyPrefixWith>new/</ReplaceKeyPrefixWith></Redirect></RoutingRule></RoutingRules></WebsiteConfiguration>"#;
|
||||
|
||||
async fn seed_config(bucket: &str, file: &str, xml: &[u8]) {
|
||||
metadata_sys::update(bucket, file, xml.to_vec())
|
||||
.await
|
||||
.expect("seed stored bucket configuration");
|
||||
}
|
||||
|
||||
pub(super) async fn seed_website(bucket: &str) {
|
||||
seed_config(bucket, BUCKET_WEBSITE_CONFIG, WEBSITE_CONFIG).await;
|
||||
}
|
||||
|
||||
async fn core_configuration_reads(server: RustFSServer, gateway: bool) {
|
||||
const CONFIGURED: &str = "core-config-granted";
|
||||
const EMPTY: &str = "core-config-empty";
|
||||
const UNUSUAL: &str = "core-config-unusual";
|
||||
const MISSING: &str = "core-config-absent";
|
||||
for bucket in [CONFIGURED, EMPTY, UNUSUAL] {
|
||||
create_bucket_in_the_store(bucket).await;
|
||||
}
|
||||
seed_website(CONFIGURED).await;
|
||||
seed_config(
|
||||
CONFIGURED,
|
||||
BUCKET_ACCELERATE_CONFIG,
|
||||
b"<AccelerateConfiguration><Status>Enabled</Status></AccelerateConfiguration>",
|
||||
)
|
||||
.await;
|
||||
seed_config(
|
||||
CONFIGURED,
|
||||
BUCKET_REQUEST_PAYMENT_CONFIG,
|
||||
b"<RequestPaymentConfiguration><Payer>Requester</Payer></RequestPaymentConfiguration>",
|
||||
)
|
||||
.await;
|
||||
seed_config(
|
||||
CONFIGURED,
|
||||
BUCKET_LOGGING_CONFIG,
|
||||
b"<BucketLoggingStatus><LoggingEnabled><TargetBucket>core-config-empty</TargetBucket><TargetPrefix>logs/</TargetPrefix></LoggingEnabled></BucketLoggingStatus>",
|
||||
).await;
|
||||
let long_error_key = "a".repeat(1025);
|
||||
let unusual_website = format!(
|
||||
"<WebsiteConfiguration><IndexDocument><Suffix>index.html</Suffix></IndexDocument><ErrorDocument><Key>{long_error_key}</Key></ErrorDocument></WebsiteConfiguration>"
|
||||
);
|
||||
seed_config(UNUSUAL, BUCKET_WEBSITE_CONFIG, unusual_website.as_bytes()).await;
|
||||
|
||||
let endpoint = server.endpoint();
|
||||
let root = s3_client(&endpoint, server.access_key(), server.secret_key());
|
||||
let policy_user = "coreconfigpolicyreader";
|
||||
let logging_user = "coreconfigloggingreader";
|
||||
create_user_allowed_on_one_bucket(policy_user, "s3:GetBucketPolicy", CONFIGURED).await;
|
||||
create_user_allowed_on_one_bucket(logging_user, "s3:GetBucketLogging", CONFIGURED).await;
|
||||
let policy = s3_client(&endpoint, policy_user, USER_SECRET_KEY);
|
||||
let logging = s3_client(&endpoint, logging_user, USER_SECRET_KEY);
|
||||
let anonymous = anonymous_client(&endpoint).await;
|
||||
|
||||
for row in MATRIX.iter().filter(|row| {
|
||||
matches!(
|
||||
row.metric,
|
||||
S3Operation::GetBucketAccelerateConfiguration
|
||||
| S3Operation::GetBucketRequestPayment
|
||||
| S3Operation::GetBucketWebsite
|
||||
| S3Operation::GetBucketLogging
|
||||
)
|
||||
}) {
|
||||
let (allowed, wrong_action) = if row.metric == S3Operation::GetBucketLogging {
|
||||
(&logging, &policy)
|
||||
} else {
|
||||
(&policy, &logging)
|
||||
};
|
||||
let operation = row.operation;
|
||||
let call = row.call;
|
||||
assert_eq!(call(allowed, CONFIGURED).await, Ok(()), "{operation} grant");
|
||||
for (caller, bucket) in [(allowed, EMPTY), (wrong_action, CONFIGURED), (&anonymous, CONFIGURED)] {
|
||||
let error = call(caller, bucket).await.expect_err(operation);
|
||||
assert_eq!((error.code.as_deref(), error.status), (Some("AccessDenied"), Some(403)), "{operation}");
|
||||
}
|
||||
let error = call(&root, MISSING).await.expect_err("missing bucket");
|
||||
assert_eq!((error.code.as_deref(), error.status), (Some("NoSuchBucket"), Some(404)), "{operation}");
|
||||
}
|
||||
|
||||
let accelerate = root
|
||||
.get_bucket_accelerate_configuration()
|
||||
.bucket(CONFIGURED)
|
||||
.send()
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(accelerate.status().map(|status| status.as_str()), Some("Enabled"));
|
||||
let accelerate = root.get_bucket_accelerate_configuration().bucket(EMPTY).send().await.unwrap();
|
||||
assert!(accelerate.status().is_none());
|
||||
|
||||
let payment = root.get_bucket_request_payment().bucket(CONFIGURED).send().await.unwrap();
|
||||
assert_eq!(payment.payer().map(|payer| payer.as_str()), Some("Requester"));
|
||||
let payment = root.get_bucket_request_payment().bucket(EMPTY).send().await.unwrap();
|
||||
assert_eq!(payment.payer().map(|payer| payer.as_str()), Some("BucketOwner"));
|
||||
|
||||
let website = root.get_bucket_website().bucket(CONFIGURED).send().await.unwrap();
|
||||
assert_eq!(website.error_document().unwrap().key(), "error.html");
|
||||
assert_eq!(website.index_document().unwrap().suffix(), "index.html");
|
||||
let [rule] = website.routing_rules() else { panic!("expected one routing rule") };
|
||||
assert_eq!(rule.condition().unwrap().key_prefix_equals(), Some("old/"));
|
||||
assert_eq!(rule.redirect().unwrap().replace_key_prefix_with(), Some("new/"));
|
||||
let missing_website = root.get_bucket_website().bucket(EMPTY).send().await.unwrap_err();
|
||||
assert_eq!(refusal(&missing_website), (Some("NoSuchWebsiteConfiguration".to_owned()), Some(404)));
|
||||
let unusual_website = root.get_bucket_website().bucket(UNUSUAL).send().await;
|
||||
if gateway {
|
||||
assert_eq!(refusal(&unusual_website.unwrap_err()), (Some("InternalError".to_owned()), Some(500)));
|
||||
} else {
|
||||
assert_eq!(unusual_website.unwrap().error_document().unwrap().key(), long_error_key);
|
||||
}
|
||||
|
||||
let output = root.get_bucket_logging().bucket(CONFIGURED).send().await.unwrap();
|
||||
let enabled = output.logging_enabled().expect("stored logging target");
|
||||
assert_eq!(enabled.target_bucket(), EMPTY);
|
||||
assert_eq!(enabled.target_prefix(), "logs/");
|
||||
let output = root.get_bucket_logging().bucket(EMPTY).send().await.unwrap();
|
||||
assert!(output.logging_enabled().is_none());
|
||||
|
||||
server.shutdown().await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_gateway_stack_reads_core_bucket_configurations() {
|
||||
with_stack(GATEWAY, |server| core_configuration_reads(server, true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_legacy_stack_reads_core_bucket_configurations() {
|
||||
with_stack(LEGACY, |server| core_configuration_reads(server, false));
|
||||
}
|
||||
|
||||
@@ -350,11 +350,12 @@ fn operations_that_answer_every_caller_alike_do_so_on_the_legacy_stack() {
|
||||
|
||||
/// Every served operation serves the root caller, counted once under its label, and refuses
|
||||
/// each caller it cannot admit with the code the legacy stack answers, counted once.
|
||||
async fn every_served_operation_serves_root_and_refuses_the_callers_it_cannot_admit(server: RustFSServer) {
|
||||
async fn every_served_operation_serves_root_and_refuses_the_callers_it_cannot_admit(server: RustFSServer, legacy: bool) {
|
||||
create_bucket_in_the_store(MATRIX_BUCKET).await;
|
||||
// Default encryption would change the object writes in the matrix bucket.
|
||||
create_bucket_in_the_store(bucket_configs::ENCRYPTION_MATRIX_BUCKET).await;
|
||||
bucket_configs::store_read_configs(MATRIX_BUCKET, bucket_configs::ENCRYPTION_MATRIX_BUCKET).await;
|
||||
bucket_core::seed_website(MATRIX_BUCKET).await;
|
||||
create_bucket_in_the_store(object_meta::MATRIX_BUCKET).await;
|
||||
create_bucket_in_the_store(object_misc::MATRIX_BUCKET).await;
|
||||
create_bucket_in_the_store(object_read::MATRIX_BUCKET).await;
|
||||
@@ -388,11 +389,23 @@ async fn every_served_operation_serves_root_and_refuses_the_callers_it_cannot_ad
|
||||
let before = s3_request_counts();
|
||||
assert_eq!((row.call)(&root, MATRIX_BUCKET).await, Ok(()), "{} as root", row.operation);
|
||||
let counted = counted_since(&before);
|
||||
// These legacy edge bodies do not record an operation label.
|
||||
let expected_label = if legacy
|
||||
&& matches!(
|
||||
row.metric,
|
||||
S3Operation::GetBucketAccelerateConfiguration
|
||||
| S3Operation::GetBucketRequestPayment
|
||||
| S3Operation::GetBucketWebsite
|
||||
) {
|
||||
"unknown"
|
||||
} else {
|
||||
row.metric.as_str()
|
||||
};
|
||||
assert_eq!(counted.len(), 1, "{}: {counted:?}", row.operation);
|
||||
assert!(
|
||||
counted
|
||||
.iter()
|
||||
.all(|((_, label, outcome), total)| (*label, *outcome, *total) == (row.metric.as_str(), "2xx", 1)),
|
||||
.all(|((_, label, outcome), total)| (*label, *outcome, *total) == (expected_label, "2xx", 1)),
|
||||
"{}: {counted:?}",
|
||||
row.operation
|
||||
);
|
||||
@@ -434,12 +447,16 @@ async fn every_served_operation_serves_root_and_refuses_the_callers_it_cannot_ad
|
||||
|
||||
#[test]
|
||||
fn the_refusal_matrix_holds_on_the_gateway_stack() {
|
||||
bucket_access::with_notification_stack(GATEWAY, every_served_operation_serves_root_and_refuses_the_callers_it_cannot_admit);
|
||||
bucket_access::with_notification_stack(GATEWAY, |server| {
|
||||
every_served_operation_serves_root_and_refuses_the_callers_it_cannot_admit(server, false)
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_refusal_matrix_holds_on_the_legacy_stack() {
|
||||
bucket_access::with_notification_stack(LEGACY, every_served_operation_serves_root_and_refuses_the_callers_it_cannot_admit);
|
||||
bucket_access::with_notification_stack(LEGACY, |server| {
|
||||
every_served_operation_serves_root_and_refuses_the_callers_it_cannot_admit(server, true)
|
||||
});
|
||||
}
|
||||
|
||||
/// Names RustFS creates and the AWS bucket grammar refuses. An IP-shaped name such as `256.1.1.1`
|
||||
|
||||
Reference in New Issue
Block a user