Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to bind to an outbound ip returns an empty list of port bindings #536

Open
4 of 5 tasks
atzoum opened this issue Sep 25, 2024 · 1 comment
Open
4 of 5 tasks
Labels

Comments

@atzoum
Copy link

atzoum commented Sep 25, 2024

Preflight checklist

Ory Network Project

No response

Describe the bug

Using a PortBindings for an outbound ip causes an empty mapped port to be returned

Reproducing the bug

func TestOutboundIPPortBinding(t *testing.T) {
	outboundIP := func() string {
		conn, err := net.Dial("udp", "8.8.8.8:80")
		require.NoError(t, err)
		defer conn.Close()
		localAddr := conn.LocalAddr().(*net.UDPAddr)
		return localAddr.IP.String()
	}()
	resource, err := pool.RunWithOptions(
		&dockertest.RunOptions{
			Repository: "postgres",
			Tag:        "9.5",
			Env:        []string{"POSTGRES_PASSWORD=secret"},
			PortBindings: map[dc.Port][]dc.PortBinding{
				"5432/tcp": {{HostIP: outboundIP, HostPort: "0"}},
			},
		})
	require.NoError(t, err)
	mappedPort := resource.GetPort("5432/tcp")
	require.NotEmpty(t, mappedPort)
	boundIP := resource.GetBoundIP("5432/tcp")
	require.Equal(t, outboundIP, boundIP)
	require.NoError(t, pool.Purge(resource))
}

Relevant log output

No response

Relevant configuration

No response

Version

latest dockertest

On which operating system are you observing this issue?

macOS

In which environment are you deploying?

None

Additional Context

No response

@atzoum atzoum added the bug label Sep 25, 2024
@atzoum
Copy link
Author

atzoum commented Sep 25, 2024

I have prepared a fix in #533

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant