Skip to content

Commit

Permalink
add test with ${host} substitution
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed May 22, 2024
1 parent a0a08a8 commit 2ae93d8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/discovery/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ func TestService_MatchServerRegex(t *testing.T) {
// regex servers
{Server: "test-prefix\\.(.*)", SrcMatch: *regexp.MustCompile("^/(.*)"),
Dst: "http://127.0.0.1:8080/$host/blah/$1", MatchType: MTProxy, dead: false},
{Server: "test-prefix2\\.(.*)", SrcMatch: *regexp.MustCompile("^/(.*)"),
Dst: "http://127.0.0.1:8080/${host}/blah/$1", MatchType: MTProxy, dead: false},
{Server: "(.*)\\.test-domain\\.(com|org)", SrcMatch: *regexp.MustCompile("^/bar/(.*)"),
Dst: "http://127.0.0.2:8080/$1/foo", MatchType: MTProxy, dead: false},

Expand Down Expand Up @@ -222,11 +224,17 @@ func TestService_MatchServerRegex(t *testing.T) {
res: Matches{MTProxy, []MatchedRoute{{Destination: "http://127.0.0.4:8080/", Alive: true}}},
},
{
name: "regex server with host match",
name: "regex server with $host match",
server: "test-prefix.example.com",
src: "/some",
res: Matches{MTProxy, []MatchedRoute{{Destination: "http://127.0.0.1:8080/test-prefix.example.com/blah/some", Alive: true}}},
},
{
name: "regex server with ${host} match",
server: "test-prefix2.example.com",
src: "/some",
res: Matches{MTProxy, []MatchedRoute{{Destination: "http://127.0.0.1:8080/test-prefix2.example.com/blah/some", Alive: true}}},
},
{
name: "regex server without a match",
server: "another-prefix.example.com",
Expand Down

0 comments on commit 2ae93d8

Please sign in to comment.