wrapper_test.go 874 B

123456789101112131415161718192021222324252627282930
  1. package main
  2. import (
  3. "testing"
  4. C "github.com/sagernet/sing-box/constant"
  5. "github.com/sagernet/sing-box/option"
  6. "github.com/stretchr/testify/require"
  7. )
  8. func TestOptionsWrapper(t *testing.T) {
  9. inbound := option.Inbound{
  10. Type: C.TypeHTTP,
  11. Options: &option.HTTPMixedInboundOptions{
  12. InboundTLSOptionsContainer: option.InboundTLSOptionsContainer{
  13. TLS: &option.InboundTLSOptions{
  14. Enabled: true,
  15. },
  16. },
  17. },
  18. }
  19. tlsOptionsWrapper, loaded := inbound.Options.(option.InboundTLSOptionsWrapper)
  20. require.True(t, loaded, "find inbound tls options")
  21. tlsOptions := tlsOptionsWrapper.TakeInboundTLSOptions()
  22. require.NotNil(t, tlsOptions, "find inbound tls options")
  23. tlsOptions.Enabled = false
  24. tlsOptionsWrapper.ReplaceInboundTLSOptions(tlsOptions)
  25. require.False(t, inbound.Options.(*option.HTTPMixedInboundOptions).TLS.Enabled, "replace tls enabled")
  26. }