aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2023-11-29 13:06:32 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2023-11-29 13:06:32 +0100
commitf11592926b9548c0797c02bd5aa4550a1f251c98 (patch)
tree4ea8abeb77f704b44df4e768f906eaef15f09bec /src
parentde72d6037f255c50ac7d326bbccc3bac462a279e (diff)
downloadtricot-f11592926b9548c0797c02bd5aa4550a1f251c98.tar.gz
tricot-f11592926b9548c0797c02bd5aa4550a1f251c98.zip
fix tests
Diffstat (limited to 'src')
-rw-r--r--src/proxy_config.rs22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/proxy_config.rs b/src/proxy_config.rs
index eebff72..a481058 100644
--- a/src/proxy_config.rs
+++ b/src/proxy_config.rs
@@ -144,16 +144,10 @@ impl ProxyEntry {
let mut redirects = vec![];
for mid in middleware.into_iter() {
match mid {
- ConfigTag::AddHeader(k, v) => add_headers.push((k.to_string(), v.to_string())),
+ ConfigTag::AddHeader(k, v) => add_headers.push((k.to_string(), v.clone())),
ConfigTag::AddRedirect(m, r, c) => redirects.push(((*m).clone(), (*r).clone(), *c)),
- ConfigTag::LocalLb =>
- /* handled in parent fx */
- {
- ()
- }
- ConfigTag::GlobalLb =>
- /* handled in parent fx */
- {
+ ConfigTag::LocalLb | ConfigTag::GlobalLb => {
+ /* handled in parent fx */
()
}
};
@@ -251,7 +245,7 @@ enum MatchTag {
#[derive(Debug)]
enum ConfigTag<'a> {
- AddHeader(&'a str, &'a str),
+ AddHeader(&'a str, String),
AddRedirect(UrlPrefix, UrlPrefix, u32),
GlobalLb,
LocalLb,
@@ -280,8 +274,8 @@ fn parse_tricot_tags(tag: &str) -> Option<ParsedTag> {
UrlPrefix::new(raw_prefix)
.map(|prefix| ParsedTag::Frontend(MatchTag::HttpWithTls(prefix, priority)))
}
- ["tricot-add-header", header_key, header_value] => Some(ParsedTag::Middleware(
- ConfigTag::AddHeader(header_key, header_value),
+ ["tricot-add-header", header_key, header_values @ ..] => Some(ParsedTag::Middleware(
+ ConfigTag::AddHeader(header_key, header_values.join(" ")),
)),
["tricot-add-redirect", raw_match, raw_replace, maybe_raw_code @ ..] => {
let (p_match, p_replace) =
@@ -525,8 +519,8 @@ mod tests {
#[test]
fn test_parse_tricot_add_header_tag() {
- match parse_tricot_add_header_tag("tricot-add-header Content-Security-Policy default-src 'none'; img-src 'self'; script-src 'self'; style-src 'self'") {
- Some((name, value)) => {
+ match parse_tricot_tags("tricot-add-header Content-Security-Policy default-src 'none'; img-src 'self'; script-src 'self'; style-src 'self'") {
+ Some(ParsedTag::Middleware(ConfigTag::AddHeader(name, value))) => {
assert_eq!(name, "Content-Security-Policy");
assert_eq!(value, "default-src 'none'; img-src 'self'; script-src 'self'; style-src 'self'");
}