v0.31.5
This commit is contained in:
1 parent
d942c1a35d
commit
75104f87ba
103 files changed
+1344
-370
No files matched your search
@@ -397,7 +397,7 @@
|
||||
.unwrap();
|
||||
assert!(std::str::from_utf8(&public_body)
|
||||
.unwrap()
|
||||
.contains("/assets/login.js"));
|
||||
.contains(&format!("/assets/login_{}.js", super::asset_build_id())));
|
||||
|
||||
let private = router
|
||||
.clone()
|
||||
@@ -415,7 +415,7 @@
|
||||
.unwrap();
|
||||
assert!(std::str::from_utf8(&private_body)
|
||||
.unwrap()
|
||||
.contains("/assets/app.js"));
|
||||
.contains(&format!("/assets/app_{}.js", super::asset_build_id())));
|
||||
}
|
||||
store.close().await;
|
||||
}
|
||||
@@ -15,13 +15,9 @@
|
||||
"/",
|
||||
"/docs",
|
||||
"/docs/",
|
||||
"/docs/init.js",
|
||||
"/docs/style.css",
|
||||
"/docs/swagger-ui-bundle.js",
|
||||
"/docs/swagger-ui.css",
|
||||
"/docs/licenses.txt",
|
||||
"/docs/content.json",
|
||||
"/assets/app.js",
|
||||
&format!("/assets/app_{}.js", super::asset_build_id()),
|
||||
] {
|
||||
let response = router
|
||||
.clone()
|
||||
|
||||
@@ -34,6 +34,7 @@ fn stored_log_tail_enforces_line_budget() {
|
||||
let source = source_from_path(
|
||||
"access".into(),
|
||||
"Access log".into(),
|
||||
"access".into(),
|
||||
"access",
|
||||
path,
|
||||
false,
|
||||
@@ -61,6 +62,7 @@ fn stored_log_normalizes_mapped_client_ip_and_searches_diagnostics() {
|
||||
let source = source_from_path(
|
||||
"vhost:app".into(),
|
||||
"app.jsonl".into(),
|
||||
"vhost:app".into(),
|
||||
"access",
|
||||
dir.path().join("app.jsonl"),
|
||||
true,
|
||||
@@ -168,6 +170,7 @@ fn stored_log_tail_reads_rotated_gzip_and_inventory_discovers_it() {
|
||||
let source = source_from_path(
|
||||
"access:gz:access.jsonl.1.gz".into(),
|
||||
"Access log · access.jsonl.1.gz".into(),
|
||||
"access".into(),
|
||||
"access",
|
||||
rotated.clone(),
|
||||
true,
|
||||
@@ -186,3 +189,48 @@ fn stored_log_tail_reads_rotated_gzip_and_inventory_discovers_it() {
|
||||
let sources = configured_file_log_sources(&config);
|
||||
assert!(sources.iter().any(|item| item.path == rotated && item.compressed));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stored_log_per_vhost_inventory_groups_active_and_rotated_files() {
|
||||
use std::io::Write;
|
||||
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let active = dir.path().join("app.jsonl");
|
||||
std::fs::write(&active, b"{\"event\":\"request\"}\n").unwrap();
|
||||
let rotated = dir.path().join("app.jsonl.1.gz");
|
||||
let file = std::fs::File::create(&rotated).unwrap();
|
||||
let mut encoder = flate2::write::GzEncoder::new(file, flate2::Compression::default());
|
||||
writeln!(encoder, r#"{{"event":"request"}}"#).unwrap();
|
||||
encoder.finish().unwrap();
|
||||
|
||||
let mut config = Config::default();
|
||||
config.logging.file.per_vhost = true;
|
||||
config.logging.file.directory = dir.path().to_string_lossy().into_owned();
|
||||
let sources = configured_file_log_sources(&config);
|
||||
let app = sources.iter().filter(|source| source.group_id == "vhost:app").collect::<Vec<_>>();
|
||||
assert_eq!(app.len(), 2);
|
||||
assert!(app.iter().any(|source| source.id == "vhost:app"));
|
||||
assert!(app.iter().any(|source| source.compressed));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stored_log_aggregate_values_support_scalars_and_bounded_arrays() {
|
||||
let value = json!(["BadBot/1", "BadBot/1", 503, true, {"ignored":"object"}]);
|
||||
let mut values = Vec::new();
|
||||
file_log_aggregate_values(&value, &mut values);
|
||||
assert_eq!(values, vec!["BadBot/1".to_string(), "BadBot/1".to_string(), "503".to_string(), "true".to_string()]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stored_log_query_validates_aggregation_controls() {
|
||||
assert!(validate_file_log_query(&FileLogQuery {
|
||||
aggregate_field: Some("user_agent".into()),
|
||||
aggregate_min_count: Some(2),
|
||||
aggregate_limit: Some(50),
|
||||
..FileLogQuery::default()
|
||||
}).is_ok());
|
||||
assert!(validate_file_log_query(&FileLogQuery {
|
||||
aggregate_field: Some("bad field".into()),
|
||||
..FileLogQuery::default()
|
||||
}).is_err());
|
||||
}
|
||||
@@ -1,4 +1,35 @@
|
||||
#[tokio::test]
|
||||
async fn only_current_build_fingerprinted_javascript_and_css_are_served() {
|
||||
let (router, store, _dir, secret, _) = fixture().await;
|
||||
let cookie = format!("{}={secret}", auth::COOKIE_NAME);
|
||||
let id = super::asset_build_id();
|
||||
for (name, suffix) in [
|
||||
("/assets/app", "js"),
|
||||
("/assets/host404", "js"),
|
||||
("/assets/style", "css"),
|
||||
("/assets/login", "js"),
|
||||
("/docs/init", "js"),
|
||||
("/docs/style", "css"),
|
||||
("/docs/swagger-ui-bundle", "js"),
|
||||
("/docs/swagger-ui", "css"),
|
||||
] {
|
||||
let legacy = format!("{name}.{suffix}");
|
||||
let wrong = format!("{name}_0000000000000000.{suffix}");
|
||||
let current = format!("{name}_{id}.{suffix}");
|
||||
for path in [legacy, wrong] {
|
||||
let response = router.clone().oneshot(request(&path)
|
||||
.header("cookie", &cookie).body(Body::empty()).unwrap())
|
||||
.await.unwrap();
|
||||
assert_eq!(response.status(), StatusCode::NOT_FOUND, "{path}");
|
||||
}
|
||||
let response = router.clone().oneshot(request(¤t)
|
||||
.header("cookie", &cookie).body(Body::empty()).unwrap())
|
||||
.await.unwrap();
|
||||
assert_eq!(response.status(), StatusCode::OK, "{current}");
|
||||
}
|
||||
store.close().await;
|
||||
}
|
||||
#[tokio::test]
|
||||
async fn public_document_and_discovery_contain_only_login_information() {
|
||||
let (router, store, _dir, _, _) = fixture().await;
|
||||
for (path, expected) in [
|
||||
@@ -22,7 +53,7 @@
|
||||
.await
|
||||
.unwrap();
|
||||
let text = std::str::from_utf8(&bytes).unwrap();
|
||||
assert!(text.contains("/assets/login.js"));
|
||||
assert!(text.contains(&format!("/assets/login_{}.js", super::asset_build_id())));
|
||||
for absent in [
|
||||
"/assets/app.js",
|
||||
"id=\"workspace\"",
|
||||
|
||||
Reference in new issue
Block a user