mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-18 01:17:50 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ca2a190b2f |
@@ -566,24 +566,68 @@ async fn test_website_redirect_full_bucket() {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let req = Request::builder()
|
{
|
||||||
.method("GET")
|
let req = Request::builder()
|
||||||
.uri(format!("http://127.0.0.1:{}/my-path", ctx.garage.web_port))
|
.method("GET")
|
||||||
.header("Host", format!("{}.web.garage", BCKT_NAME))
|
.uri(format!("http://127.0.0.1:{}/my-path", ctx.garage.web_port))
|
||||||
.body(Body::new(Bytes::new()))
|
.header("Host", format!("{}.web.garage", BCKT_NAME))
|
||||||
.unwrap();
|
.body(Body::new(Bytes::new()))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let client = Client::builder(TokioExecutor::new()).build_http();
|
let client = Client::builder(TokioExecutor::new()).build_http();
|
||||||
let resp = client.request(req).await.unwrap();
|
let resp = client.request(req).await.unwrap();
|
||||||
assert_eq!(resp.status(), StatusCode::FOUND);
|
assert_eq!(resp.status(), StatusCode::FOUND);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resp.headers()
|
resp.headers()
|
||||||
.get(hyper::header::LOCATION)
|
.get(hyper::header::LOCATION)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
"https://other.tld/my-path"
|
"https://other.tld/my-path"
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let req = Request::builder()
|
||||||
|
.method("GET")
|
||||||
|
.uri(format!("http://127.0.0.1:{}/my-path/", ctx.garage.web_port))
|
||||||
|
.header("Host", format!("{}.web.garage", BCKT_NAME))
|
||||||
|
.body(Body::new(Bytes::new()))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let client = Client::builder(TokioExecutor::new()).build_http();
|
||||||
|
let resp = client.request(req).await.unwrap();
|
||||||
|
assert_eq!(resp.status(), StatusCode::FOUND);
|
||||||
|
assert_eq!(
|
||||||
|
resp.headers()
|
||||||
|
.get(hyper::header::LOCATION)
|
||||||
|
.unwrap()
|
||||||
|
.to_str()
|
||||||
|
.unwrap(),
|
||||||
|
"https://other.tld/my-path/"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let req = Request::builder()
|
||||||
|
.method("GET")
|
||||||
|
.uri(format!("http://127.0.0.1:{}/", ctx.garage.web_port))
|
||||||
|
.header("Host", format!("{}.web.garage", BCKT_NAME))
|
||||||
|
.body(Body::new(Bytes::new()))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let client = Client::builder(TokioExecutor::new()).build_http();
|
||||||
|
let resp = client.request(req).await.unwrap();
|
||||||
|
assert_eq!(resp.status(), StatusCode::FOUND);
|
||||||
|
assert_eq!(
|
||||||
|
resp.headers()
|
||||||
|
.get(hyper::header::LOCATION)
|
||||||
|
.unwrap()
|
||||||
|
.to_str()
|
||||||
|
.unwrap(),
|
||||||
|
"https://other.tld/"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
|||||||
@@ -559,7 +559,7 @@ fn path_to_keys(
|
|||||||
};
|
};
|
||||||
if let Some(condition) = &routing_rule.condition {
|
if let Some(condition) = &routing_rule.condition {
|
||||||
let suffix = if let Some(prefix) = &condition.prefix {
|
let suffix = if let Some(prefix) = &condition.prefix {
|
||||||
let Some(suffix) = key.strip_prefix(prefix) else {
|
let Some(suffix) = base_key.strip_prefix(prefix) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
Some(suffix)
|
Some(suffix)
|
||||||
|
|||||||
Reference in New Issue
Block a user