Skip to content

Commit

Permalink
CUSTESC-33731: Make rule match test report rule in 0-index base
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
joliveirinha committed Oct 3, 2023
1 parent 541c63d commit adb7d40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/cloudflared/tunnel/ingress_subcommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
12 changes: 6 additions & 6 deletions component-tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ def test_validate_ingress_rules(self, tmp_path, component_tests_config):
_ = 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 <url> matches rule number <rule_num>. Note that rule number uses 1-based indexing

Expand Down

0 comments on commit adb7d40

Please sign in to comment.