Skip to content

Commit

Permalink
added a test for HasName
Browse files Browse the repository at this point in the history
  • Loading branch information
avatus committed Jun 29, 2022
1 parent 461fbb5 commit 5a97047
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions lib/web/app/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,42 @@ func TestAuthPOST(t *testing.T) {
}
}

func TestHasName(t *testing.T) {
for _, test := range []struct {
desc string
addrs []string
reqHost string
reqURL string
expectedURL string
hasName bool
}{
{
desc: "NOK - invalid host",
addrs: []string{"proxy.com"},
reqURL: "badurl.com",
expectedURL: "",
hasName: false,
},
{
desc: "OK - adds path",
addrs: []string{"proxy.com"},
reqURL: "https://app1.proxy.com/foo",
expectedURL: "https://proxy.com/web/launch/app1.proxy.com%3Fpath=/foo",
hasName: true,
},
} {
t.Run(test.desc, func(t *testing.T) {
req, err := http.NewRequest(http.MethodGet, test.reqURL, nil)
require.NoError(t, err)

addrs := utils.MustParseAddrList(test.addrs...)
u, ok := HasName(req, addrs)
require.Equal(t, test.expectedURL, u)
require.Equal(t, test.hasName, ok)
})
}
}

func TestMatchApplicationServers(t *testing.T) {
clusterName := "test-cluster"
publicAddr := "app.example.com"
Expand Down

0 comments on commit 5a97047

Please sign in to comment.