[diff] Apply sequence: control applies six steps, Ianitor and Caddy answer the corpus identically after each
This commit is contained in:
+29
-1
@@ -37,6 +37,9 @@ pub struct Env {
|
||||
pub dir: TempDir,
|
||||
pub ca: TestCa,
|
||||
pub model: Model,
|
||||
/// The routes behind `model`: the site file and `(hosts/<name>.toml, contents)`.
|
||||
pub site: String,
|
||||
pub hosts: Vec<(String, String)>,
|
||||
_upstreams: (Echo, Echo, Echo, Echo, WsEcho, MockAuthelia),
|
||||
}
|
||||
|
||||
@@ -146,6 +149,8 @@ impl Env {
|
||||
dir,
|
||||
ca,
|
||||
model,
|
||||
site,
|
||||
hosts,
|
||||
_upstreams: (app, sick, rr_a, rr_b, ws, auth),
|
||||
}
|
||||
}
|
||||
@@ -877,10 +882,33 @@ fn short(o: &Observation) -> Observation {
|
||||
o
|
||||
}
|
||||
|
||||
/// The host a case is about (its SNI, or the Host header of plain-HTTP cases).
|
||||
pub fn case_host(case: &Case) -> String {
|
||||
match &case.action {
|
||||
Action::Https { sni, .. } | Action::Websocket { sni, .. } => (*sni).to_owned(),
|
||||
Action::Http { req } => req
|
||||
.headers
|
||||
.iter()
|
||||
.find(|(n, _)| n == "host")
|
||||
.map(|(_, v)| v.to_ascii_lowercase())
|
||||
.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Send every case to both targets, one after the other (round robin needs a stable order).
|
||||
pub async fn run_corpus(ianitor: &Target, caddy: &Target, roots: Arc<RootCertStore>) -> Report {
|
||||
run_cases(ianitor, caddy, roots, |_| true).await
|
||||
}
|
||||
|
||||
/// Like [`run_corpus`], for the cases `keep` selects.
|
||||
pub async fn run_cases(
|
||||
ianitor: &Target,
|
||||
caddy: &Target,
|
||||
roots: Arc<RootCertStore>,
|
||||
keep: impl Fn(&Case) -> bool,
|
||||
) -> Report {
|
||||
let mut outcomes = Vec::new();
|
||||
for case in corpus() {
|
||||
for case in corpus().into_iter().filter(|c| keep(c)) {
|
||||
let i = run_case(&case, ianitor, roots.clone()).await;
|
||||
let c = run_case(&case, caddy, roots.clone()).await;
|
||||
outcomes.push(Outcome {
|
||||
|
||||
Reference in New Issue
Block a user