Skip to content

Commit

Permalink
e2e: add connect-to flag smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatczuk committed Sep 11, 2024
1 parent dd6c0f3 commit b03e94a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions e2e/forwarder/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ func (s *Service) WithDNSTimeout(timeout time.Duration) *Service {
return s
}

func (s *Service) WithConnectTo(v string) compose.ServiceBuilder {
s.Environment["FORWARDER_CONNECT_TO"] = v
return s
}

func (s *Service) WithHTTPDialTimeout(timeout time.Duration) *Service {
s.Environment["FORWARDER_HTTP_DIAL_TIMEOUT"] = timeout.String()
return s
Expand Down
18 changes: 18 additions & 0 deletions e2e/setups.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func AllSetups() []setup.Setup {
SetupFlagResponseHeader(l)
SetupFlagConnectHeader(l)
SetupFlagDNSServer(l)
SetupFlagConnectTo(l)
SetupFlagInsecure(l)
SetupFlagMITMCACert(l)
SetupFlagMITMGenCA(l)
Expand Down Expand Up @@ -294,6 +295,23 @@ func SetupFlagDNSServer(l *setupList) {
}
}

func SetupFlagConnectTo(l *setupList) {
l.Add(
setup.Setup{
Name: "flag-connect-to",
Compose: compose.NewBuilder().
AddService(
forwarder.HttpbinService()).
AddService(
forwarder.ProxyService().
WithConnectTo("foo::httpbin:8080")).
MustBuild(),
Run: "^TestFlagConnectTo$",
},
)

}

func SetupFlagInsecure(l *setupList) {
l.Add(
setup.Setup{
Expand Down
4 changes: 4 additions & 0 deletions e2e/tests/flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ func TestFlagDNSServer(t *testing.T) {
})
}

func TestFlagConnectTo(t *testing.T) {
newClient(t, serviceScheme("HTTPBIN_PROTOCOL") + "://foo:123").GET("/status/200").ExpectStatus(http.StatusOK)
}

func TestFlagInsecure(t *testing.T) {
t.Run("true", func(t *testing.T) {
newClient(t, httpbin).GET("/status/200").ExpectStatus(http.StatusOK)
Expand Down

0 comments on commit b03e94a

Please sign in to comment.