2023-12-11 18:36:06 +08:00
|
|
|
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 18:59:19 +08:00
|
|
|
inbound := option.Inbound{
|
2023-12-11 18:36:06 +08:00
|
|
|
Type: C.TypeHTTP,
|
2024-11-18 18:59:19 +08:00
|
|
|
Options: &option.HTTPMixedInboundOptions{
|
2023-12-11 18:36:06 +08:00
|
|
|
InboundTLSOptionsContainer: option.InboundTLSOptionsContainer{
|
|
|
|
TLS: &option.InboundTLSOptions{
|
|
|
|
Enabled: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2024-11-18 18:59:19 +08:00
|
|
|
tlsOptionsWrapper, loaded := inbound.Options.(option.InboundTLSOptionsWrapper)
|
2023-12-11 18:36:06 +08:00
|
|
|
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 18:59:19 +08:00
|
|
|
require.False(t, inbound.Options.(*option.HTTPMixedInboundOptions).TLS.Enabled, "replace tls enabled")
|
2023-12-11 18:36:06 +08:00
|
|
|
}
|