sing-box/test/wrapper_test.go

31 lines
874 B
Go
Raw Normal View History

package main
import (
"testing"
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option"
"github.com/stretchr/testify/require"
)
func TestOptionsWrapper(t *testing.T) {
2024-11-18 10:59:19 +00:00
inbound := option.Inbound{
Type: C.TypeHTTP,
2024-11-18 10:59:19 +00:00
Options: &option.HTTPMixedInboundOptions{
InboundTLSOptionsContainer: option.InboundTLSOptionsContainer{
TLS: &option.InboundTLSOptions{
Enabled: true,
},
},
},
}
2024-11-18 10:59:19 +00:00
tlsOptionsWrapper, loaded := inbound.Options.(option.InboundTLSOptionsWrapper)
require.True(t, loaded, "find inbound tls options")
tlsOptions := tlsOptionsWrapper.TakeInboundTLSOptions()
require.NotNil(t, tlsOptions, "find inbound tls options")
tlsOptions.Enabled = false
tlsOptionsWrapper.ReplaceInboundTLSOptions(tlsOptions)
2024-11-18 10:59:19 +00:00
require.False(t, inbound.Options.(*option.HTTPMixedInboundOptions).TLS.Enabled, "replace tls enabled")
}