tun_test.go 795 B

123456789101112131415161718192021222324
  1. package overlay
  2. import (
  3. "net/netip"
  4. "testing"
  5. "github.com/slackhq/nebula/config"
  6. "github.com/slackhq/nebula/test"
  7. "github.com/stretchr/testify/assert"
  8. "github.com/stretchr/testify/require"
  9. )
  10. // tun.disabled and the disabled tun's settings are only read when the device is made
  11. func TestDisabledTunRestartKeys(t *testing.T) {
  12. c := config.NewC(test.NewLogger())
  13. require.NoError(t, c.LoadString("tun:\n disabled: true\n"))
  14. d, err := NewDeviceFromConfig(c, test.NewLogger(), []netip.Prefix{netip.MustParsePrefix("10.1.0.2/24")}, 1)
  15. require.NoError(t, err)
  16. t.Cleanup(func() { _ = d.Close() })
  17. res := c.ReloadConfigString("tun:\n disabled: false\n tx_queue: 100\n")
  18. require.NoError(t, res.Err)
  19. assert.ElementsMatch(t, []string{"tun.disabled", "tun.tx_queue"}, res.RestartKeys)
  20. }