Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

53 lines
1.1 KiB

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package meshv2beta1
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestIsTransparentProxy(t *testing.T) {
cases := map[string]struct {
dynamicConfig *DynamicConfig
exp bool
}{
"nil dynamic config": {
dynamicConfig: nil,
exp: false,
},
"default mode": {
dynamicConfig: &DynamicConfig{
Mode: ProxyMode_PROXY_MODE_DEFAULT,
},
exp: false,
},
"direct mode": {
dynamicConfig: &DynamicConfig{
Mode: ProxyMode_PROXY_MODE_DEFAULT,
},
exp: false,
},
"transparent mode": {
dynamicConfig: &DynamicConfig{
Mode: ProxyMode_PROXY_MODE_TRANSPARENT,
},
exp: true,
},
}
for name, c := range cases {
t.Run(name, func(t *testing.T) {
proxyCfg := &ProxyConfiguration{
DynamicConfig: c.dynamicConfig,
}
compProxyCfg := &ComputedProxyConfiguration{
DynamicConfig: c.dynamicConfig,
}
require.Equal(t, c.exp, proxyCfg.IsTransparentProxy())
require.Equal(t, c.exp, compProxyCfg.IsTransparentProxy())
})
}
}