v0.34.16
This commit is contained in:
1 parent
f27fbf6a30
commit
2c03fcf248
18 files changed
+430
-920
No files matched your search
@@ -832,6 +832,50 @@ mod tests {
|
||||
store.close().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn vhosts_section_accepts_large_config_and_persists_it() {
|
||||
let config = config::demo_config("127.0.0.1:9000".parse().unwrap());
|
||||
let (router, store, _dir, secret, csrf) = fixture_with_config(config.clone()).await;
|
||||
let cookie = format!("{}={secret}", auth::COOKIE_NAME);
|
||||
let mut vhosts = config.vhosts;
|
||||
vhosts[0].routes = (0..5)
|
||||
.map(|index| crate::vhost::PathRoute {
|
||||
id: format!("large-{index}"),
|
||||
path_prefix: format!("/large-{index}"),
|
||||
response: Some(crate::vhost::LocationResponse {
|
||||
body: "x".repeat(60_000),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
})
|
||||
.collect();
|
||||
let body = serde_json::to_vec(&json!({"expected_revision": 0, "value": vhosts})).unwrap();
|
||||
assert!(body.len() > 262_144);
|
||||
let response = router
|
||||
.clone()
|
||||
.oneshot(
|
||||
request("/api/config/vhosts")
|
||||
.method("PUT")
|
||||
.header("content-type", "application/json")
|
||||
.header("cookie", &cookie)
|
||||
.header("origin", "http://127.0.0.1:9090")
|
||||
.header("x-rustproxy-request", "1")
|
||||
.header("x-csrf-token", &csrf)
|
||||
.body(Body::from(body))
|
||||
.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
assert_eq!(json_body(response).await["revision"], 1);
|
||||
let saved = store.load().await.unwrap();
|
||||
assert_eq!(saved.revision, 1);
|
||||
assert_eq!(saved.config.vhosts[0].routes.len(), 5);
|
||||
let history = store.configuration_revision(1).await.unwrap().unwrap();
|
||||
assert_eq!(history.config.vhosts[0].routes.len(), 5);
|
||||
store.close().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn section_updates_are_revisioned_and_do_not_require_full_config_payloads() {
|
||||
let (router, store, _dir, secret, csrf) = fixture().await;
|
||||
|
||||
Reference in new issue
Block a user