"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pkg/anonymize/anonymize_config_test.go" between
traefik-v2.3.2.src.tar.gz and traefik-v2.3.3.src.tar.gz

About: Traefik is a cloud native edge router, a reverse proxy and load balancer for HTTP and TCP-based applications.

anonymize_config_test.go  (traefik-v2.3.2.src):anonymize_config_test.go  (traefik-v2.3.3.src)
package anonymize package anonymize
import ( import (
"flag"
"io/ioutil"
"os" "os"
"strings"
"testing" "testing"
"time" "time"
assetfs "github.com/elazarl/go-bindata-assetfs" assetfs "github.com/elazarl/go-bindata-assetfs"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
ptypes "github.com/traefik/paerser/types" ptypes "github.com/traefik/paerser/types"
"github.com/traefik/traefik/v2/pkg/config/static" "github.com/traefik/traefik/v2/pkg/config/static"
"github.com/traefik/traefik/v2/pkg/ping" "github.com/traefik/traefik/v2/pkg/ping"
"github.com/traefik/traefik/v2/pkg/plugins"
"github.com/traefik/traefik/v2/pkg/provider/acme" "github.com/traefik/traefik/v2/pkg/provider/acme"
"github.com/traefik/traefik/v2/pkg/provider/consulcatalog"
"github.com/traefik/traefik/v2/pkg/provider/docker" "github.com/traefik/traefik/v2/pkg/provider/docker"
"github.com/traefik/traefik/v2/pkg/provider/ecs"
"github.com/traefik/traefik/v2/pkg/provider/file" "github.com/traefik/traefik/v2/pkg/provider/file"
"github.com/traefik/traefik/v2/pkg/provider/http"
"github.com/traefik/traefik/v2/pkg/provider/kubernetes/crd" "github.com/traefik/traefik/v2/pkg/provider/kubernetes/crd"
"github.com/traefik/traefik/v2/pkg/provider/kubernetes/ingress" "github.com/traefik/traefik/v2/pkg/provider/kubernetes/ingress"
"github.com/traefik/traefik/v2/pkg/provider/kv"
"github.com/traefik/traefik/v2/pkg/provider/kv/consul"
"github.com/traefik/traefik/v2/pkg/provider/kv/etcd"
"github.com/traefik/traefik/v2/pkg/provider/kv/redis"
"github.com/traefik/traefik/v2/pkg/provider/kv/zk"
"github.com/traefik/traefik/v2/pkg/provider/marathon"
"github.com/traefik/traefik/v2/pkg/provider/rancher"
"github.com/traefik/traefik/v2/pkg/provider/rest"
traefiktls "github.com/traefik/traefik/v2/pkg/tls" traefiktls "github.com/traefik/traefik/v2/pkg/tls"
"github.com/traefik/traefik/v2/pkg/tracing/datadog" "github.com/traefik/traefik/v2/pkg/tracing/datadog"
"github.com/traefik/traefik/v2/pkg/tracing/elastic"
"github.com/traefik/traefik/v2/pkg/tracing/haystack" "github.com/traefik/traefik/v2/pkg/tracing/haystack"
"github.com/traefik/traefik/v2/pkg/tracing/instana" "github.com/traefik/traefik/v2/pkg/tracing/instana"
"github.com/traefik/traefik/v2/pkg/tracing/jaeger" "github.com/traefik/traefik/v2/pkg/tracing/jaeger"
"github.com/traefik/traefik/v2/pkg/tracing/zipkin" "github.com/traefik/traefik/v2/pkg/tracing/zipkin"
"github.com/traefik/traefik/v2/pkg/types" "github.com/traefik/traefik/v2/pkg/types"
) )
var updateExpected = flag.Bool("update_expected", false, "Update expected files
in fixtures")
func TestDo_globalConfiguration(t *testing.T) { func TestDo_globalConfiguration(t *testing.T) {
config := &static.Configuration{} config := &static.Configuration{}
config.Global = &static.Global{ config.Global = &static.Global{
CheckNewVersion: true, CheckNewVersion: true,
SendAnonymousUsage: true, SendAnonymousUsage: true,
} }
config.AccessLog = &types.AccessLog{ config.ServersTransport = &static.ServersTransport{
FilePath: "AccessLog FilePath", InsecureSkipVerify: true,
Format: "AccessLog Format", RootCAs: []traefiktls.FileOrContent{"root.ca"},
Filters: &types.AccessLogFilters{ MaxIdleConnsPerHost: 42,
StatusCodes: []string{"200", "500"}, ForwardingTimeouts: &static.ForwardingTimeouts{
RetryAttempts: true, DialTimeout: 42,
MinDuration: 10, ResponseHeaderTimeout: 42,
}, IdleConnTimeout: 42,
Fields: &types.AccessLogFields{
DefaultMode: "drop",
Names: map[string]string{
"RequestHost": "keep",
},
Headers: &types.FieldHeaders{
DefaultMode: "drop",
Names: map[string]string{
"Referer": "keep",
},
},
}, },
BufferingSize: 4,
}
config.Log = &types.TraefikLog{
Level: "Level",
FilePath: "/foo/path",
Format: "json",
} }
config.EntryPoints = static.EntryPoints{ config.EntryPoints = static.EntryPoints{
"foo": { "foobar": {
Address: "foo Address", Address: "foo Address",
Transport: &static.EntryPointsTransport{ Transport: &static.EntryPointsTransport{
LifeCycle: &static.LifeCycle{
RequestAcceptGraceTimeout: ptypes.Duratio
n(111 * time.Second),
GraceTimeOut: ptypes.Duratio
n(111 * time.Second),
},
RespondingTimeouts: &static.RespondingTimeouts{ RespondingTimeouts: &static.RespondingTimeouts{
ReadTimeout: ptypes.Duration(111 * time. Second), ReadTimeout: ptypes.Duration(111 * time. Second),
WriteTimeout: ptypes.Duration(111 * time. Second), WriteTimeout: ptypes.Duration(111 * time. Second),
IdleTimeout: ptypes.Duration(111 * time. Second), IdleTimeout: ptypes.Duration(111 * time. Second),
}, },
}, },
ProxyProtocol: &static.ProxyProtocol{ ProxyProtocol: &static.ProxyProtocol{
Insecure: true,
TrustedIPs: []string{"127.0.0.1/32", "192.168.0.1 "}, TrustedIPs: []string{"127.0.0.1/32", "192.168.0.1 "},
}, },
}, ForwardedHeaders: &static.ForwardedHeaders{
"fii": { Insecure: true,
Address: "fii Address",
Transport: &static.EntryPointsTransport{
RespondingTimeouts: &static.RespondingTimeouts{
ReadTimeout: ptypes.Duration(111 * time.
Second),
WriteTimeout: ptypes.Duration(111 * time.
Second),
IdleTimeout: ptypes.Duration(111 * time.
Second),
},
},
ProxyProtocol: &static.ProxyProtocol{
TrustedIPs: []string{"127.0.0.1/32", "192.168.0.1 "}, TrustedIPs: []string{"127.0.0.1/32", "192.168.0.1 "},
}, },
}, HTTP: static.HTTPConfig{
} Redirections: &static.Redirections{
config.CertificatesResolvers = map[string]static.CertificateResolver{ EntryPoint: &static.RedirectEntryPoint{
"default": { To: "foobar",
ACME: &acme.Configuration{ Scheme: "foobar",
Email: "acme Email", Permanent: true,
CAServer: "CAServer", Priority: 42,
Storage: "Storage", },
KeyType: "MyKeyType", },
DNSChallenge: &acme.DNSChallenge{Provider: "DNSPr Middlewares: []string{"foobar", "foobar"},
ovider"}, TLS: &static.TLSConfig{
HTTPChallenge: &acme.HTTPChallenge{ Options: "foobar",
EntryPoint: "MyEntryPoint", CertResolver: "foobar",
Domains: []types.Domain{
{Main: "foobar", SANs: []string{"
foobar", "foobar"}},
},
}, },
TLSChallenge: &acme.TLSChallenge{},
}, },
}, },
} }
config.Providers = &static.Providers{ config.Providers = &static.Providers{
ProvidersThrottleDuration: ptypes.Duration(111 * time.Second), ProvidersThrottleDuration: ptypes.Duration(111 * time.Second),
} }
config.ServersTransport = &static.ServersTransport{ config.ServersTransport = &static.ServersTransport{
InsecureSkipVerify: true, InsecureSkipVerify: true,
RootCAs: []traefiktls.FileOrContent{"RootCAs 1", "Roo tCAs 2", "RootCAs 3"}, RootCAs: []traefiktls.FileOrContent{"RootCAs 1", "Roo tCAs 2", "RootCAs 3"},
MaxIdleConnsPerHost: 111, MaxIdleConnsPerHost: 111,
ForwardingTimeouts: &static.ForwardingTimeouts{ ForwardingTimeouts: &static.ForwardingTimeouts{
DialTimeout: ptypes.Duration(111 * time.Second) , DialTimeout: ptypes.Duration(111 * time.Second) ,
ResponseHeaderTimeout: ptypes.Duration(111 * time.Second) , ResponseHeaderTimeout: ptypes.Duration(111 * time.Second) ,
}, IdleConnTimeout: ptypes.Duration(111 * time.Second)
} ,
config.API = &static.API{
Dashboard: true,
DashboardAssets: &assetfs.AssetFS{
Asset: func(path string) ([]byte, error) {
return nil, nil
},
AssetDir: func(path string) ([]string, error) {
return nil, nil
},
AssetInfo: func(path string) (os.FileInfo, error) {
return nil, nil
},
Prefix: "fii",
}, },
} }
config.Providers.File = &file.Provider{ config.Providers.File = &file.Provider{
Directory: "file Directory", Directory: "file Directory",
Watch: true, Watch: true,
Filename: "file Filename", Filename: "file Filename",
DebugLogGeneratedTemplate: true, DebugLogGeneratedTemplate: true,
} }
skipping to change at line 162 skipping to change at line 149
Key: "mycert.key", Key: "mycert.key",
InsecureSkipVerify: true, InsecureSkipVerify: true,
}, },
ExposedByDefault: true, ExposedByDefault: true,
UseBindPortIP: true, UseBindPortIP: true,
SwarmMode: true, SwarmMode: true,
Network: "MyNetwork", Network: "MyNetwork",
SwarmModeRefreshSeconds: 42, SwarmModeRefreshSeconds: 42,
} }
config.Providers.Marathon = &marathon.Provider{
Constraints: `Label("foo", "bar")`,
Trace: true,
Watch: true,
Endpoint: "foobar",
DefaultRule: "PathPrefix(`/`)",
ExposedByDefault: true,
DCOSToken: "foobar",
TLS: &types.ClientTLS{
CA: "myCa",
CAOptional: true,
Cert: "mycert.pem",
Key: "mycert.key",
InsecureSkipVerify: true,
},
DialerTimeout: 42,
ResponseHeaderTimeout: 42,
TLSHandshakeTimeout: 42,
KeepAlive: 42,
ForceTaskHostname: true,
Basic: &marathon.Basic{
HTTPBasicAuthUser: "user",
HTTPBasicPassword: "password",
},
RespectReadinessChecks: true,
}
config.Providers.KubernetesIngress = &ingress.Provider{ config.Providers.KubernetesIngress = &ingress.Provider{
Endpoint: "MyEndpoint", Endpoint: "MyEndpoint",
Token: "MyToken", Token: "MyToken",
CertAuthFilePath: "MyCertAuthPath", CertAuthFilePath: "MyCertAuthPath",
DisablePassHostHeaders: true, DisablePassHostHeaders: true,
Namespaces: []string{"a", "b"}, Namespaces: []string{"a", "b"},
LabelSelector: "myLabelSelector", LabelSelector: "myLabelSelector",
IngressClass: "MyIngressClass", IngressClass: "MyIngressClass",
IngressEndpoint: &ingress.EndpointIngress{
IP: "IP",
Hostname: "Hostname",
PublishedService: "PublishedService",
},
ThrottleDuration: ptypes.Duration(111 * time.Second),
} }
config.Providers.KubernetesCRD = &crd.Provider{ config.Providers.KubernetesCRD = &crd.Provider{
Endpoint: "MyEndpoint", Endpoint: "MyEndpoint",
Token: "MyToken", Token: "MyToken",
CertAuthFilePath: "MyCertAuthPath", CertAuthFilePath: "MyCertAuthPath",
DisablePassHostHeaders: true, DisablePassHostHeaders: true,
Namespaces: []string{"a", "b"}, Namespaces: []string{"a", "b"},
LabelSelector: "myLabelSelector", LabelSelector: "myLabelSelector",
IngressClass: "MyIngressClass", IngressClass: "MyIngressClass",
ThrottleDuration: ptypes.Duration(111 * time.Second),
}
config.Providers.Rest = &rest.Provider{
Insecure: true,
}
config.Providers.Rancher = &rancher.Provider{
Constraints: `Label("foo", "bar")`,
Watch: true,
DefaultRule: "PathPrefix(`/`)",
ExposedByDefault: true,
EnableServiceHealthFilter: true,
RefreshSeconds: 42,
IntervalPoll: true,
Prefix: "MyPrefix",
}
config.Providers.ConsulCatalog = &consulcatalog.Provider{
Constraints: `Label("foo", "bar")`,
Endpoint: &consulcatalog.EndpointConfig{
Address: "MyAddress",
Scheme: "MyScheme",
DataCenter: "MyDatacenter",
Token: "MyToken",
TLS: &types.ClientTLS{
CA: "myCa",
CAOptional: true,
Cert: "mycert.pem",
Key: "mycert.key",
InsecureSkipVerify: true,
},
HTTPAuth: &consulcatalog.EndpointHTTPAuthConfig{
Username: "MyUsername",
Password: "MyPassword",
},
EndpointWaitTime: 42,
},
Prefix: "MyPrefix",
RefreshInterval: 42,
RequireConsistent: true,
Stale: true,
Cache: true,
ExposedByDefault: true,
DefaultRule: "PathPrefix(`/`)",
}
config.Providers.Ecs = &ecs.Provider{
Constraints: `Label("foo", "bar")`,
ExposedByDefault: true,
RefreshSeconds: 42,
DefaultRule: "PathPrefix(`/`)",
Clusters: []string{"Cluster1", "Cluster2"},
AutoDiscoverClusters: true,
Region: "Awsregion",
AccessKeyID: "AwsAccessKeyID",
SecretAccessKey: "AwsSecretAccessKey",
}
config.Providers.Consul = &consul.Provider{
Provider: kv.Provider{
RootKey: "RootKey",
Endpoints: nil,
Username: "username",
Password: "password",
TLS: &types.ClientTLS{
CA: "myCa",
CAOptional: true,
Cert: "mycert.pem",
Key: "mycert.key",
InsecureSkipVerify: true,
},
},
} }
// FIXME Test the other providers once they are migrated config.Providers.Etcd = &etcd.Provider{
Provider: kv.Provider{
RootKey: "RootKey",
Endpoints: nil,
Username: "username",
Password: "password",
TLS: &types.ClientTLS{
CA: "myCa",
CAOptional: true,
Cert: "mycert.pem",
Key: "mycert.key",
InsecureSkipVerify: true,
},
},
}
config.Providers.ZooKeeper = &zk.Provider{
Provider: kv.Provider{
RootKey: "RootKey",
Endpoints: nil,
Username: "username",
Password: "password",
TLS: &types.ClientTLS{
CA: "myCa",
CAOptional: true,
Cert: "mycert.pem",
Key: "mycert.key",
InsecureSkipVerify: true,
},
},
}
config.Providers.Redis = &redis.Provider{
Provider: kv.Provider{
RootKey: "RootKey",
Endpoints: nil,
Username: "username",
Password: "password",
TLS: &types.ClientTLS{
CA: "myCa",
CAOptional: true,
Cert: "mycert.pem",
Key: "mycert.key",
InsecureSkipVerify: true,
},
},
}
config.Providers.HTTP = &http.Provider{
Endpoint: "Myenpoint",
PollInterval: 42,
PollTimeout: 42,
TLS: &types.ClientTLS{
CA: "myCa",
CAOptional: true,
Cert: "mycert.pem",
Key: "mycert.key",
InsecureSkipVerify: true,
},
}
config.API = &static.API{
Insecure: true,
Dashboard: true,
Debug: true,
DashboardAssets: &assetfs.AssetFS{
Asset: func(path string) ([]byte, error) {
return nil, nil
},
AssetDir: func(path string) ([]string, error) {
return nil, nil
},
AssetInfo: func(path string) (os.FileInfo, error) {
return nil, nil
},
Prefix: "fii",
},
}
config.Metrics = &types.Metrics{ config.Metrics = &types.Metrics{
Prometheus: &types.Prometheus{ Prometheus: &types.Prometheus{
Buckets: []float64{0.1, 0.3, 1.2, 5}, Buckets: []float64{0.1, 0.3, 1.2, 5},
AddEntryPointsLabels: true,
AddServicesLabels: true,
EntryPoint: "MyEntryPoint",
ManualRouting: true,
}, },
Datadog: &types.Datadog{ Datadog: &types.Datadog{
Address: "localhost:8181", Address: "localhost:8181",
PushInterval: 12, PushInterval: 42,
AddEntryPointsLabels: true,
AddServicesLabels: true,
}, },
StatsD: &types.Statsd{ StatsD: &types.Statsd{
Address: "localhost:8182", Address: "localhost:8182",
PushInterval: 42, PushInterval: 42,
AddEntryPointsLabels: true,
AddServicesLabels: true,
Prefix: "MyPrefix",
}, },
InfluxDB: &types.InfluxDB{ InfluxDB: &types.InfluxDB{
Address: "localhost:8183", Address: "localhost:8183",
Protocol: "http", Protocol: "http",
PushInterval: 22, PushInterval: 42,
Database: "myDB", Database: "myDB",
RetentionPolicy: "12", RetentionPolicy: "12",
Username: "a", Username: "a",
Password: "aaaa", Password: "aaaa",
AddEntryPointsLabels: true,
AddServicesLabels: true,
}, },
} }
config.Ping = &ping.Handler{} config.Ping = &ping.Handler{
EntryPoint: "MyEntryPoint",
ManualRouting: true,
TerminatingStatusCode: 42,
}
config.Log = &types.TraefikLog{
Level: "Level",
FilePath: "/foo/path",
Format: "json",
}
config.AccessLog = &types.AccessLog{
FilePath: "AccessLog FilePath",
Format: "AccessLog Format",
Filters: &types.AccessLogFilters{
StatusCodes: []string{"200", "500"},
RetryAttempts: true,
MinDuration: 42,
},
Fields: &types.AccessLogFields{
DefaultMode: "drop",
Names: map[string]string{
"RequestHost": "keep",
},
Headers: &types.FieldHeaders{
DefaultMode: "drop",
Names: map[string]string{
"Referer": "keep",
},
},
},
BufferingSize: 42,
}
config.Tracing = &static.Tracing{ config.Tracing = &static.Tracing{
ServiceName: "myServiceName", ServiceName: "myServiceName",
SpanNameLimit: 3, SpanNameLimit: 42,
Jaeger: &jaeger.Config{ Jaeger: &jaeger.Config{
SamplingServerURL: "aaa", SamplingServerURL: "foobar",
SamplingType: "bbb", SamplingType: "foobar",
SamplingParam: 43, SamplingParam: 42,
LocalAgentHostPort: "ccc", LocalAgentHostPort: "foobar",
Gen128Bit: true, Gen128Bit: true,
Propagation: "ddd", Propagation: "foobar",
TraceContextHeaderName: "eee", TraceContextHeaderName: "foobar",
Collector: &jaeger.Collector{
Endpoint: "foobar",
User: "foobar",
Password: "foobar",
},
DisableAttemptReconnecting: true,
}, },
Zipkin: &zipkin.Config{ Zipkin: &zipkin.Config{
HTTPEndpoint: "fff", HTTPEndpoint: "foobar",
SameSpan: true, SameSpan: true,
ID128Bit: true, ID128Bit: true,
SampleRate: 53, SampleRate: 42,
}, },
Datadog: &datadog.Config{ Datadog: &datadog.Config{
LocalAgentHostPort: "ggg", LocalAgentHostPort: "foobar",
GlobalTag: "eee", GlobalTag: "foobar",
Debug: true, Debug: true,
PrioritySampling: true, PrioritySampling: true,
TraceIDHeaderName: "foobar",
ParentIDHeaderName: "foobar",
SamplingPriorityHeaderName: "foobar",
BagagePrefixHeaderName: "foobar",
}, },
Instana: &instana.Config{ Instana: &instana.Config{
LocalAgentHost: "fff", LocalAgentHost: "foobar",
LocalAgentPort: 32, LocalAgentPort: 4242,
LogLevel: "ggg", LogLevel: "foobar",
}, },
Haystack: &haystack.Config{ Haystack: &haystack.Config{
LocalAgentHost: "fff", LocalAgentHost: "foobar",
LocalAgentPort: 32, LocalAgentPort: 42,
GlobalTag: "eee", GlobalTag: "foobar",
TraceIDHeaderName: "fff", TraceIDHeaderName: "foobar",
ParentIDHeaderName: "ggg", ParentIDHeaderName: "foobar",
SpanIDHeaderName: "hhh", SpanIDHeaderName: "foobar",
BaggagePrefixHeaderName: "iii", BaggagePrefixHeaderName: "foobar",
},
Elastic: &elastic.Config{
ServerURL: "foobar",
SecretToken: "foobar",
ServiceEnvironment: "foobar",
}, },
} }
config.HostResolver = &types.HostResolverConfig{ config.HostResolver = &types.HostResolverConfig{
CnameFlattening: true, CnameFlattening: true,
ResolvConfig: "aaa", ResolvConfig: "foobar",
ResolvDepth: 3, ResolvDepth: 42,
} }
config.CertificatesResolvers = map[string]static.CertificateResolver{
"CertificateResolver0": {
ACME: &acme.Configuration{
Email: "acme Email",
CAServer: "CAServer",
PreferredChain: "foobar",
Storage: "Storage",
KeyType: "MyKeyType",
DNSChallenge: &acme.DNSChallenge{
Provider: "DNSProvider",
DelayBeforeCheck: 42,
Resolvers: []string{"resolv
er1", "resolver2"},
DisablePropagationCheck: true,
},
HTTPChallenge: &acme.HTTPChallenge{
EntryPoint: "MyEntryPoint",
},
TLSChallenge: &acme.TLSChallenge{},
},
},
}
config.Pilot = &static.Pilot{
Token: "token",
}
config.Experimental = &static.Experimental{
Plugins: map[string]plugins.Descriptor{
"Descriptor0": {
ModuleName: "foobar",
Version: "foobar",
},
"Descriptor1": {
ModuleName: "foobar",
Version: "foobar",
},
},
DevPlugin: &plugins.DevPlugin{
GoPath: "foobar",
ModuleName: "foobar",
},
}
expectedConfiguration, err := ioutil.ReadFile("./testdata/anonymized-stat
ic-config.json")
require.NoError(t, err)
cleanJSON, err := Do(config, true) cleanJSON, err := Do(config, true)
if err != nil { require.NoError(t, err)
t.Fatal(err, cleanJSON)
if *updateExpected {
require.NoError(t, ioutil.WriteFile("testdata/anonymized-static-c
onfig.json", []byte(cleanJSON), 0666))
} }
expected := strings.TrimSuffix(string(expectedConfiguration), "\n")
assert.Equal(t, expected, cleanJSON)
} }
 End of changes. 41 change blocks. 
112 lines changed or deleted 396 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)