mirror of
https://github.com/rustfs/rustfs.git
synced 2026-11-21 07:26:37 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 357e78c523 |
@@ -1021,6 +1021,33 @@ impl<T> S3Router<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl<T: OwnedOperation> S3Router<T> {
|
||||
/// Dispatches one legacy admin request. Callers keep their assertions and do not name s3s.
|
||||
pub(crate) async fn call_legacy(
|
||||
&self,
|
||||
method: Method,
|
||||
uri: &str,
|
||||
extensions: http::Extensions,
|
||||
) -> s3s::S3Result<S3Response<Body>> {
|
||||
S3Route::call(
|
||||
self,
|
||||
S3Request {
|
||||
input: Body::empty(),
|
||||
method,
|
||||
uri: uri.parse().expect("test URI"),
|
||||
headers: HeaderMap::new(),
|
||||
extensions,
|
||||
credentials: None,
|
||||
region: None,
|
||||
service: None,
|
||||
trailing_headers: None,
|
||||
},
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Default for S3Router<T> {
|
||||
fn default() -> Self {
|
||||
Self::new(false)
|
||||
|
||||
@@ -142,14 +142,12 @@ mod tests {
|
||||
};
|
||||
use crate::admin::operation::{AdminRequest, AdminResponse, Operation};
|
||||
use crate::admin::router::S3Router;
|
||||
use crate::app::RequestEnvelope;
|
||||
use crate::app::{RequestEnvelope, RequestHead};
|
||||
use hyper::{Method, StatusCode};
|
||||
use matchit::Params;
|
||||
use rustfs_iam::{store::object::ObjectStore, sys::IamSys};
|
||||
use rustfs_kms::KmsServiceManager;
|
||||
use rustfs_s3_types::{S3ErrorCode, s3_error};
|
||||
use s3s::route::S3Route;
|
||||
use s3s::{Body, S3Request};
|
||||
use std::sync::Arc;
|
||||
|
||||
struct UnreadyIam;
|
||||
@@ -192,22 +190,18 @@ mod tests {
|
||||
Arc::new(AppContext::new(context.object_store(), Arc::new(UnreadyIam), Arc::new(TestKms)))
|
||||
}
|
||||
|
||||
fn request(extensions: http::Extensions) -> S3Request<Body> {
|
||||
S3Request {
|
||||
input: Body::empty(),
|
||||
method: Method::GET,
|
||||
uri: "/context-probe".parse().expect("test URI"),
|
||||
headers: http::HeaderMap::new(),
|
||||
extensions,
|
||||
credentials: None,
|
||||
region: None,
|
||||
service: None,
|
||||
trailing_headers: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn envelope(extensions: http::Extensions) -> RequestEnvelope {
|
||||
RequestEnvelope::from_s3s(&request(extensions))
|
||||
RequestEnvelope::from_parts(
|
||||
RequestHead {
|
||||
method: Method::GET,
|
||||
uri: "/context-probe".parse().expect("test URI"),
|
||||
headers: http::HeaderMap::new(),
|
||||
credentials: None,
|
||||
region: None,
|
||||
service: None,
|
||||
},
|
||||
extensions,
|
||||
)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -330,14 +324,14 @@ mod tests {
|
||||
.expect("register test route");
|
||||
|
||||
let err = router
|
||||
.call(request(http::Extensions::new()))
|
||||
.call_legacy(Method::GET, "/context-probe", http::Extensions::new())
|
||||
.await
|
||||
.expect_err("empty slot must fail closed");
|
||||
assert_eq!(err.code(), &S3ErrorCode::ServiceUnavailable.into());
|
||||
|
||||
assert!(slot.install(distinct_context(&ambient)));
|
||||
let response = router
|
||||
.call(request(http::Extensions::new()))
|
||||
.call_legacy(Method::GET, "/context-probe", http::Extensions::new())
|
||||
.await
|
||||
.expect("installed slot must serve request");
|
||||
assert_eq!(response.status, Some(StatusCode::NO_CONTENT));
|
||||
|
||||
Reference in New Issue
Block a user