From adb7d400844f44bf1d79f7982e7b07469c909327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveirinha?= Date: Tue, 3 Oct 2023 11:25:59 +0100 Subject: [PATCH] CUSTESC-33731: Make rule match test report rule in 0-index base This changes guarantees that the coommand to report rule matches when testing local config reports the rule number using the 0-based indexing. This is to be consistent with the 0-based indexing on the log lines when proxying requests. --- cmd/cloudflared/tunnel/ingress_subcommands.go | 2 +- component-tests/test_config.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/cloudflared/tunnel/ingress_subcommands.go b/cmd/cloudflared/tunnel/ingress_subcommands.go index cc55e7a1..82ef7561 100644 --- a/cmd/cloudflared/tunnel/ingress_subcommands.go +++ b/cmd/cloudflared/tunnel/ingress_subcommands.go @@ -139,7 +139,7 @@ func testURLCommand(c *cli.Context) error { } _, i := ing.FindMatchingRule(requestURL.Hostname(), requestURL.Path) - fmt.Printf("Matched rule #%d\n", i+1) + fmt.Printf("Matched rule #%d\n", i) fmt.Println(ing.Rules[i].MultiLineString()) return nil } diff --git a/component-tests/test_config.py b/component-tests/test_config.py index 6402be57..2356e5f0 100644 --- a/component-tests/test_config.py +++ b/component-tests/test_config.py @@ -36,17 +36,17 @@ class TestConfig: _ = start_cloudflared(tmp_path, config, validate_args) self.match_rule(tmp_path, config, - "http://example.com/index.html", 1) + "http://example.com/index.html", 0) self.match_rule(tmp_path, config, - "https://example.com/index.html", 1) + "https://example.com/index.html", 0) self.match_rule(tmp_path, config, - "https://api.example.com/login", 2) + "https://api.example.com/login", 1) self.match_rule(tmp_path, config, - "https://wss.example.com", 3) + "https://wss.example.com", 2) self.match_rule(tmp_path, config, - "https://ssh.example.com", 4) + "https://ssh.example.com", 3) self.match_rule(tmp_path, config, - "https://api.example.com", 5) + "https://api.example.com", 4) # This is used to check that the command tunnel ingress url matches rule number . Note that rule number uses 1-based indexing