|
1 | 1 | package networking |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "context" |
4 | 5 | "strings" |
5 | 6 | "testing" |
| 7 | + "time" |
6 | 8 |
|
7 | 9 | containertypes "github.com/docker/docker/api/types/container" |
8 | 10 | "github.com/docker/docker/integration/internal/container" |
@@ -131,3 +133,27 @@ func TestInternalNetworkDNS(t *testing.T) { |
131 | 133 | assert.Check(t, is.Equal(res.ExitCode, 0)) |
132 | 134 | assert.Check(t, is.Contains(res.Stdout(), network.DNSRespAddr)) |
133 | 135 | } |
| 136 | + |
| 137 | +// TestNslookupWindows checks that nslookup gets results from external DNS. |
| 138 | +// Regression test for https://github.com/moby/moby/issues/46792 |
| 139 | +func TestNslookupWindows(t *testing.T) { |
| 140 | + skip.If(t, testEnv.DaemonInfo.OSType != "windows") |
| 141 | + |
| 142 | + ctx := setupTest(t) |
| 143 | + c := testEnv.APIClient() |
| 144 | + |
| 145 | + attachCtx, cancel := context.WithTimeout(ctx, 5*time.Second) |
| 146 | + defer cancel() |
| 147 | + res := container.RunAttach(attachCtx, t, c, |
| 148 | + container.WithCmd("nslookup", "docker.com"), |
| 149 | + ) |
| 150 | + defer c.ContainerRemove(ctx, res.ContainerID, containertypes.RemoveOptions{Force: true}) |
| 151 | + |
| 152 | + assert.Check(t, is.Equal(res.ExitCode, 0)) |
| 153 | + // Current default is to not-forward requests to external servers, which |
| 154 | + // can only be changed in daemon.json using feature flag "windows-dns-proxy". |
| 155 | + // So, expect the lookup to fail... |
| 156 | + assert.Check(t, is.Contains(res.Stderr.String(), "Server failed")) |
| 157 | + // When the default behaviour is changed, nslookup should succeed... |
| 158 | + //assert.Check(t, is.Contains(res.Stdout.String(), "Addresses:")) |
| 159 | +} |
0 commit comments