v0.26.0
This commit is contained in:
1 parent
d168ee2afa
commit
ddc5c6593f
70 files changed
+2293
-594
No files matched your search
@@ -383,6 +383,7 @@
|
||||
"/cache",
|
||||
"/transform",
|
||||
"/logging",
|
||||
"/logs",
|
||||
"/settings",
|
||||
] {
|
||||
let public = router
|
||||
|
||||
@@ -78,6 +78,9 @@
|
||||
for (path, expected) in [
|
||||
("/api/logs?vhost=demo&limit=8", 200),
|
||||
("/api/logs?cache=BAD", 400),
|
||||
("/api/file-logs", 200),
|
||||
("/api/file-logs/query?source=all&limit=8", 200),
|
||||
("/api/file-logs/query?limit=0", 400),
|
||||
("/api/traffic", 200),
|
||||
("/api/cache", 200),
|
||||
("/api/transform", 200),
|
||||
|
||||
@@ -293,6 +293,8 @@
|
||||
"/api/cache?limit=invalid",
|
||||
"/api/logs?limit=invalid",
|
||||
"/api/live-logs",
|
||||
"/api/file-logs",
|
||||
"/api/file-logs/query?limit=invalid",
|
||||
"/api/certificate-api",
|
||||
"/api/preferences",
|
||||
"/api/audit",
|
||||
@@ -322,6 +324,7 @@
|
||||
"/assets/redirects.js",
|
||||
"/assets/host404.js",
|
||||
"/assets/settings.js",
|
||||
"/assets/file-logs.js",
|
||||
"/assets/acme.js",
|
||||
"/api/not-a-route",
|
||||
"/not-a-route",
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
#[test]
|
||||
fn stored_log_inventory_keeps_existing_files_visible_when_writer_is_disabled() {
|
||||
use std::io::Write;
|
||||
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join("access.jsonl");
|
||||
let mut file = std::fs::File::create(&path).unwrap();
|
||||
writeln!(file, r#"{{"event":"request","status":200}}"#).unwrap();
|
||||
|
||||
let mut config = Config::default();
|
||||
config.logging.file.enabled = false;
|
||||
config.logging.file.per_vhost = false;
|
||||
config.logging.file.path = path.to_string_lossy().into_owned();
|
||||
let sources = configured_file_log_sources(&config);
|
||||
let access = sources.iter().find(|source| source.id == "access").unwrap();
|
||||
assert!(!access.enabled);
|
||||
assert!(access.exists);
|
||||
assert!(access.size > 0);
|
||||
assert_eq!(access.path, path);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stored_log_tail_enforces_line_budget() {
|
||||
use std::io::Write;
|
||||
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join("access.jsonl");
|
||||
let mut file = std::fs::File::create(&path).unwrap();
|
||||
for id in 0..10 {
|
||||
writeln!(file, r#"{{"time_ms":{id},"event":"request"}}"#).unwrap();
|
||||
}
|
||||
drop(file);
|
||||
|
||||
let source = source_from_path(
|
||||
"access".into(),
|
||||
"Access log".into(),
|
||||
"access",
|
||||
path,
|
||||
false,
|
||||
"JSONL",
|
||||
);
|
||||
let (lines, _bytes, truncated) = read_tail(&source, 1024 * 1024, 3).unwrap();
|
||||
assert_eq!(lines.len(), 3);
|
||||
assert!(lines[0].contains(r#""time_ms":9"#));
|
||||
assert!(lines[2].contains(r#""time_ms":7"#));
|
||||
assert!(truncated);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stored_log_query_rejects_oversized_source_identifier() {
|
||||
let query = FileLogQuery {
|
||||
source: Some("x".repeat(193)),
|
||||
..FileLogQuery::default()
|
||||
};
|
||||
assert!(validate_file_log_query(&query).is_err());
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn stored_log_reader_refuses_symlink_targets() {
|
||||
use std::os::unix::fs::symlink;
|
||||
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let real = dir.path().join("real.jsonl");
|
||||
let link = dir.path().join("link.jsonl");
|
||||
std::fs::write(&real, b"{}\n").unwrap();
|
||||
symlink(&real, &link).unwrap();
|
||||
assert!(open_file_log(&link).is_err());
|
||||
}
|
||||
Reference in new issue
Block a user