v0.36.0
This commit is contained in:
1 parent
3a384baa6b
commit
672c84bc13
21 files changed
+450
-70
No files matched your search
@@ -3527,6 +3527,91 @@ mod tests {
|
||||
store.close().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn polling_views_omit_static_configuration_and_reject_unknown_modes() {
|
||||
let (router, store, _dir, secret, _) = fixture().await;
|
||||
let cookie = format!("{}={secret}", auth::COOKIE_NAME);
|
||||
|
||||
for (path, omitted, retained) in [
|
||||
(
|
||||
"/api/cache?view=live",
|
||||
&["settings", "vhosts"][..],
|
||||
&["revision", "metrics", "dashboard", "bans"][..],
|
||||
),
|
||||
(
|
||||
"/api/transform?view=live",
|
||||
&["settings", "vhosts"][..],
|
||||
&["revision", "resources", "metrics"][..],
|
||||
),
|
||||
(
|
||||
"/api/traffic?view=live",
|
||||
&["vhosts"][..],
|
||||
&["revision", "settings", "geoip", "analytics"][..],
|
||||
),
|
||||
] {
|
||||
let response = router
|
||||
.clone()
|
||||
.oneshot(
|
||||
request(path)
|
||||
.header("cookie", &cookie)
|
||||
.body(Body::empty())
|
||||
.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(response.status(), StatusCode::OK, "GET {path}");
|
||||
let value = json_body(response).await;
|
||||
for &field in omitted {
|
||||
assert!(value.get(field).is_none(), "{path} unexpectedly contains {field}");
|
||||
}
|
||||
for &field in retained {
|
||||
assert!(value.get(field).is_some(), "{path} is missing {field}");
|
||||
}
|
||||
}
|
||||
|
||||
for (path, required) in [
|
||||
("/api/cache", &["settings", "vhosts"][..]),
|
||||
("/api/transform", &["settings", "vhosts"][..]),
|
||||
("/api/traffic", &["vhosts"][..]),
|
||||
] {
|
||||
let response = router
|
||||
.clone()
|
||||
.oneshot(
|
||||
request(path)
|
||||
.header("cookie", &cookie)
|
||||
.body(Body::empty())
|
||||
.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(response.status(), StatusCode::OK, "GET {path}");
|
||||
let value = json_body(response).await;
|
||||
assert!(value.get("revision").is_some());
|
||||
for &field in required {
|
||||
assert!(value.get(field).is_some(), "{path} is missing {field}");
|
||||
}
|
||||
}
|
||||
|
||||
for path in [
|
||||
"/api/cache?view=unknown",
|
||||
"/api/transform?view=unknown",
|
||||
"/api/traffic?view=unknown",
|
||||
] {
|
||||
let response = router
|
||||
.clone()
|
||||
.oneshot(
|
||||
request(path)
|
||||
.header("cookie", &cookie)
|
||||
.body(Body::empty())
|
||||
.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(response.status(), StatusCode::BAD_REQUEST, "GET {path}");
|
||||
}
|
||||
store.close().await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn defaults_and_partial_legacy_refresh_documents() {
|
||||
let previous = serde_json::to_value(AdminPreferences::default()).unwrap();
|
||||
|
||||
Reference in new issue
Block a user