Skip to content

Commit

Permalink
Add test to verify that DNS search path is restored on quit.
Browse files Browse the repository at this point in the history
This test is windows specific because:
- On linux, the DNS search path is attached to the VIF, so when the VIF
  is gone, our DNS settings are gone with it.
- On macOS, there's no DNS search path. Instead, we add domains that
  correspond to the namespaces.

Signed-off-by: Thomas Hallgren <[email protected]>
  • Loading branch information
thallgren committed Nov 27, 2023
1 parent 8cf1fa2 commit 5a376bb
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions integration_test/restore_dns_search_windows_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package integration_test

import (
"os"
"strings"

"golang.org/x/sys/windows/registry"

"github.com/telepresenceio/telepresence/v2/integration_test/itest"
)

func (s *notConnectedSuite) getGlobalSearchList() []string {
const (
tcpParamKey = `System\CurrentControlSet\Services\Tcpip\Parameters`
searchListKey = `SearchList`
)
rk, err := registry.OpenKey(registry.LOCAL_MACHINE, tcpParamKey, registry.QUERY_VALUE)
if os.IsNotExist(err) {
err = nil
}
s.Require().NoError(err)
defer rk.Close()
csv, _, err := rk.GetStringValue(searchListKey)
if os.IsNotExist(err) {
err = nil
}
s.Require().NoError(err)
return strings.Split(csv, ",")
}

func (s *notConnectedSuite) Test_DNSSearchRestored() {
beforeConnect := s.getGlobalSearchList()
ctx := s.Context()
s.TelepresenceConnect(ctx)
afterConnect := s.getGlobalSearchList()
s.Assert().NotEqual(beforeConnect, afterConnect)
itest.TelepresenceQuitOk(ctx)
afterQuit := s.getGlobalSearchList()
s.Assert().Equal(beforeConnect, afterQuit)
}

0 comments on commit 5a376bb

Please sign in to comment.