diff --git a/docker/services/httpbin.yml b/docker/services/httpbin.yml index 5231913a267..d9566ccfd34 100644 --- a/docker/services/httpbin.yml +++ b/docker/services/httpbin.yml @@ -4,12 +4,14 @@ services: image: tykio/ci-tools:latest networks: - proxy + ports: + - 3123:3123 volumes: - ./logs:/logs:rw entrypoint: - /usr/local/bin/httpbin-logserver command: - '-addr' - - ':80' + - ':3123' - '-output' - '/logs/service.json' diff --git a/tests/regression/issue_10104_test.go b/tests/regression/issue_10104_test.go index 610b7fd184b..e3ee3b239be 100644 --- a/tests/regression/issue_10104_test.go +++ b/tests/regression/issue_10104_test.go @@ -10,7 +10,7 @@ import ( func Test_Issue10104(t *testing.T) { ts := gateway.StartTest(nil) - defer ts.Close() + t.Cleanup(ts.Close) // load api definition from file ts.Gw.LoadAPI(loadAPISpec(t, "testdata/issue-10104-apidef.json")) diff --git a/tests/regression/issue_11585_test.go b/tests/regression/issue_11585_test.go index 5e89448ece5..3455ce275e2 100644 --- a/tests/regression/issue_11585_test.go +++ b/tests/regression/issue_11585_test.go @@ -17,7 +17,7 @@ import ( func Test_Issue11585_DeleteAPICacheSignal(t *testing.T) { t.Run("redis event", func(t *testing.T) { ts := gateway.StartTest(nil) - defer ts.Close() + t.Cleanup(ts.Close) api := ts.Gw.BuildAndLoadAPI(func(spec *gateway.APISpec) { spec.UseKeylessAccess = true @@ -49,7 +49,7 @@ func Test_Issue11585_DeleteAPICacheSignal(t *testing.T) { t.Run("rpc", func(t *testing.T) { ts := gateway.StartTest(nil) - defer ts.Close() + t.Cleanup(ts.Close) rpcListener := gateway.RPCStorageHandler{ KeyPrefix: "rpc.listener.", diff --git a/tests/regression/issue_11806_test.go b/tests/regression/issue_11806_test.go index 83a23332adb..589acee1e87 100644 --- a/tests/regression/issue_11806_test.go +++ b/tests/regression/issue_11806_test.go @@ -25,7 +25,7 @@ func Test_Issue11806_DomainRouting(t *testing.T) { t.Run("Load listenPath without domain first", func(t *testing.T) { ts := gateway.StartTest(testConfig) - defer ts.Close() + t.Cleanup(ts.Close) ts.Gw.LoadAPI(noDomain, withDomain) @@ -34,7 +34,7 @@ func Test_Issue11806_DomainRouting(t *testing.T) { t.Run("Load listenPath with domain first", func(t *testing.T) { ts := gateway.StartTest(testConfig) - defer ts.Close() + t.Cleanup(ts.Close) ts.Gw.LoadAPI(withDomain, noDomain) @@ -62,10 +62,10 @@ func testDomainRouting(tb testing.TB, ts *gateway.Test) { }, { Path: "/test/", - Host: "customer.mydomain.com", + Host: "example.com", Method: http.MethodGet, Code: http.StatusOK, - BodyMatch: "customer.mydomain.com", + BodyMatch: "example.com", }, }...) } @@ -80,7 +80,7 @@ func testSubrouterHost(t *testing.T) { ctx := context.Background() // Create a subrouter with a specific host - subrouter := router.Host("customer.mydomain.com").Subrouter() + subrouter := router.Host("example.com").Subrouter() subrouter.HandleFunc("/test", func(w http.ResponseWriter, _ *http.Request) { _, err := w.Write([]byte("Subrouter")) assert.NoError(t, err) @@ -117,7 +117,7 @@ func testSubrouterHost(t *testing.T) { reqWithSpecificHost, err := http.NewRequestWithContext(ctx, "GET", "/test", nil) assert.NoError(t, err) - reqWithSpecificHost.Host = "customer.mydomain.com" + reqWithSpecificHost.Host = "example.com" respWithSpecificHost := httptest.NewRecorder() router.ServeHTTP(respWithSpecificHost, reqWithSpecificHost) if respWithSpecificHost.Body.String() != "Subrouter" { @@ -131,7 +131,7 @@ func testRouteLongestPathFirst(t *testing.T) { ts := gateway.StartTest(func(globalConf *config.Config) { globalConf.EnableCustomDomains = true }) - defer ts.Close() + t.Cleanup(ts.Close) type hostAndPath struct { host, path string diff --git a/tests/regression/regression_test.go b/tests/regression/regression_test.go index df100c4f6fc..653d0b78b23 100644 --- a/tests/regression/regression_test.go +++ b/tests/regression/regression_test.go @@ -3,6 +3,7 @@ package regression import ( "embed" "encoding/json" + "strings" "testing" "github.com/stretchr/testify/require" @@ -25,6 +26,9 @@ func loadAPISpec(tb testing.TB, filename string) *gateway.APISpec { err := json.Unmarshal(data, apidef) require.NoError(tb, err, "Error decoding API Definition: %s", filename) + // auto replace from public to private endpoint, part of CI env + apidef.Proxy.ListenPath = strings.ReplaceAll(apidef.Proxy.ListenPath, "httpbin.org", "127.0.0.1:3123") + return &gateway.APISpec{ APIDefinition: apidef, } diff --git a/tests/regression/testdata/issue-11806-api-with-domain.json b/tests/regression/testdata/issue-11806-api-with-domain.json index 080f971c315..4e34440f883 100644 --- a/tests/regression/testdata/issue-11806-api-with-domain.json +++ b/tests/regression/testdata/issue-11806-api-with-domain.json @@ -4,12 +4,12 @@ "auth": { "auth_header_name": "Authorization" }, - "domain": "customer.mydomain.com", + "domain": "example.com", "name": "api3", "proxy": { "listen_path": "/test/", "strip_listen_path": true, - "target_url": "http://httpbin.org/anything/api3/customer.mydomain.com" + "target_url": "http://httpbin.org/anything/api3/example.com" }, "use_keyless": true, "version_data": {