Merge pull request #9444 from hashicorp/dnephin/config-tests-sanitize
config: Use golden for TestRuntimeConfig_Sanitize
This commit is contained in:
commit
1b374a20dc
|
@ -0,0 +1,36 @@
|
||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
// update allows golden files to be updated based on the current output.
|
||||||
|
var update = flag.Bool("update", false, "update golden files")
|
||||||
|
|
||||||
|
// golden reads the expected value from the file at filename and returns the value.
|
||||||
|
// filename is relative to the ./testdata directory.
|
||||||
|
//
|
||||||
|
// If the `-update` flag is used with `go test`, the golden file will be updated
|
||||||
|
// to the value of actual.
|
||||||
|
func golden(t *testing.T, actual, filename string) string {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
path := filepath.Join("testdata", filename)
|
||||||
|
if *update && actual != "" {
|
||||||
|
if dir := filepath.Dir(path); dir != "." {
|
||||||
|
require.NoError(t, os.MkdirAll(dir, 0755))
|
||||||
|
}
|
||||||
|
err := ioutil.WriteFile(path, []byte(actual), 0644)
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
expected, err := ioutil.ReadFile(path)
|
||||||
|
require.NoError(t, err)
|
||||||
|
return string(expected)
|
||||||
|
}
|
|
@ -2,13 +2,7 @@
|
||||||
|
|
||||||
package config
|
package config
|
||||||
|
|
||||||
var authMethodEntFields = `{}`
|
var testRuntimeConfigSanitizeExpectedFilename = "TestRuntimeConfig_Sanitize.golden"
|
||||||
|
|
||||||
var entMetaJSON = `{}`
|
|
||||||
|
|
||||||
var entRuntimeConfigSanitize = `{}`
|
|
||||||
|
|
||||||
var entTokenConfigSanitize = `"EnterpriseConfig": {},`
|
|
||||||
|
|
||||||
func entFullRuntimeConfig(rt *RuntimeConfig) {}
|
func entFullRuntimeConfig(rt *RuntimeConfig) {}
|
||||||
|
|
||||||
|
|
|
@ -7460,7 +7460,7 @@ func parseCIDR(t *testing.T, cidr string) *net.IPNet {
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSanitize(t *testing.T) {
|
func TestRuntimeConfig_Sanitize(t *testing.T) {
|
||||||
rt := RuntimeConfig{
|
rt := RuntimeConfig{
|
||||||
BindAddr: &net.IPAddr{IP: net.ParseIP("127.0.0.1")},
|
BindAddr: &net.IPAddr{IP: net.ParseIP("127.0.0.1")},
|
||||||
CheckOutputMaxSize: checks.DefaultBufSize,
|
CheckOutputMaxSize: checks.DefaultBufSize,
|
||||||
|
@ -7529,413 +7529,10 @@ func TestSanitize(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
rtJSON := `{
|
|
||||||
"ACLTokens": {
|
|
||||||
` + entTokenConfigSanitize + `
|
|
||||||
"ACLAgentMasterToken": "hidden",
|
|
||||||
"ACLAgentToken": "hidden",
|
|
||||||
"ACLDefaultToken": "hidden",
|
|
||||||
"ACLReplicationToken": "hidden",
|
|
||||||
"DataDir": "",
|
|
||||||
"EnablePersistence": false
|
|
||||||
},
|
|
||||||
"ACLDatacenter": "",
|
|
||||||
"ACLDefaultPolicy": "",
|
|
||||||
"ACLDisabledTTL": "0s",
|
|
||||||
"ACLDownPolicy": "",
|
|
||||||
"ACLEnableKeyListPolicy": false,
|
|
||||||
"ACLMasterToken": "hidden",
|
|
||||||
"ACLPolicyTTL": "0s",
|
|
||||||
"ACLRoleTTL": "0s",
|
|
||||||
"ACLTokenReplication": false,
|
|
||||||
"ACLTokenTTL": "0s",
|
|
||||||
"ACLsEnabled": false,
|
|
||||||
"AEInterval": "0s",
|
|
||||||
"AdvertiseAddrLAN": "",
|
|
||||||
"AdvertiseAddrWAN": "",
|
|
||||||
"AdvertiseReconnectTimeout": "0s",
|
|
||||||
"AutopilotCleanupDeadServers": false,
|
|
||||||
"AutopilotDisableUpgradeMigration": false,
|
|
||||||
"AutopilotLastContactThreshold": "0s",
|
|
||||||
"AutopilotMaxTrailingLogs": 0,
|
|
||||||
"AutopilotMinQuorum": 0,
|
|
||||||
"AutopilotRedundancyZoneTag": "",
|
|
||||||
"AutopilotServerStabilizationTime": "0s",
|
|
||||||
"AutopilotUpgradeVersionTag": "",
|
|
||||||
"BindAddr": "127.0.0.1",
|
|
||||||
"Bootstrap": false,
|
|
||||||
"BootstrapExpect": 0,
|
|
||||||
"Cache": {
|
|
||||||
"EntryFetchMaxBurst": 42,
|
|
||||||
"EntryFetchRate": 0.334
|
|
||||||
},
|
|
||||||
"CAFile": "",
|
|
||||||
"CAPath": "",
|
|
||||||
"CertFile": "",
|
|
||||||
"CheckDeregisterIntervalMin": "0s",
|
|
||||||
"CheckOutputMaxSize": ` + strconv.Itoa(checks.DefaultBufSize) + `,
|
|
||||||
"CheckReapInterval": "0s",
|
|
||||||
"CheckUpdateInterval": "0s",
|
|
||||||
"Checks": [{
|
|
||||||
"AliasNode": "",
|
|
||||||
"AliasService": "",
|
|
||||||
"DeregisterCriticalServiceAfter": "0s",
|
|
||||||
"DockerContainerID": "",
|
|
||||||
"EnterpriseMeta": ` + entMetaJSON + `,
|
|
||||||
"SuccessBeforePassing": 0,
|
|
||||||
"FailuresBeforeCritical": 0,
|
|
||||||
"GRPC": "",
|
|
||||||
"GRPCUseTLS": false,
|
|
||||||
"HTTP": "",
|
|
||||||
"Header": {},
|
|
||||||
"ID": "",
|
|
||||||
"Interval": "0s",
|
|
||||||
"Method": "",
|
|
||||||
"Body": "",
|
|
||||||
"Name": "zoo",
|
|
||||||
"Notes": "",
|
|
||||||
"OutputMaxSize": ` + strconv.Itoa(checks.DefaultBufSize) + `,
|
|
||||||
"ScriptArgs": [],
|
|
||||||
"ServiceID": "",
|
|
||||||
"Shell": "",
|
|
||||||
"Status": "",
|
|
||||||
"TCP": "",
|
|
||||||
"TLSSkipVerify": false,
|
|
||||||
"TTL": "0s",
|
|
||||||
"Timeout": "0s",
|
|
||||||
"Token": "hidden"
|
|
||||||
}],
|
|
||||||
"ClientAddrs": [],
|
|
||||||
"ConfigEntryBootstrap": [],
|
|
||||||
"AutoEncryptTLS": false,
|
|
||||||
"AutoEncryptDNSSAN": [],
|
|
||||||
"AutoEncryptIPSAN": [],
|
|
||||||
"AutoEncryptAllowTLS": false,
|
|
||||||
"ConnectCAConfig": {},
|
|
||||||
"ConnectCAProvider": "",
|
|
||||||
"ConnectEnabled": false,
|
|
||||||
"ConnectMeshGatewayWANFederationEnabled": false,
|
|
||||||
"ConnectSidecarMaxPort": 0,
|
|
||||||
"ConnectSidecarMinPort": 0,
|
|
||||||
"ConnectTestCALeafRootChangeSpread": "0s",
|
|
||||||
"ConsulCoordinateUpdateBatchSize": 0,
|
|
||||||
"ConsulCoordinateUpdateMaxBatches": 0,
|
|
||||||
"ConsulCoordinateUpdatePeriod": "15s",
|
|
||||||
"ConsulRaftElectionTimeout": "0s",
|
|
||||||
"CheckOutputMaxSize": ` + strconv.Itoa(checks.DefaultBufSize) + `,
|
|
||||||
"ConsulRaftHeartbeatTimeout": "0s",
|
|
||||||
"ConsulRaftLeaderLeaseTimeout": "0s",
|
|
||||||
"GossipLANGossipInterval": "0s",
|
|
||||||
"GossipLANGossipNodes": 0,
|
|
||||||
"GossipLANProbeInterval": "0s",
|
|
||||||
"GossipLANProbeTimeout": "0s",
|
|
||||||
"GossipLANRetransmitMult": 0,
|
|
||||||
"GossipLANSuspicionMult": 0,
|
|
||||||
"GossipWANGossipInterval": "0s",
|
|
||||||
"GossipWANGossipNodes": 0,
|
|
||||||
"GossipWANProbeInterval": "0s",
|
|
||||||
"GossipWANProbeTimeout": "0s",
|
|
||||||
"GossipWANRetransmitMult": 0,
|
|
||||||
"GossipWANSuspicionMult": 0,
|
|
||||||
"ConsulServerHealthInterval": "0s",
|
|
||||||
"DNSARecordLimit": 0,
|
|
||||||
"DNSAddrs": [
|
|
||||||
"tcp://1.2.3.4:5678",
|
|
||||||
"udp://1.2.3.4:5678"
|
|
||||||
],
|
|
||||||
"DNSAllowStale": false,
|
|
||||||
"DNSDisableCompression": false,
|
|
||||||
"DNSDomain": "",
|
|
||||||
"DNSAltDomain": "",
|
|
||||||
"DNSEnableTruncate": false,
|
|
||||||
"DNSMaxStale": "0s",
|
|
||||||
"DNSNodeMetaTXT": false,
|
|
||||||
"DNSNodeTTL": "0s",
|
|
||||||
"DNSOnlyPassing": false,
|
|
||||||
"DNSPort": 0,
|
|
||||||
"DNSRecursorTimeout": "0s",
|
|
||||||
"DNSRecursors": [],
|
|
||||||
"DNSServiceTTL": {},
|
|
||||||
"DNSSOA": {
|
|
||||||
"Refresh": 3600,
|
|
||||||
"Retry": 600,
|
|
||||||
"Expire": 86400,
|
|
||||||
"Minttl": 0
|
|
||||||
},
|
|
||||||
"DNSUDPAnswerLimit": 0,
|
|
||||||
"DNSUseCache": false,
|
|
||||||
"DNSCacheMaxAge": "0s",
|
|
||||||
"DataDir": "",
|
|
||||||
"Datacenter": "",
|
|
||||||
"DefaultQueryTime": "0s",
|
|
||||||
"DevMode": false,
|
|
||||||
"DisableAnonymousSignature": false,
|
|
||||||
"DisableCoordinates": false,
|
|
||||||
"DisableHTTPUnprintableCharFilter": false,
|
|
||||||
"DisableHostNodeID": false,
|
|
||||||
"DisableKeyringFile": false,
|
|
||||||
"DisableRemoteExec": false,
|
|
||||||
"DisableUpdateCheck": false,
|
|
||||||
"DiscardCheckOutput": false,
|
|
||||||
"DiscoveryMaxStale": "0s",
|
|
||||||
"EnableAgentTLSForChecks": false,
|
|
||||||
"EnableDebug": false,
|
|
||||||
"EnableCentralServiceConfig": false,
|
|
||||||
"EnableLocalScriptChecks": false,
|
|
||||||
"EnableRemoteScriptChecks": false,
|
|
||||||
"EncryptKey": "hidden",
|
|
||||||
"EncryptVerifyIncoming": false,
|
|
||||||
"EncryptVerifyOutgoing": false,
|
|
||||||
"EnterpriseRuntimeConfig": ` + entRuntimeConfigSanitize + `,
|
|
||||||
"ExposeMaxPort": 0,
|
|
||||||
"ExposeMinPort": 0,
|
|
||||||
"GRPCAddrs": [],
|
|
||||||
"GRPCPort": 0,
|
|
||||||
"HTTPAddrs": [
|
|
||||||
"tcp://1.2.3.4:5678",
|
|
||||||
"unix:///var/run/foo"
|
|
||||||
],
|
|
||||||
"HTTPBlockEndpoints": [],
|
|
||||||
"HTTPMaxConnsPerClient": 0,
|
|
||||||
"HTTPMaxHeaderBytes": 0,
|
|
||||||
"HTTPPort": 0,
|
|
||||||
"HTTPResponseHeaders": {},
|
|
||||||
"HTTPUseCache": false,
|
|
||||||
"HTTPSAddrs": [],
|
|
||||||
"HTTPSHandshakeTimeout": "0s",
|
|
||||||
"HTTPSPort": 0,
|
|
||||||
"KeyFile": "hidden",
|
|
||||||
"KVMaxValueSize": 1234567800000000,
|
|
||||||
"LeaveDrainTime": "0s",
|
|
||||||
"LeaveOnTerm": false,
|
|
||||||
"Logging": {
|
|
||||||
"EnableSyslog": false,
|
|
||||||
"LogLevel": "",
|
|
||||||
"LogJSON": false,
|
|
||||||
"LogFilePath": "",
|
|
||||||
"LogRotateBytes": 0,
|
|
||||||
"LogRotateDuration": "0s",
|
|
||||||
"LogRotateMaxFiles": 0,
|
|
||||||
"Name": "",
|
|
||||||
"SyslogFacility": ""
|
|
||||||
},
|
|
||||||
"MaxQueryTime": "0s",
|
|
||||||
"NodeID": "",
|
|
||||||
"NodeMeta": {},
|
|
||||||
"NodeName": "",
|
|
||||||
"PidFile": "",
|
|
||||||
"PrimaryDatacenter": "",
|
|
||||||
"PrimaryGateways": [
|
|
||||||
"pmgw_foo=bar pmgw_key=baz pmgw_secret=boom pmgw_bang=bar"
|
|
||||||
],
|
|
||||||
"PrimaryGatewaysInterval": "0s",
|
|
||||||
"ReadReplica": false,
|
|
||||||
"RPCAdvertiseAddr": "",
|
|
||||||
"RPCBindAddr": "",
|
|
||||||
"RPCHandshakeTimeout": "0s",
|
|
||||||
"RPCHoldTimeout": "0s",
|
|
||||||
"RPCMaxBurst": 0,
|
|
||||||
"RPCMaxConnsPerClient": 0,
|
|
||||||
"RPCProtocol": 0,
|
|
||||||
"RPCRateLimit": 0,
|
|
||||||
"RPCConfig": {
|
|
||||||
"EnableStreaming": false
|
|
||||||
},
|
|
||||||
"RaftProtocol": 3,
|
|
||||||
"RaftSnapshotInterval": "0s",
|
|
||||||
"RaftSnapshotThreshold": 0,
|
|
||||||
"RaftTrailingLogs": 0,
|
|
||||||
"ReconnectTimeoutLAN": "0s",
|
|
||||||
"ReconnectTimeoutWAN": "0s",
|
|
||||||
"RejoinAfterLeave": false,
|
|
||||||
"RetryJoinIntervalLAN": "0s",
|
|
||||||
"RetryJoinIntervalWAN": "0s",
|
|
||||||
"RetryJoinLAN": [
|
|
||||||
"foo=bar key=hidden secret=hidden bang=bar"
|
|
||||||
],
|
|
||||||
"RetryJoinMaxAttemptsLAN": 0,
|
|
||||||
"RetryJoinMaxAttemptsWAN": 0,
|
|
||||||
"RetryJoinWAN": [
|
|
||||||
"wan_foo=bar wan_key=hidden wan_secret=hidden wan_bang=bar"
|
|
||||||
],
|
|
||||||
"Revision": "",
|
|
||||||
"SegmentLimit": 0,
|
|
||||||
"SegmentName": "",
|
|
||||||
"SegmentNameLimit": 0,
|
|
||||||
"Segments": [],
|
|
||||||
"SerfAdvertiseAddrLAN": "tcp://1.2.3.4:5678",
|
|
||||||
"SerfAdvertiseAddrWAN": "",
|
|
||||||
"SerfAllowedCIDRsLAN": ["192.168.1.0/24", "127.0.0.0/8"],
|
|
||||||
"SerfAllowedCIDRsWAN": [],
|
|
||||||
"SerfBindAddrLAN": "",
|
|
||||||
"SerfBindAddrWAN": "",
|
|
||||||
"SerfPortLAN": 0,
|
|
||||||
"SerfPortWAN": 0,
|
|
||||||
"UseStreamingBackend": false,
|
|
||||||
"ServerMode": false,
|
|
||||||
"ServerName": "",
|
|
||||||
"ServerPort": 0,
|
|
||||||
"Services": [{
|
|
||||||
"Address": "",
|
|
||||||
"Check": {
|
|
||||||
"AliasNode": "",
|
|
||||||
"AliasService": "",
|
|
||||||
"CheckID": "",
|
|
||||||
"DeregisterCriticalServiceAfter": "0s",
|
|
||||||
"DockerContainerID": "",
|
|
||||||
"SuccessBeforePassing": 0,
|
|
||||||
"FailuresBeforeCritical": 0,
|
|
||||||
"GRPC": "",
|
|
||||||
"GRPCUseTLS": false,
|
|
||||||
"HTTP": "",
|
|
||||||
"Header": {},
|
|
||||||
"Interval": "0s",
|
|
||||||
"Method": "",
|
|
||||||
"Body": "",
|
|
||||||
"Name": "blurb",
|
|
||||||
"Notes": "",
|
|
||||||
"OutputMaxSize": ` + strconv.Itoa(checks.DefaultBufSize) + `,
|
|
||||||
"ProxyGRPC": "",
|
|
||||||
"ProxyHTTP": "",
|
|
||||||
"ScriptArgs": [],
|
|
||||||
"Shell": "",
|
|
||||||
"Status": "",
|
|
||||||
"TCP": "",
|
|
||||||
"TLSSkipVerify": false,
|
|
||||||
"TTL": "0s",
|
|
||||||
"Timeout": "0s"
|
|
||||||
},
|
|
||||||
"Checks": [],
|
|
||||||
"Connect": null,
|
|
||||||
"EnableTagOverride": false,
|
|
||||||
"EnterpriseMeta": ` + entMetaJSON + `,
|
|
||||||
"ID": "",
|
|
||||||
"Kind": "",
|
|
||||||
"Meta": {},
|
|
||||||
"Name": "foo",
|
|
||||||
"Port": 0,
|
|
||||||
"Proxy": null,
|
|
||||||
"TaggedAddresses": {},
|
|
||||||
"Tags": [],
|
|
||||||
"Token": "hidden",
|
|
||||||
"Weights": {
|
|
||||||
"Passing": 67,
|
|
||||||
"Warning": 3
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
"SessionTTLMin": "0s",
|
|
||||||
"SkipLeaveOnInt": false,
|
|
||||||
"StartJoinAddrsLAN": [],
|
|
||||||
"StartJoinAddrsWAN": [],
|
|
||||||
"SyncCoordinateIntervalMin": "0s",
|
|
||||||
"SyncCoordinateRateTarget": 0,
|
|
||||||
"TLSCipherSuites": [],
|
|
||||||
"TLSMinVersion": "",
|
|
||||||
"TLSPreferServerCipherSuites": false,
|
|
||||||
"TaggedAddresses": {},
|
|
||||||
"Telemetry": {
|
|
||||||
"AllowedPrefixes": [],
|
|
||||||
"BlockedPrefixes": [],
|
|
||||||
"CirconusAPIApp": "",
|
|
||||||
"CirconusAPIToken": "hidden",
|
|
||||||
"CirconusAPIURL": "",
|
|
||||||
"CirconusBrokerID": "",
|
|
||||||
"CirconusBrokerSelectTag": "",
|
|
||||||
"CirconusCheckDisplayName": "",
|
|
||||||
"CirconusCheckForceMetricActivation": "",
|
|
||||||
"CirconusCheckID": "",
|
|
||||||
"CirconusCheckInstanceID": "",
|
|
||||||
"CirconusCheckSearchTag": "",
|
|
||||||
"CirconusCheckTags": "",
|
|
||||||
"CirconusSubmissionInterval": "",
|
|
||||||
"CirconusSubmissionURL": "",
|
|
||||||
"Disable": false,
|
|
||||||
"DisableCompatOneNine": false,
|
|
||||||
"DisableHostname": false,
|
|
||||||
"DogstatsdAddr": "",
|
|
||||||
"DogstatsdTags": [],
|
|
||||||
"FilterDefault": false,
|
|
||||||
"MetricsPrefix": "",
|
|
||||||
"StatsdAddr": "",
|
|
||||||
"StatsiteAddr": "",
|
|
||||||
"PrometheusOpts": {
|
|
||||||
"Expiration": "0s",
|
|
||||||
"Registerer": null,
|
|
||||||
"GaugeDefinitions": [],
|
|
||||||
"CounterDefinitions": [],
|
|
||||||
"SummaryDefinitions": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"TranslateWANAddrs": false,
|
|
||||||
"TxnMaxReqLen": 5678000000000000,
|
|
||||||
"UIConfig": {
|
|
||||||
"ContentPath": "",
|
|
||||||
"Dir": "",
|
|
||||||
"Enabled": false,
|
|
||||||
"MetricsProvider": "",
|
|
||||||
"MetricsProviderFiles": [],
|
|
||||||
"MetricsProviderOptionsJSON": "",
|
|
||||||
"MetricsProxy": {
|
|
||||||
"AddHeaders": [
|
|
||||||
{
|
|
||||||
"Name": "foo",
|
|
||||||
"Value": "hidden"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"BaseURL": "",
|
|
||||||
"PathAllowlist": []
|
|
||||||
},
|
|
||||||
"DashboardURLTemplates": {}
|
|
||||||
},
|
|
||||||
"UnixSocketGroup": "",
|
|
||||||
"UnixSocketMode": "",
|
|
||||||
"UnixSocketUser": "",
|
|
||||||
"VerifyIncoming": false,
|
|
||||||
"VerifyIncomingHTTPS": false,
|
|
||||||
"VerifyIncomingRPC": false,
|
|
||||||
"VerifyOutgoing": false,
|
|
||||||
"VerifyServerHostname": false,
|
|
||||||
"Version": "",
|
|
||||||
"VersionPrerelease": "",
|
|
||||||
"Watches": [],
|
|
||||||
"AllowWriteHTTPFrom": [
|
|
||||||
"127.0.0.0/8",
|
|
||||||
"::1/128"
|
|
||||||
],
|
|
||||||
"AutoConfig": {
|
|
||||||
"Authorizer": {
|
|
||||||
"Enabled": false,
|
|
||||||
"AllowReuse": false,
|
|
||||||
"AuthMethod": {
|
|
||||||
"ACLAuthMethodEnterpriseFields": ` + authMethodEntFields + `,
|
|
||||||
"Config": {},
|
|
||||||
"Description": "",
|
|
||||||
"DisplayName": "",
|
|
||||||
"EnterpriseMeta": ` + entMetaJSON + `,
|
|
||||||
"MaxTokenTTL": "0s",
|
|
||||||
"Name": "",
|
|
||||||
"RaftIndex": {
|
|
||||||
"CreateIndex": 0,
|
|
||||||
"ModifyIndex": 0
|
|
||||||
},
|
|
||||||
"Type": "",
|
|
||||||
"TokenLocality": ""
|
|
||||||
},
|
|
||||||
"ClaimAssertions": []
|
|
||||||
},
|
|
||||||
"Enabled": false,
|
|
||||||
"DNSSANs": [],
|
|
||||||
"IntroToken": "hidden",
|
|
||||||
"IntroTokenFile": "",
|
|
||||||
"IPSANs": [],
|
|
||||||
"ServerAddresses": []
|
|
||||||
}
|
|
||||||
}`
|
|
||||||
b, err := json.MarshalIndent(rt.Sanitized(), "", " ")
|
b, err := json.MarshalIndent(rt.Sanitized(), "", " ")
|
||||||
if err != nil {
|
require.NoError(t, err)
|
||||||
t.Fatal(err)
|
actual := string(b)
|
||||||
}
|
require.JSONEq(t, golden(t, actual, testRuntimeConfigSanitizeExpectedFilename), actual)
|
||||||
require.JSONEq(t, rtJSON, string(b))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRuntime_apiAddresses(t *testing.T) {
|
func TestRuntime_apiAddresses(t *testing.T) {
|
||||||
|
|
|
@ -0,0 +1,408 @@
|
||||||
|
{
|
||||||
|
"ACLDatacenter": "",
|
||||||
|
"ACLDefaultPolicy": "",
|
||||||
|
"ACLDisabledTTL": "0s",
|
||||||
|
"ACLDownPolicy": "",
|
||||||
|
"ACLEnableKeyListPolicy": false,
|
||||||
|
"ACLMasterToken": "hidden",
|
||||||
|
"ACLPolicyTTL": "0s",
|
||||||
|
"ACLRoleTTL": "0s",
|
||||||
|
"ACLTokenReplication": false,
|
||||||
|
"ACLTokenTTL": "0s",
|
||||||
|
"ACLTokens": {
|
||||||
|
"ACLAgentMasterToken": "hidden",
|
||||||
|
"ACLAgentToken": "hidden",
|
||||||
|
"ACLDefaultToken": "hidden",
|
||||||
|
"ACLReplicationToken": "hidden",
|
||||||
|
"DataDir": "",
|
||||||
|
"EnablePersistence": false,
|
||||||
|
"EnterpriseConfig": {}
|
||||||
|
},
|
||||||
|
"ACLsEnabled": false,
|
||||||
|
"AEInterval": "0s",
|
||||||
|
"AdvertiseAddrLAN": "",
|
||||||
|
"AdvertiseAddrWAN": "",
|
||||||
|
"AdvertiseReconnectTimeout": "0s",
|
||||||
|
"AllowWriteHTTPFrom": [
|
||||||
|
"127.0.0.0/8",
|
||||||
|
"::1/128"
|
||||||
|
],
|
||||||
|
"AutoConfig": {
|
||||||
|
"Authorizer": {
|
||||||
|
"AllowReuse": false,
|
||||||
|
"AuthMethod": {
|
||||||
|
"ACLAuthMethodEnterpriseFields": {},
|
||||||
|
"Config": {},
|
||||||
|
"Description": "",
|
||||||
|
"DisplayName": "",
|
||||||
|
"EnterpriseMeta": {},
|
||||||
|
"MaxTokenTTL": "0s",
|
||||||
|
"Name": "",
|
||||||
|
"RaftIndex": {
|
||||||
|
"CreateIndex": 0,
|
||||||
|
"ModifyIndex": 0
|
||||||
|
},
|
||||||
|
"TokenLocality": "",
|
||||||
|
"Type": ""
|
||||||
|
},
|
||||||
|
"ClaimAssertions": [],
|
||||||
|
"Enabled": false
|
||||||
|
},
|
||||||
|
"DNSSANs": [],
|
||||||
|
"Enabled": false,
|
||||||
|
"IPSANs": [],
|
||||||
|
"IntroToken": "hidden",
|
||||||
|
"IntroTokenFile": "",
|
||||||
|
"ServerAddresses": []
|
||||||
|
},
|
||||||
|
"AutoEncryptAllowTLS": false,
|
||||||
|
"AutoEncryptDNSSAN": [],
|
||||||
|
"AutoEncryptIPSAN": [],
|
||||||
|
"AutoEncryptTLS": false,
|
||||||
|
"AutopilotCleanupDeadServers": false,
|
||||||
|
"AutopilotDisableUpgradeMigration": false,
|
||||||
|
"AutopilotLastContactThreshold": "0s",
|
||||||
|
"AutopilotMaxTrailingLogs": 0,
|
||||||
|
"AutopilotMinQuorum": 0,
|
||||||
|
"AutopilotRedundancyZoneTag": "",
|
||||||
|
"AutopilotServerStabilizationTime": "0s",
|
||||||
|
"AutopilotUpgradeVersionTag": "",
|
||||||
|
"BindAddr": "127.0.0.1",
|
||||||
|
"Bootstrap": false,
|
||||||
|
"BootstrapExpect": 0,
|
||||||
|
"CAFile": "",
|
||||||
|
"CAPath": "",
|
||||||
|
"Cache": {
|
||||||
|
"EntryFetchMaxBurst": 42,
|
||||||
|
"EntryFetchRate": 0.334
|
||||||
|
},
|
||||||
|
"CertFile": "",
|
||||||
|
"CheckDeregisterIntervalMin": "0s",
|
||||||
|
"CheckOutputMaxSize": 4096,
|
||||||
|
"CheckReapInterval": "0s",
|
||||||
|
"CheckUpdateInterval": "0s",
|
||||||
|
"Checks": [
|
||||||
|
{
|
||||||
|
"AliasNode": "",
|
||||||
|
"AliasService": "",
|
||||||
|
"Body": "",
|
||||||
|
"DeregisterCriticalServiceAfter": "0s",
|
||||||
|
"DockerContainerID": "",
|
||||||
|
"EnterpriseMeta": {},
|
||||||
|
"FailuresBeforeCritical": 0,
|
||||||
|
"GRPC": "",
|
||||||
|
"GRPCUseTLS": false,
|
||||||
|
"HTTP": "",
|
||||||
|
"Header": {},
|
||||||
|
"ID": "",
|
||||||
|
"Interval": "0s",
|
||||||
|
"Method": "",
|
||||||
|
"Name": "zoo",
|
||||||
|
"Notes": "",
|
||||||
|
"OutputMaxSize": 4096,
|
||||||
|
"ScriptArgs": [],
|
||||||
|
"ServiceID": "",
|
||||||
|
"Shell": "",
|
||||||
|
"Status": "",
|
||||||
|
"SuccessBeforePassing": 0,
|
||||||
|
"TCP": "",
|
||||||
|
"TLSSkipVerify": false,
|
||||||
|
"TTL": "0s",
|
||||||
|
"Timeout": "0s",
|
||||||
|
"Token": "hidden"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ClientAddrs": [],
|
||||||
|
"ConfigEntryBootstrap": [],
|
||||||
|
"ConnectCAConfig": {},
|
||||||
|
"ConnectCAProvider": "",
|
||||||
|
"ConnectEnabled": false,
|
||||||
|
"ConnectMeshGatewayWANFederationEnabled": false,
|
||||||
|
"ConnectSidecarMaxPort": 0,
|
||||||
|
"ConnectSidecarMinPort": 0,
|
||||||
|
"ConnectTestCALeafRootChangeSpread": "0s",
|
||||||
|
"ConsulCoordinateUpdateBatchSize": 0,
|
||||||
|
"ConsulCoordinateUpdateMaxBatches": 0,
|
||||||
|
"ConsulCoordinateUpdatePeriod": "15s",
|
||||||
|
"ConsulRaftElectionTimeout": "0s",
|
||||||
|
"ConsulRaftHeartbeatTimeout": "0s",
|
||||||
|
"ConsulRaftLeaderLeaseTimeout": "0s",
|
||||||
|
"ConsulServerHealthInterval": "0s",
|
||||||
|
"DNSARecordLimit": 0,
|
||||||
|
"DNSAddrs": [
|
||||||
|
"tcp://1.2.3.4:5678",
|
||||||
|
"udp://1.2.3.4:5678"
|
||||||
|
],
|
||||||
|
"DNSAllowStale": false,
|
||||||
|
"DNSAltDomain": "",
|
||||||
|
"DNSCacheMaxAge": "0s",
|
||||||
|
"DNSDisableCompression": false,
|
||||||
|
"DNSDomain": "",
|
||||||
|
"DNSEnableTruncate": false,
|
||||||
|
"DNSMaxStale": "0s",
|
||||||
|
"DNSNodeMetaTXT": false,
|
||||||
|
"DNSNodeTTL": "0s",
|
||||||
|
"DNSOnlyPassing": false,
|
||||||
|
"DNSPort": 0,
|
||||||
|
"DNSRecursorTimeout": "0s",
|
||||||
|
"DNSRecursors": [],
|
||||||
|
"DNSSOA": {
|
||||||
|
"Expire": 86400,
|
||||||
|
"Minttl": 0,
|
||||||
|
"Refresh": 3600,
|
||||||
|
"Retry": 600
|
||||||
|
},
|
||||||
|
"DNSServiceTTL": {},
|
||||||
|
"DNSUDPAnswerLimit": 0,
|
||||||
|
"DNSUseCache": false,
|
||||||
|
"DataDir": "",
|
||||||
|
"Datacenter": "",
|
||||||
|
"DefaultQueryTime": "0s",
|
||||||
|
"DevMode": false,
|
||||||
|
"DisableAnonymousSignature": false,
|
||||||
|
"DisableCoordinates": false,
|
||||||
|
"DisableHTTPUnprintableCharFilter": false,
|
||||||
|
"DisableHostNodeID": false,
|
||||||
|
"DisableKeyringFile": false,
|
||||||
|
"DisableRemoteExec": false,
|
||||||
|
"DisableUpdateCheck": false,
|
||||||
|
"DiscardCheckOutput": false,
|
||||||
|
"DiscoveryMaxStale": "0s",
|
||||||
|
"EnableAgentTLSForChecks": false,
|
||||||
|
"EnableCentralServiceConfig": false,
|
||||||
|
"EnableDebug": false,
|
||||||
|
"EnableLocalScriptChecks": false,
|
||||||
|
"EnableRemoteScriptChecks": false,
|
||||||
|
"EncryptKey": "hidden",
|
||||||
|
"EncryptVerifyIncoming": false,
|
||||||
|
"EncryptVerifyOutgoing": false,
|
||||||
|
"EnterpriseRuntimeConfig": {},
|
||||||
|
"ExposeMaxPort": 0,
|
||||||
|
"ExposeMinPort": 0,
|
||||||
|
"GRPCAddrs": [],
|
||||||
|
"GRPCPort": 0,
|
||||||
|
"GossipLANGossipInterval": "0s",
|
||||||
|
"GossipLANGossipNodes": 0,
|
||||||
|
"GossipLANProbeInterval": "0s",
|
||||||
|
"GossipLANProbeTimeout": "0s",
|
||||||
|
"GossipLANRetransmitMult": 0,
|
||||||
|
"GossipLANSuspicionMult": 0,
|
||||||
|
"GossipWANGossipInterval": "0s",
|
||||||
|
"GossipWANGossipNodes": 0,
|
||||||
|
"GossipWANProbeInterval": "0s",
|
||||||
|
"GossipWANProbeTimeout": "0s",
|
||||||
|
"GossipWANRetransmitMult": 0,
|
||||||
|
"GossipWANSuspicionMult": 0,
|
||||||
|
"HTTPAddrs": [
|
||||||
|
"tcp://1.2.3.4:5678",
|
||||||
|
"unix:///var/run/foo"
|
||||||
|
],
|
||||||
|
"HTTPBlockEndpoints": [],
|
||||||
|
"HTTPMaxConnsPerClient": 0,
|
||||||
|
"HTTPMaxHeaderBytes": 0,
|
||||||
|
"HTTPPort": 0,
|
||||||
|
"HTTPResponseHeaders": {},
|
||||||
|
"HTTPSAddrs": [],
|
||||||
|
"HTTPSHandshakeTimeout": "0s",
|
||||||
|
"HTTPSPort": 0,
|
||||||
|
"HTTPUseCache": false,
|
||||||
|
"KVMaxValueSize": 1234567800000000,
|
||||||
|
"KeyFile": "hidden",
|
||||||
|
"LeaveDrainTime": "0s",
|
||||||
|
"LeaveOnTerm": false,
|
||||||
|
"Logging": {
|
||||||
|
"EnableSyslog": false,
|
||||||
|
"LogFilePath": "",
|
||||||
|
"LogJSON": false,
|
||||||
|
"LogLevel": "",
|
||||||
|
"LogRotateBytes": 0,
|
||||||
|
"LogRotateDuration": "0s",
|
||||||
|
"LogRotateMaxFiles": 0,
|
||||||
|
"Name": "",
|
||||||
|
"SyslogFacility": ""
|
||||||
|
},
|
||||||
|
"MaxQueryTime": "0s",
|
||||||
|
"NodeID": "",
|
||||||
|
"NodeMeta": {},
|
||||||
|
"NodeName": "",
|
||||||
|
"PidFile": "",
|
||||||
|
"PrimaryDatacenter": "",
|
||||||
|
"PrimaryGateways": [
|
||||||
|
"pmgw_foo=bar pmgw_key=baz pmgw_secret=boom pmgw_bang=bar"
|
||||||
|
],
|
||||||
|
"PrimaryGatewaysInterval": "0s",
|
||||||
|
"RPCAdvertiseAddr": "",
|
||||||
|
"RPCBindAddr": "",
|
||||||
|
"RPCConfig": {
|
||||||
|
"EnableStreaming": false
|
||||||
|
},
|
||||||
|
"RPCHandshakeTimeout": "0s",
|
||||||
|
"RPCHoldTimeout": "0s",
|
||||||
|
"RPCMaxBurst": 0,
|
||||||
|
"RPCMaxConnsPerClient": 0,
|
||||||
|
"RPCProtocol": 0,
|
||||||
|
"RPCRateLimit": 0,
|
||||||
|
"RaftProtocol": 3,
|
||||||
|
"RaftSnapshotInterval": "0s",
|
||||||
|
"RaftSnapshotThreshold": 0,
|
||||||
|
"RaftTrailingLogs": 0,
|
||||||
|
"ReadReplica": false,
|
||||||
|
"ReconnectTimeoutLAN": "0s",
|
||||||
|
"ReconnectTimeoutWAN": "0s",
|
||||||
|
"RejoinAfterLeave": false,
|
||||||
|
"RetryJoinIntervalLAN": "0s",
|
||||||
|
"RetryJoinIntervalWAN": "0s",
|
||||||
|
"RetryJoinLAN": [
|
||||||
|
"foo=bar key=hidden secret=hidden bang=bar"
|
||||||
|
],
|
||||||
|
"RetryJoinMaxAttemptsLAN": 0,
|
||||||
|
"RetryJoinMaxAttemptsWAN": 0,
|
||||||
|
"RetryJoinWAN": [
|
||||||
|
"wan_foo=bar wan_key=hidden wan_secret=hidden wan_bang=bar"
|
||||||
|
],
|
||||||
|
"Revision": "",
|
||||||
|
"SegmentLimit": 0,
|
||||||
|
"SegmentName": "",
|
||||||
|
"SegmentNameLimit": 0,
|
||||||
|
"Segments": [],
|
||||||
|
"SerfAdvertiseAddrLAN": "tcp://1.2.3.4:5678",
|
||||||
|
"SerfAdvertiseAddrWAN": "",
|
||||||
|
"SerfAllowedCIDRsLAN": [
|
||||||
|
"192.168.1.0/24",
|
||||||
|
"127.0.0.0/8"
|
||||||
|
],
|
||||||
|
"SerfAllowedCIDRsWAN": [],
|
||||||
|
"SerfBindAddrLAN": "",
|
||||||
|
"SerfBindAddrWAN": "",
|
||||||
|
"SerfPortLAN": 0,
|
||||||
|
"SerfPortWAN": 0,
|
||||||
|
"ServerMode": false,
|
||||||
|
"ServerName": "",
|
||||||
|
"ServerPort": 0,
|
||||||
|
"Services": [
|
||||||
|
{
|
||||||
|
"Address": "",
|
||||||
|
"Check": {
|
||||||
|
"AliasNode": "",
|
||||||
|
"AliasService": "",
|
||||||
|
"Body": "",
|
||||||
|
"CheckID": "",
|
||||||
|
"DeregisterCriticalServiceAfter": "0s",
|
||||||
|
"DockerContainerID": "",
|
||||||
|
"FailuresBeforeCritical": 0,
|
||||||
|
"GRPC": "",
|
||||||
|
"GRPCUseTLS": false,
|
||||||
|
"HTTP": "",
|
||||||
|
"Header": {},
|
||||||
|
"Interval": "0s",
|
||||||
|
"Method": "",
|
||||||
|
"Name": "blurb",
|
||||||
|
"Notes": "",
|
||||||
|
"OutputMaxSize": 4096,
|
||||||
|
"ProxyGRPC": "",
|
||||||
|
"ProxyHTTP": "",
|
||||||
|
"ScriptArgs": [],
|
||||||
|
"Shell": "",
|
||||||
|
"Status": "",
|
||||||
|
"SuccessBeforePassing": 0,
|
||||||
|
"TCP": "",
|
||||||
|
"TLSSkipVerify": false,
|
||||||
|
"TTL": "0s",
|
||||||
|
"Timeout": "0s"
|
||||||
|
},
|
||||||
|
"Checks": [],
|
||||||
|
"Connect": null,
|
||||||
|
"EnableTagOverride": false,
|
||||||
|
"EnterpriseMeta": {},
|
||||||
|
"ID": "",
|
||||||
|
"Kind": "",
|
||||||
|
"Meta": {},
|
||||||
|
"Name": "foo",
|
||||||
|
"Port": 0,
|
||||||
|
"Proxy": null,
|
||||||
|
"TaggedAddresses": {},
|
||||||
|
"Tags": [],
|
||||||
|
"Token": "hidden",
|
||||||
|
"Weights": {
|
||||||
|
"Passing": 67,
|
||||||
|
"Warning": 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"SessionTTLMin": "0s",
|
||||||
|
"SkipLeaveOnInt": false,
|
||||||
|
"StartJoinAddrsLAN": [],
|
||||||
|
"StartJoinAddrsWAN": [],
|
||||||
|
"SyncCoordinateIntervalMin": "0s",
|
||||||
|
"SyncCoordinateRateTarget": 0,
|
||||||
|
"TLSCipherSuites": [],
|
||||||
|
"TLSMinVersion": "",
|
||||||
|
"TLSPreferServerCipherSuites": false,
|
||||||
|
"TaggedAddresses": {},
|
||||||
|
"Telemetry": {
|
||||||
|
"AllowedPrefixes": [],
|
||||||
|
"BlockedPrefixes": [],
|
||||||
|
"CirconusAPIApp": "",
|
||||||
|
"CirconusAPIToken": "hidden",
|
||||||
|
"CirconusAPIURL": "",
|
||||||
|
"CirconusBrokerID": "",
|
||||||
|
"CirconusBrokerSelectTag": "",
|
||||||
|
"CirconusCheckDisplayName": "",
|
||||||
|
"CirconusCheckForceMetricActivation": "",
|
||||||
|
"CirconusCheckID": "",
|
||||||
|
"CirconusCheckInstanceID": "",
|
||||||
|
"CirconusCheckSearchTag": "",
|
||||||
|
"CirconusCheckTags": "",
|
||||||
|
"CirconusSubmissionInterval": "",
|
||||||
|
"CirconusSubmissionURL": "",
|
||||||
|
"Disable": false,
|
||||||
|
"DisableCompatOneNine": false,
|
||||||
|
"DisableHostname": false,
|
||||||
|
"DogstatsdAddr": "",
|
||||||
|
"DogstatsdTags": [],
|
||||||
|
"FilterDefault": false,
|
||||||
|
"MetricsPrefix": "",
|
||||||
|
"PrometheusOpts": {
|
||||||
|
"CounterDefinitions": [],
|
||||||
|
"Expiration": "0s",
|
||||||
|
"GaugeDefinitions": [],
|
||||||
|
"Registerer": null,
|
||||||
|
"SummaryDefinitions": []
|
||||||
|
},
|
||||||
|
"StatsdAddr": "",
|
||||||
|
"StatsiteAddr": ""
|
||||||
|
},
|
||||||
|
"TranslateWANAddrs": false,
|
||||||
|
"TxnMaxReqLen": 5678000000000000,
|
||||||
|
"UIConfig": {
|
||||||
|
"ContentPath": "",
|
||||||
|
"DashboardURLTemplates": {},
|
||||||
|
"Dir": "",
|
||||||
|
"Enabled": false,
|
||||||
|
"MetricsProvider": "",
|
||||||
|
"MetricsProviderFiles": [],
|
||||||
|
"MetricsProviderOptionsJSON": "",
|
||||||
|
"MetricsProxy": {
|
||||||
|
"AddHeaders": [
|
||||||
|
{
|
||||||
|
"Name": "foo",
|
||||||
|
"Value": "hidden"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"BaseURL": "",
|
||||||
|
"PathAllowlist": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"UnixSocketGroup": "",
|
||||||
|
"UnixSocketMode": "",
|
||||||
|
"UnixSocketUser": "",
|
||||||
|
"UseStreamingBackend": false,
|
||||||
|
"VerifyIncoming": false,
|
||||||
|
"VerifyIncomingHTTPS": false,
|
||||||
|
"VerifyIncomingRPC": false,
|
||||||
|
"VerifyOutgoing": false,
|
||||||
|
"VerifyServerHostname": false,
|
||||||
|
"Version": "",
|
||||||
|
"VersionPrerelease": "",
|
||||||
|
"Watches": []
|
||||||
|
}
|
|
@ -33,9 +33,9 @@ There are four specific cases covered with increasing complexity:
|
||||||
`TestFullConfig` in `agent/config/runtime_test.go`, it should fail now, then
|
`TestFullConfig` in `agent/config/runtime_test.go`, it should fail now, then
|
||||||
add the same random value to the expected struct in that test so it passes
|
add the same random value to the expected struct in that test so it passes
|
||||||
again.
|
again.
|
||||||
- [ ] Add the new field and it's default value to `TestSanitize` in the same
|
- [ ] Run `go test -run TestRuntimeConfig_Sanitize ./agent/config -update` to update
|
||||||
file. (Running the test first gives you a nice diff which can save working
|
the expected value for `TestRuntimeConfig_Sanitize`. Look at `git diff` to
|
||||||
out where etc.)
|
make sure the value changed as you expect.
|
||||||
- [ ] **If** your new config field needed some validation as it's only valid in
|
- [ ] **If** your new config field needed some validation as it's only valid in
|
||||||
some cases or with some values (often true).
|
some cases or with some values (often true).
|
||||||
- [ ] Add validation to Validate in `agent/config/builder.go`.
|
- [ ] Add validation to Validate in `agent/config/builder.go`.
|
||||||
|
|
Loading…
Reference in New Issue