Skip to content

Commit adb7d40

Browse files
committed
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.
1 parent 541c63d commit adb7d40

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

cmd/cloudflared/tunnel/ingress_subcommands.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func testURLCommand(c *cli.Context) error {
139139
}
140140

141141
_, i := ing.FindMatchingRule(requestURL.Hostname(), requestURL.Path)
142-
fmt.Printf("Matched rule #%d\n", i+1)
142+
fmt.Printf("Matched rule #%d\n", i)
143143
fmt.Println(ing.Rules[i].MultiLineString())
144144
return nil
145145
}

component-tests/test_config.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ def test_validate_ingress_rules(self, tmp_path, component_tests_config):
3636
_ = start_cloudflared(tmp_path, config, validate_args)
3737

3838
self.match_rule(tmp_path, config,
39-
"http://example.com/index.html", 1)
39+
"http://example.com/index.html", 0)
4040
self.match_rule(tmp_path, config,
41-
"https://example.com/index.html", 1)
41+
"https://example.com/index.html", 0)
4242
self.match_rule(tmp_path, config,
43-
"https://api.example.com/login", 2)
43+
"https://api.example.com/login", 1)
4444
self.match_rule(tmp_path, config,
45-
"https://wss.example.com", 3)
45+
"https://wss.example.com", 2)
4646
self.match_rule(tmp_path, config,
47-
"https://ssh.example.com", 4)
47+
"https://ssh.example.com", 3)
4848
self.match_rule(tmp_path, config,
49-
"https://api.example.com", 5)
49+
"https://api.example.com", 4)
5050

5151
# This is used to check that the command tunnel ingress url <url> matches rule number <rule_num>. Note that rule number uses 1-based indexing
5252

0 commit comments

Comments
 (0)