summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-05-11 18:12:20 -0600
committermo khan <mo@mokhan.ca>2025-05-11 21:21:38 -0600
commita22be1d21780ad56b25401c4fd93b1c04d95f841 (patch)
tree123ce2320ce2de4beab2c1673981c201c5e18a44
parent371b8631aa32bc3ef906cf25eaa1fece0b2523d9 (diff)
test: provider container accessible host address
-rw-r--r--test/integration/container_test.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/test/integration/container_test.go b/test/integration/container_test.go
index dcea018..bc86046 100644
--- a/test/integration/container_test.go
+++ b/test/integration/container_test.go
@@ -8,6 +8,7 @@ import (
"net/http"
"net/url"
"strconv"
+ "strings"
"testing"
"time"
@@ -39,8 +40,11 @@ func TestContainer(t *testing.T) {
address, err := url.Parse(srv.MockOIDC.Addr())
require.NoError(t, err)
+ port, err := strconv.Atoi(address.Port())
+ require.NoError(t, err)
- t.Logf("mockoidc: %v %v\n", address.String(), srv.Issuer())
+ issuer := srv.Issuer()
+ t.Logf("mockoidc: %v %v %v\n", address.String(), issuer, testcontainers.HostInternal)
container, err := testcontainers.Run(
ctx,
env.Fetch("IMAGE_TAG", "sparkled:invalid"),
@@ -52,9 +56,9 @@ func TestContainer(t *testing.T) {
"OAUTH_CLIENT_ID": srv.MockOIDC.Config().ClientID,
"OAUTH_CLIENT_SECRET": srv.MockOIDC.Config().ClientSecret,
"OAUTH_REDIRECT_URL": "",
- "OIDC_ISSUER": srv.Issuer(),
+ "OIDC_ISSUER": strings.Replace(issuer, "127.0.0.1", testcontainers.HostInternal, 1),
}),
- testcontainers.WithHostPortAccess(x.Must(strconv.Atoi(address.Port()))),
+ testcontainers.WithHostPortAccess(port),
testcontainers.WithExposedPorts("8080/tcp", "9901/tcp", "10000/tcp"),
testcontainers.WithLogConsumers(&TestLogConsumer{t: t}),
testcontainers.WithWaitStrategy(wait.ForLog("Listening on").WithStartupTimeout(time.Second*5)),
@@ -70,6 +74,8 @@ func TestContainer(t *testing.T) {
envoyEndpoint, err := container.PortEndpoint(ctx, "10000", "http")
require.NoError(t, err)
+ client := &http.Client{Timeout: 5 * time.Second}
+
paths := []string{
envoyEndpoint + "/",
envoyEndpoint + "/health",
@@ -79,8 +85,6 @@ func TestContainer(t *testing.T) {
sparkleEndpoint + "/health",
}
- client := &http.Client{Timeout: 5 * time.Second}
-
for _, path := range paths {
t.Run(path, func(t *testing.T) {
request, err := http.NewRequestWithContext(ctx, http.MethodGet, path, nil)