2022-01-24 10:08:05 +00:00
|
|
|
package redactor
|
2017-10-02 08:32:02 +00:00
|
|
|
|
|
|
|
import (
|
2020-10-30 11:44:05 +00:00
|
|
|
"flag"
|
2018-10-01 17:18:03 +00:00
|
|
|
"os"
|
2020-10-30 11:44:05 +00:00
|
|
|
"strings"
|
2017-10-02 08:32:02 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2020-10-30 11:44:05 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
2020-08-17 16:04:03 +00:00
|
|
|
ptypes "github.com/traefik/paerser/types"
|
2020-12-03 14:52:05 +00:00
|
|
|
"github.com/traefik/traefik/v2/pkg/config/dynamic"
|
2020-09-16 13:46:04 +00:00
|
|
|
"github.com/traefik/traefik/v2/pkg/config/static"
|
|
|
|
"github.com/traefik/traefik/v2/pkg/ping"
|
2020-10-30 11:44:05 +00:00
|
|
|
"github.com/traefik/traefik/v2/pkg/plugins"
|
2020-09-16 13:46:04 +00:00
|
|
|
"github.com/traefik/traefik/v2/pkg/provider/acme"
|
2020-10-30 11:44:05 +00:00
|
|
|
"github.com/traefik/traefik/v2/pkg/provider/consulcatalog"
|
2020-09-16 13:46:04 +00:00
|
|
|
"github.com/traefik/traefik/v2/pkg/provider/docker"
|
2020-10-30 11:44:05 +00:00
|
|
|
"github.com/traefik/traefik/v2/pkg/provider/ecs"
|
2020-09-16 13:46:04 +00:00
|
|
|
"github.com/traefik/traefik/v2/pkg/provider/file"
|
2020-10-30 11:44:05 +00:00
|
|
|
"github.com/traefik/traefik/v2/pkg/provider/http"
|
2020-09-16 13:46:04 +00:00
|
|
|
"github.com/traefik/traefik/v2/pkg/provider/kubernetes/crd"
|
2020-12-15 15:40:05 +00:00
|
|
|
"github.com/traefik/traefik/v2/pkg/provider/kubernetes/gateway"
|
2020-09-16 13:46:04 +00:00
|
|
|
"github.com/traefik/traefik/v2/pkg/provider/kubernetes/ingress"
|
2020-10-30 11:44:05 +00:00
|
|
|
"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"
|
2020-09-16 13:46:04 +00:00
|
|
|
traefiktls "github.com/traefik/traefik/v2/pkg/tls"
|
|
|
|
"github.com/traefik/traefik/v2/pkg/tracing/datadog"
|
2020-10-30 11:44:05 +00:00
|
|
|
"github.com/traefik/traefik/v2/pkg/tracing/elastic"
|
2020-09-16 13:46:04 +00:00
|
|
|
"github.com/traefik/traefik/v2/pkg/tracing/haystack"
|
|
|
|
"github.com/traefik/traefik/v2/pkg/tracing/instana"
|
|
|
|
"github.com/traefik/traefik/v2/pkg/tracing/jaeger"
|
|
|
|
"github.com/traefik/traefik/v2/pkg/tracing/zipkin"
|
|
|
|
"github.com/traefik/traefik/v2/pkg/types"
|
2017-10-02 08:32:02 +00:00
|
|
|
)
|
|
|
|
|
2020-10-30 11:44:05 +00:00
|
|
|
var updateExpected = flag.Bool("update_expected", false, "Update expected files in fixtures")
|
|
|
|
|
2022-01-24 10:08:05 +00:00
|
|
|
var fullDynConf *dynamic.Configuration
|
|
|
|
|
|
|
|
func init() {
|
2020-12-03 14:52:05 +00:00
|
|
|
config := &dynamic.Configuration{}
|
|
|
|
config.HTTP = &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"foo": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Middlewares: []string{"foo"},
|
|
|
|
Service: "foo",
|
|
|
|
Rule: "foo",
|
|
|
|
Priority: 42,
|
|
|
|
TLS: &dynamic.RouterTLSConfig{
|
|
|
|
Options: "foo",
|
|
|
|
CertResolver: "foo",
|
|
|
|
Domains: []types.Domain{
|
|
|
|
{
|
|
|
|
Main: "foo",
|
|
|
|
SANs: []string{"foo"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"foo": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Sticky: &dynamic.Sticky{
|
|
|
|
Cookie: &dynamic.Cookie{
|
|
|
|
Name: "foo",
|
|
|
|
Secure: true,
|
|
|
|
HTTPOnly: true,
|
|
|
|
SameSite: "foo",
|
|
|
|
},
|
|
|
|
},
|
2021-06-25 19:08:11 +00:00
|
|
|
HealthCheck: &dynamic.ServerHealthCheck{
|
2020-12-03 14:52:05 +00:00
|
|
|
Scheme: "foo",
|
|
|
|
Path: "foo",
|
|
|
|
Port: 42,
|
2022-11-16 10:38:07 +00:00
|
|
|
Interval: ptypes.Duration(111 * time.Second),
|
|
|
|
Timeout: ptypes.Duration(111 * time.Second),
|
2020-12-03 14:52:05 +00:00
|
|
|
Hostname: "foo",
|
|
|
|
FollowRedirects: boolPtr(true),
|
|
|
|
Headers: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: boolPtr(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
2022-11-16 10:38:07 +00:00
|
|
|
FlushInterval: ptypes.Duration(111 * time.Second),
|
2020-12-03 14:52:05 +00:00
|
|
|
},
|
|
|
|
ServersTransport: "foo",
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://127.0.0.1:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"bar": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Weight: intPtr(42),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Sticky: &dynamic.Sticky{
|
|
|
|
Cookie: &dynamic.Cookie{
|
|
|
|
Name: "foo",
|
|
|
|
Secure: true,
|
|
|
|
HTTPOnly: true,
|
|
|
|
SameSite: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"baz": {
|
|
|
|
Mirroring: &dynamic.Mirroring{
|
|
|
|
Service: "foo",
|
|
|
|
MaxBodySize: int64Ptr(42),
|
|
|
|
Mirrors: []dynamic.MirrorService{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Percent: 42,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{
|
|
|
|
"foo": {
|
|
|
|
ServerName: "foo",
|
|
|
|
InsecureSkipVerify: true,
|
|
|
|
RootCAs: []traefiktls.FileOrContent{"rootca.pem"},
|
|
|
|
Certificates: []traefiktls.Certificate{
|
|
|
|
{
|
|
|
|
CertFile: "cert.pem",
|
|
|
|
KeyFile: "key.pem",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
MaxIdleConnsPerHost: 42,
|
|
|
|
ForwardingTimeouts: &dynamic.ForwardingTimeouts{
|
|
|
|
DialTimeout: 42,
|
|
|
|
ResponseHeaderTimeout: 42,
|
|
|
|
IdleConnTimeout: 42,
|
2021-11-09 11:16:08 +00:00
|
|
|
ReadIdleTimeout: 42,
|
|
|
|
PingTimeout: 42,
|
2020-12-03 14:52:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Models: map[string]*dynamic.Model{
|
|
|
|
"foo": {
|
|
|
|
Middlewares: []string{"foo"},
|
|
|
|
TLS: &dynamic.RouterTLSConfig{
|
|
|
|
Options: "foo",
|
|
|
|
CertResolver: "foo",
|
|
|
|
Domains: []types.Domain{
|
|
|
|
{
|
|
|
|
Main: "foo",
|
|
|
|
SANs: []string{"foo"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
|
|
|
"foo": {
|
|
|
|
AddPrefix: &dynamic.AddPrefix{
|
|
|
|
Prefix: "foo",
|
|
|
|
},
|
|
|
|
StripPrefix: &dynamic.StripPrefix{
|
|
|
|
Prefixes: []string{"foo"},
|
|
|
|
ForceSlash: true,
|
|
|
|
},
|
|
|
|
StripPrefixRegex: &dynamic.StripPrefixRegex{
|
|
|
|
Regex: []string{"foo"},
|
|
|
|
},
|
|
|
|
ReplacePath: &dynamic.ReplacePath{
|
|
|
|
Path: "foo",
|
|
|
|
},
|
|
|
|
ReplacePathRegex: &dynamic.ReplacePathRegex{
|
|
|
|
Regex: "foo",
|
|
|
|
Replacement: "foo",
|
|
|
|
},
|
|
|
|
Chain: &dynamic.Chain{
|
|
|
|
Middlewares: []string{"foo"},
|
|
|
|
},
|
2022-10-26 15:16:05 +00:00
|
|
|
IPAllowList: &dynamic.IPAllowList{
|
2020-12-03 14:52:05 +00:00
|
|
|
SourceRange: []string{"foo"},
|
|
|
|
IPStrategy: &dynamic.IPStrategy{
|
|
|
|
Depth: 42,
|
|
|
|
ExcludedIPs: []string{"127.0.0.1"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Headers: &dynamic.Headers{
|
|
|
|
CustomRequestHeaders: map[string]string{"foo": "bar"},
|
|
|
|
CustomResponseHeaders: map[string]string{"foo": "bar"},
|
|
|
|
AccessControlAllowCredentials: true,
|
|
|
|
AccessControlAllowHeaders: []string{"foo"},
|
|
|
|
AccessControlAllowMethods: []string{"foo"},
|
|
|
|
AccessControlAllowOriginList: []string{"foo"},
|
|
|
|
AccessControlAllowOriginListRegex: []string{"foo"},
|
|
|
|
AccessControlExposeHeaders: []string{"foo"},
|
|
|
|
AccessControlMaxAge: 42,
|
|
|
|
AddVaryHeader: true,
|
|
|
|
AllowedHosts: []string{"foo"},
|
|
|
|
HostsProxyHeaders: []string{"foo"},
|
|
|
|
SSLRedirect: true,
|
|
|
|
SSLTemporaryRedirect: true,
|
|
|
|
SSLHost: "foo",
|
|
|
|
SSLProxyHeaders: map[string]string{"foo": "bar"},
|
|
|
|
SSLForceHost: true,
|
|
|
|
STSSeconds: 42,
|
|
|
|
STSIncludeSubdomains: true,
|
|
|
|
STSPreload: true,
|
|
|
|
ForceSTSHeader: true,
|
|
|
|
FrameDeny: true,
|
|
|
|
CustomFrameOptionsValue: "foo",
|
|
|
|
ContentTypeNosniff: true,
|
|
|
|
BrowserXSSFilter: true,
|
|
|
|
CustomBrowserXSSValue: "foo",
|
|
|
|
ContentSecurityPolicy: "foo",
|
|
|
|
PublicKey: "foo",
|
|
|
|
ReferrerPolicy: "foo",
|
|
|
|
FeaturePolicy: "foo",
|
2021-06-21 13:16:13 +00:00
|
|
|
PermissionsPolicy: "foo",
|
2020-12-03 14:52:05 +00:00
|
|
|
IsDevelopment: true,
|
|
|
|
},
|
|
|
|
Errors: &dynamic.ErrorPage{
|
|
|
|
Status: []string{"foo"},
|
|
|
|
Service: "foo",
|
|
|
|
Query: "foo",
|
|
|
|
},
|
|
|
|
RateLimit: &dynamic.RateLimit{
|
|
|
|
Average: 42,
|
|
|
|
Period: 42,
|
|
|
|
Burst: 42,
|
|
|
|
SourceCriterion: &dynamic.SourceCriterion{
|
|
|
|
IPStrategy: &dynamic.IPStrategy{
|
|
|
|
Depth: 42,
|
2022-01-24 10:08:05 +00:00
|
|
|
ExcludedIPs: []string{"127.0.0.1"},
|
2020-12-03 14:52:05 +00:00
|
|
|
},
|
|
|
|
RequestHeaderName: "foo",
|
|
|
|
RequestHost: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
RedirectRegex: &dynamic.RedirectRegex{
|
|
|
|
Regex: "foo",
|
|
|
|
Replacement: "foo",
|
|
|
|
Permanent: true,
|
|
|
|
},
|
|
|
|
RedirectScheme: &dynamic.RedirectScheme{
|
|
|
|
Scheme: "foo",
|
|
|
|
Port: "foo",
|
|
|
|
Permanent: true,
|
|
|
|
},
|
|
|
|
BasicAuth: &dynamic.BasicAuth{
|
|
|
|
Users: []string{"foo"},
|
|
|
|
UsersFile: "foo",
|
|
|
|
Realm: "foo",
|
|
|
|
RemoveHeader: true,
|
|
|
|
HeaderField: "foo",
|
|
|
|
},
|
|
|
|
DigestAuth: &dynamic.DigestAuth{
|
|
|
|
Users: []string{"foo"},
|
|
|
|
UsersFile: "foo",
|
|
|
|
RemoveHeader: true,
|
|
|
|
Realm: "foo",
|
|
|
|
HeaderField: "foo",
|
|
|
|
},
|
|
|
|
ForwardAuth: &dynamic.ForwardAuth{
|
|
|
|
Address: "127.0.0.1",
|
2021-10-26 08:54:11 +00:00
|
|
|
TLS: &types.ClientTLS{
|
2020-12-03 14:52:05 +00:00
|
|
|
CA: "ca.pem",
|
|
|
|
CAOptional: true,
|
|
|
|
Cert: "cert.pem",
|
|
|
|
Key: "cert.pem",
|
|
|
|
InsecureSkipVerify: true,
|
|
|
|
},
|
|
|
|
TrustForwardHeader: true,
|
|
|
|
AuthResponseHeaders: []string{"foo"},
|
|
|
|
AuthResponseHeadersRegex: "foo",
|
|
|
|
AuthRequestHeaders: []string{"foo"},
|
|
|
|
},
|
|
|
|
InFlightReq: &dynamic.InFlightReq{
|
|
|
|
Amount: 42,
|
|
|
|
SourceCriterion: &dynamic.SourceCriterion{
|
|
|
|
IPStrategy: &dynamic.IPStrategy{
|
|
|
|
Depth: 42,
|
2022-01-24 10:08:05 +00:00
|
|
|
ExcludedIPs: []string{"127.0.0.1"},
|
2020-12-03 14:52:05 +00:00
|
|
|
},
|
|
|
|
RequestHeaderName: "foo",
|
|
|
|
RequestHost: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Buffering: &dynamic.Buffering{
|
|
|
|
MaxRequestBodyBytes: 42,
|
|
|
|
MemRequestBodyBytes: 42,
|
|
|
|
MaxResponseBodyBytes: 42,
|
|
|
|
MemResponseBodyBytes: 42,
|
|
|
|
RetryExpression: "foo",
|
|
|
|
},
|
|
|
|
CircuitBreaker: &dynamic.CircuitBreaker{
|
|
|
|
Expression: "foo",
|
|
|
|
},
|
|
|
|
Compress: &dynamic.Compress{
|
|
|
|
ExcludedContentTypes: []string{"foo"},
|
|
|
|
},
|
|
|
|
PassTLSClientCert: &dynamic.PassTLSClientCert{
|
|
|
|
PEM: true,
|
|
|
|
Info: &dynamic.TLSClientCertificateInfo{
|
|
|
|
NotAfter: true,
|
|
|
|
NotBefore: true,
|
|
|
|
Sans: true,
|
2021-11-08 21:41:43 +00:00
|
|
|
Subject: &dynamic.TLSClientCertificateSubjectDNInfo{
|
2021-07-28 15:42:09 +00:00
|
|
|
Country: true,
|
|
|
|
Province: true,
|
|
|
|
Locality: true,
|
|
|
|
Organization: true,
|
|
|
|
OrganizationalUnit: true,
|
|
|
|
CommonName: true,
|
|
|
|
SerialNumber: true,
|
|
|
|
DomainComponent: true,
|
2020-12-03 14:52:05 +00:00
|
|
|
},
|
2021-11-08 21:41:43 +00:00
|
|
|
Issuer: &dynamic.TLSClientCertificateIssuerDNInfo{
|
2020-12-03 14:52:05 +00:00
|
|
|
Country: true,
|
|
|
|
Province: true,
|
|
|
|
Locality: true,
|
|
|
|
Organization: true,
|
|
|
|
CommonName: true,
|
|
|
|
SerialNumber: true,
|
|
|
|
DomainComponent: true,
|
|
|
|
},
|
|
|
|
SerialNumber: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Retry: &dynamic.Retry{
|
|
|
|
Attempts: 42,
|
|
|
|
InitialInterval: 42,
|
|
|
|
},
|
|
|
|
ContentType: &dynamic.ContentType{
|
|
|
|
AutoDetect: true,
|
|
|
|
},
|
|
|
|
Plugin: map[string]dynamic.PluginConf{
|
|
|
|
"foo": {
|
|
|
|
"answer": struct{ Answer int }{
|
|
|
|
Answer: 42,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
config.TCP = &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"foo": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "foo",
|
|
|
|
Rule: "foo",
|
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
|
|
|
Passthrough: true,
|
|
|
|
Options: "foo",
|
|
|
|
CertResolver: "foo",
|
|
|
|
Domains: []types.Domain{
|
|
|
|
{
|
|
|
|
Main: "foo",
|
|
|
|
SANs: []string{"foo"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"foo": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
TerminationDelay: intPtr(42),
|
|
|
|
ProxyProtocol: &dynamic.ProxyProtocol{
|
|
|
|
Version: 42,
|
|
|
|
},
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "127.0.0.1:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"bar": {
|
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Weight: intPtr(42),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
config.UDP = &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"foo": {
|
|
|
|
EntryPoints: []string{"foo"},
|
|
|
|
Service: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{
|
|
|
|
"foo": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "127.0.0.1:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"bar": {
|
|
|
|
Weighted: &dynamic.UDPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.UDPWRRService{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Weight: intPtr(42),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
config.TLS = &dynamic.TLSConfiguration{
|
|
|
|
Options: map[string]traefiktls.Options{
|
|
|
|
"foo": {
|
|
|
|
MinVersion: "foo",
|
|
|
|
MaxVersion: "foo",
|
|
|
|
CipherSuites: []string{"foo"},
|
|
|
|
CurvePreferences: []string{"foo"},
|
|
|
|
ClientAuth: traefiktls.ClientAuth{
|
|
|
|
CAFiles: []traefiktls.FileOrContent{"ca.pem"},
|
|
|
|
ClientAuthType: "RequireAndVerifyClientCert",
|
|
|
|
},
|
2022-08-09 15:36:08 +00:00
|
|
|
SniStrict: true,
|
2020-12-03 14:52:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Certificates: []*traefiktls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: traefiktls.Certificate{
|
|
|
|
CertFile: "cert.pem",
|
|
|
|
KeyFile: "key.pem",
|
|
|
|
},
|
|
|
|
Stores: []string{"foo"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Stores: map[string]traefiktls.Store{
|
|
|
|
"foo": {
|
|
|
|
DefaultCertificate: &traefiktls.Certificate{
|
|
|
|
CertFile: "cert.pem",
|
|
|
|
KeyFile: "key.pem",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-01-24 10:08:05 +00:00
|
|
|
fullDynConf = config
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAnonymize_dynamicConfiguration(t *testing.T) {
|
|
|
|
config := fullDynConf
|
|
|
|
|
2021-03-04 19:08:03 +00:00
|
|
|
expectedConfiguration, err := os.ReadFile("./testdata/anonymized-dynamic-config.json")
|
2020-12-03 14:52:05 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-01-24 10:08:05 +00:00
|
|
|
cleanJSON, err := anonymize(config, true)
|
2020-12-03 14:52:05 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
if *updateExpected {
|
2021-09-16 07:16:07 +00:00
|
|
|
require.NoError(t, os.WriteFile("testdata/anonymized-dynamic-config.json", []byte(cleanJSON), 0o666))
|
2020-12-03 14:52:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
expected := strings.TrimSuffix(string(expectedConfiguration), "\n")
|
|
|
|
assert.Equal(t, expected, cleanJSON)
|
|
|
|
}
|
|
|
|
|
2022-01-24 10:08:05 +00:00
|
|
|
func TestSecure_dynamicConfiguration(t *testing.T) {
|
|
|
|
config := fullDynConf
|
|
|
|
|
|
|
|
expectedConfiguration, err := os.ReadFile("./testdata/secured-dynamic-config.json")
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
cleanJSON, err := removeCredentials(config, true)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
if *updateExpected {
|
|
|
|
require.NoError(t, os.WriteFile("testdata/secured-dynamic-config.json", []byte(cleanJSON), 0o666))
|
|
|
|
}
|
|
|
|
|
|
|
|
expected := strings.TrimSuffix(string(expectedConfiguration), "\n")
|
|
|
|
assert.Equal(t, expected, cleanJSON)
|
|
|
|
}
|
|
|
|
|
2020-12-03 14:52:05 +00:00
|
|
|
func TestDo_staticConfiguration(t *testing.T) {
|
2018-11-27 16:42:04 +00:00
|
|
|
config := &static.Configuration{}
|
2017-10-02 08:32:02 +00:00
|
|
|
|
2018-11-27 16:42:04 +00:00
|
|
|
config.Global = &static.Global{
|
|
|
|
CheckNewVersion: true,
|
2019-09-16 15:26:06 +00:00
|
|
|
SendAnonymousUsage: true,
|
2018-11-27 16:42:04 +00:00
|
|
|
}
|
2019-03-14 18:32:03 +00:00
|
|
|
|
2020-10-30 11:44:05 +00:00
|
|
|
config.ServersTransport = &static.ServersTransport{
|
|
|
|
InsecureSkipVerify: true,
|
|
|
|
RootCAs: []traefiktls.FileOrContent{"root.ca"},
|
|
|
|
MaxIdleConnsPerHost: 42,
|
|
|
|
ForwardingTimeouts: &static.ForwardingTimeouts{
|
|
|
|
DialTimeout: 42,
|
|
|
|
ResponseHeaderTimeout: 42,
|
|
|
|
IdleConnTimeout: 42,
|
2019-03-14 18:32:03 +00:00
|
|
|
},
|
2018-11-27 16:42:04 +00:00
|
|
|
}
|
2019-03-14 18:32:03 +00:00
|
|
|
|
2018-11-27 16:42:04 +00:00
|
|
|
config.EntryPoints = static.EntryPoints{
|
2020-10-30 11:44:05 +00:00
|
|
|
"foobar": {
|
2017-10-02 08:32:02 +00:00
|
|
|
Address: "foo Address",
|
2018-11-27 16:42:04 +00:00
|
|
|
Transport: &static.EntryPointsTransport{
|
2020-10-30 11:44:05 +00:00
|
|
|
LifeCycle: &static.LifeCycle{
|
|
|
|
RequestAcceptGraceTimeout: ptypes.Duration(111 * time.Second),
|
|
|
|
GraceTimeOut: ptypes.Duration(111 * time.Second),
|
|
|
|
},
|
2018-11-27 16:42:04 +00:00
|
|
|
RespondingTimeouts: &static.RespondingTimeouts{
|
2020-08-17 16:04:03 +00:00
|
|
|
ReadTimeout: ptypes.Duration(111 * time.Second),
|
|
|
|
WriteTimeout: ptypes.Duration(111 * time.Second),
|
|
|
|
IdleTimeout: ptypes.Duration(111 * time.Second),
|
2018-11-27 16:42:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
ProxyProtocol: &static.ProxyProtocol{
|
2020-10-30 11:44:05 +00:00
|
|
|
Insecure: true,
|
2017-10-10 12:50:03 +00:00
|
|
|
TrustedIPs: []string{"127.0.0.1/32", "192.168.0.1"},
|
|
|
|
},
|
2020-10-30 11:44:05 +00:00
|
|
|
ForwardedHeaders: &static.ForwardedHeaders{
|
|
|
|
Insecure: true,
|
2017-10-10 12:50:03 +00:00
|
|
|
TrustedIPs: []string{"127.0.0.1/32", "192.168.0.1"},
|
|
|
|
},
|
2020-10-30 11:44:05 +00:00
|
|
|
HTTP: static.HTTPConfig{
|
|
|
|
Redirections: &static.Redirections{
|
|
|
|
EntryPoint: &static.RedirectEntryPoint{
|
|
|
|
To: "foobar",
|
|
|
|
Scheme: "foobar",
|
|
|
|
Permanent: true,
|
|
|
|
Priority: 42,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: []string{"foobar", "foobar"},
|
|
|
|
TLS: &static.TLSConfig{
|
|
|
|
Options: "foobar",
|
|
|
|
CertResolver: "foobar",
|
|
|
|
Domains: []types.Domain{
|
|
|
|
{Main: "foobar", SANs: []string{"foobar", "foobar"}},
|
|
|
|
},
|
2019-07-19 09:52:04 +00:00
|
|
|
},
|
2017-10-02 08:32:02 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2020-10-30 11:44:05 +00:00
|
|
|
|
2018-11-27 16:42:04 +00:00
|
|
|
config.Providers = &static.Providers{
|
2020-08-17 16:04:03 +00:00
|
|
|
ProvidersThrottleDuration: ptypes.Duration(111 * time.Second),
|
2017-10-02 08:32:02 +00:00
|
|
|
}
|
2018-11-27 16:42:04 +00:00
|
|
|
|
|
|
|
config.ServersTransport = &static.ServersTransport{
|
|
|
|
InsecureSkipVerify: true,
|
2019-06-17 09:48:05 +00:00
|
|
|
RootCAs: []traefiktls.FileOrContent{"RootCAs 1", "RootCAs 2", "RootCAs 3"},
|
2018-11-27 16:42:04 +00:00
|
|
|
MaxIdleConnsPerHost: 111,
|
|
|
|
ForwardingTimeouts: &static.ForwardingTimeouts{
|
2020-08-17 16:04:03 +00:00
|
|
|
DialTimeout: ptypes.Duration(111 * time.Second),
|
|
|
|
ResponseHeaderTimeout: ptypes.Duration(111 * time.Second),
|
2020-10-30 11:44:05 +00:00
|
|
|
IdleConnTimeout: ptypes.Duration(111 * time.Second),
|
2018-10-01 17:18:03 +00:00
|
|
|
},
|
|
|
|
}
|
2018-11-27 16:42:04 +00:00
|
|
|
|
|
|
|
config.Providers.File = &file.Provider{
|
2019-03-27 14:02:06 +00:00
|
|
|
Directory: "file Directory",
|
|
|
|
Watch: true,
|
|
|
|
Filename: "file Filename",
|
|
|
|
DebugLogGeneratedTemplate: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
config.Providers.Docker = &docker.Provider{
|
2019-06-21 07:24:04 +00:00
|
|
|
Constraints: `Label("foo", "bar")`,
|
2019-03-27 14:02:06 +00:00
|
|
|
Watch: true,
|
2019-03-14 18:32:03 +00:00
|
|
|
Endpoint: "MyEndPoint",
|
|
|
|
DefaultRule: "PathPrefix(`/`)",
|
|
|
|
TLS: &types.ClientTLS{
|
|
|
|
CA: "myCa",
|
|
|
|
CAOptional: true,
|
|
|
|
Cert: "mycert.pem",
|
|
|
|
Key: "mycert.key",
|
|
|
|
InsecureSkipVerify: true,
|
|
|
|
},
|
|
|
|
ExposedByDefault: true,
|
|
|
|
UseBindPortIP: true,
|
|
|
|
SwarmMode: true,
|
|
|
|
Network: "MyNetwork",
|
|
|
|
SwarmModeRefreshSeconds: 42,
|
2020-08-28 08:02:03 +00:00
|
|
|
HTTPClientTimeout: 42,
|
2019-03-14 18:32:03 +00:00
|
|
|
}
|
|
|
|
|
2020-10-30 11:44:05 +00:00
|
|
|
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,
|
|
|
|
}
|
|
|
|
|
2019-07-08 19:36:03 +00:00
|
|
|
config.Providers.KubernetesIngress = &ingress.Provider{
|
2020-12-15 15:40:05 +00:00
|
|
|
Endpoint: "MyEndpoint",
|
|
|
|
Token: "MyToken",
|
|
|
|
CertAuthFilePath: "MyCertAuthPath",
|
|
|
|
Namespaces: []string{"a", "b"},
|
|
|
|
LabelSelector: "myLabelSelector",
|
|
|
|
IngressClass: "MyIngressClass",
|
2020-10-30 11:44:05 +00:00
|
|
|
IngressEndpoint: &ingress.EndpointIngress{
|
|
|
|
IP: "IP",
|
|
|
|
Hostname: "Hostname",
|
|
|
|
PublishedService: "PublishedService",
|
|
|
|
},
|
|
|
|
ThrottleDuration: ptypes.Duration(111 * time.Second),
|
2019-03-14 18:32:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
config.Providers.KubernetesCRD = &crd.Provider{
|
2020-12-15 15:40:05 +00:00
|
|
|
Endpoint: "MyEndpoint",
|
|
|
|
Token: "MyToken",
|
|
|
|
CertAuthFilePath: "MyCertAuthPath",
|
|
|
|
Namespaces: []string{"a", "b"},
|
|
|
|
LabelSelector: "myLabelSelector",
|
|
|
|
IngressClass: "MyIngressClass",
|
|
|
|
ThrottleDuration: ptypes.Duration(111 * time.Second),
|
|
|
|
}
|
|
|
|
|
|
|
|
config.Providers.KubernetesGateway = &gateway.Provider{
|
|
|
|
Endpoint: "MyEndpoint",
|
|
|
|
Token: "MyToken",
|
|
|
|
CertAuthFilePath: "MyCertAuthPath",
|
|
|
|
Namespaces: []string{"a", "b"},
|
|
|
|
LabelSelector: "myLabelSelector",
|
|
|
|
ThrottleDuration: ptypes.Duration(111 * time.Second),
|
2020-10-30 11:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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",
|
2019-03-14 18:32:03 +00:00
|
|
|
}
|
|
|
|
|
2022-06-03 10:00:09 +00:00
|
|
|
config.Providers.ConsulCatalog = &consulcatalog.ProviderBuilder{
|
|
|
|
Configuration: consulcatalog.Configuration{
|
|
|
|
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,
|
2020-10-30 11:44:05 +00:00
|
|
|
},
|
2022-06-03 10:00:09 +00:00
|
|
|
Prefix: "MyPrefix",
|
|
|
|
RefreshInterval: 42,
|
|
|
|
RequireConsistent: true,
|
|
|
|
Stale: true,
|
|
|
|
Cache: true,
|
|
|
|
ExposedByDefault: true,
|
|
|
|
DefaultRule: "PathPrefix(`/`)",
|
2020-10-30 11:44:05 +00:00
|
|
|
},
|
2022-06-03 10:00:09 +00:00
|
|
|
Namespace: "ns",
|
|
|
|
Namespaces: []string{"ns1", "ns2"},
|
2020-10-30 11:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
config.Providers.Ecs = &ecs.Provider{
|
|
|
|
Constraints: `Label("foo", "bar")`,
|
|
|
|
ExposedByDefault: true,
|
|
|
|
RefreshSeconds: 42,
|
|
|
|
DefaultRule: "PathPrefix(`/`)",
|
|
|
|
Clusters: []string{"Cluster1", "Cluster2"},
|
|
|
|
AutoDiscoverClusters: true,
|
2022-09-14 14:22:08 +00:00
|
|
|
ECSAnywhere: true,
|
2020-10-30 11:44:05 +00:00
|
|
|
Region: "Awsregion",
|
|
|
|
AccessKeyID: "AwsAccessKeyID",
|
|
|
|
SecretAccessKey: "AwsSecretAccessKey",
|
|
|
|
}
|
|
|
|
|
2022-06-03 10:00:09 +00:00
|
|
|
config.Providers.Consul = &consul.ProviderBuilder{
|
2020-10-30 11:44:05 +00:00
|
|
|
Provider: kv.Provider{
|
|
|
|
RootKey: "RootKey",
|
|
|
|
Endpoints: nil,
|
2022-09-12 15:40:09 +00:00
|
|
|
},
|
|
|
|
Token: "secret",
|
|
|
|
TLS: &types.ClientTLS{
|
|
|
|
CA: "myCa",
|
|
|
|
CAOptional: true,
|
|
|
|
Cert: "mycert.pem",
|
|
|
|
Key: "mycert.key",
|
|
|
|
InsecureSkipVerify: true,
|
2020-10-30 11:44:05 +00:00
|
|
|
},
|
2022-06-03 10:00:09 +00:00
|
|
|
Namespace: "ns",
|
|
|
|
Namespaces: []string{"ns1", "ns2"},
|
2020-10-30 11:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
config.Providers.Etcd = &etcd.Provider{
|
|
|
|
Provider: kv.Provider{
|
|
|
|
RootKey: "RootKey",
|
|
|
|
Endpoints: nil,
|
2022-09-12 15:40:09 +00:00
|
|
|
},
|
|
|
|
Username: "username",
|
|
|
|
Password: "password",
|
|
|
|
TLS: &types.ClientTLS{
|
|
|
|
CA: "myCa",
|
|
|
|
CAOptional: true,
|
|
|
|
Cert: "mycert.pem",
|
|
|
|
Key: "mycert.key",
|
|
|
|
InsecureSkipVerify: true,
|
2020-10-30 11:44:05 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
config.Providers.ZooKeeper = &zk.Provider{
|
|
|
|
Provider: kv.Provider{
|
|
|
|
RootKey: "RootKey",
|
|
|
|
Endpoints: nil,
|
|
|
|
},
|
2022-09-12 15:40:09 +00:00
|
|
|
Username: "username",
|
|
|
|
Password: "password",
|
2020-10-30 11:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
config.Providers.Redis = &redis.Provider{
|
|
|
|
Provider: kv.Provider{
|
|
|
|
RootKey: "RootKey",
|
|
|
|
Endpoints: nil,
|
2022-09-12 15:40:09 +00:00
|
|
|
},
|
|
|
|
Username: "username",
|
|
|
|
Password: "password",
|
|
|
|
TLS: &types.ClientTLS{
|
|
|
|
CA: "myCa",
|
|
|
|
CAOptional: true,
|
|
|
|
Cert: "mycert.pem",
|
|
|
|
Key: "mycert.key",
|
|
|
|
InsecureSkipVerify: true,
|
2020-10-30 11:44:05 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
}
|
2017-10-02 08:32:02 +00:00
|
|
|
|
2019-03-14 18:32:03 +00:00
|
|
|
config.Metrics = &types.Metrics{
|
|
|
|
Prometheus: &types.Prometheus{
|
2020-10-30 11:44:05 +00:00
|
|
|
Buckets: []float64{0.1, 0.3, 1.2, 5},
|
|
|
|
AddEntryPointsLabels: true,
|
|
|
|
AddServicesLabels: true,
|
|
|
|
EntryPoint: "MyEntryPoint",
|
|
|
|
ManualRouting: true,
|
2019-03-14 18:32:03 +00:00
|
|
|
},
|
2019-09-02 10:18:04 +00:00
|
|
|
Datadog: &types.Datadog{
|
2020-10-30 11:44:05 +00:00
|
|
|
Address: "localhost:8181",
|
|
|
|
PushInterval: 42,
|
|
|
|
AddEntryPointsLabels: true,
|
|
|
|
AddServicesLabels: true,
|
2019-03-14 18:32:03 +00:00
|
|
|
},
|
|
|
|
StatsD: &types.Statsd{
|
2020-10-30 11:44:05 +00:00
|
|
|
Address: "localhost:8182",
|
|
|
|
PushInterval: 42,
|
|
|
|
AddEntryPointsLabels: true,
|
|
|
|
AddServicesLabels: true,
|
|
|
|
Prefix: "MyPrefix",
|
2019-03-14 18:32:03 +00:00
|
|
|
},
|
|
|
|
InfluxDB: &types.InfluxDB{
|
2020-10-30 11:44:05 +00:00
|
|
|
Address: "localhost:8183",
|
|
|
|
Protocol: "http",
|
|
|
|
PushInterval: 42,
|
|
|
|
Database: "myDB",
|
|
|
|
RetentionPolicy: "12",
|
|
|
|
Username: "a",
|
|
|
|
Password: "aaaa",
|
|
|
|
AddEntryPointsLabels: true,
|
|
|
|
AddServicesLabels: true,
|
2019-03-14 18:32:03 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-10-30 11:44:05 +00:00
|
|
|
config.Ping = &ping.Handler{
|
|
|
|
EntryPoint: "MyEntryPoint",
|
|
|
|
ManualRouting: true,
|
|
|
|
TerminatingStatusCode: 42,
|
|
|
|
}
|
|
|
|
|
|
|
|
config.Log = &types.TraefikLog{
|
2022-11-21 17:36:05 +00:00
|
|
|
Level: "Level",
|
|
|
|
Format: "json",
|
|
|
|
FilePath: "/foo/path",
|
|
|
|
MaxSize: 5,
|
|
|
|
MaxAge: 3,
|
|
|
|
MaxBackups: 4,
|
|
|
|
Compress: true,
|
2020-10-30 11:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
}
|
2019-03-14 18:32:03 +00:00
|
|
|
|
|
|
|
config.Tracing = &static.Tracing{
|
|
|
|
ServiceName: "myServiceName",
|
2020-10-30 11:44:05 +00:00
|
|
|
SpanNameLimit: 42,
|
2019-03-14 18:32:03 +00:00
|
|
|
Jaeger: &jaeger.Config{
|
2020-10-30 11:44:05 +00:00
|
|
|
SamplingServerURL: "foobar",
|
|
|
|
SamplingType: "foobar",
|
|
|
|
SamplingParam: 42,
|
|
|
|
LocalAgentHostPort: "foobar",
|
2019-03-14 18:32:03 +00:00
|
|
|
Gen128Bit: true,
|
2020-10-30 11:44:05 +00:00
|
|
|
Propagation: "foobar",
|
|
|
|
TraceContextHeaderName: "foobar",
|
|
|
|
Collector: &jaeger.Collector{
|
|
|
|
Endpoint: "foobar",
|
|
|
|
User: "foobar",
|
|
|
|
Password: "foobar",
|
|
|
|
},
|
|
|
|
DisableAttemptReconnecting: true,
|
2019-03-14 18:32:03 +00:00
|
|
|
},
|
|
|
|
Zipkin: &zipkin.Config{
|
2020-10-30 11:44:05 +00:00
|
|
|
HTTPEndpoint: "foobar",
|
2019-03-14 18:32:03 +00:00
|
|
|
SameSpan: true,
|
|
|
|
ID128Bit: true,
|
2020-10-30 11:44:05 +00:00
|
|
|
SampleRate: 42,
|
2019-03-14 18:32:03 +00:00
|
|
|
},
|
2019-09-02 10:18:04 +00:00
|
|
|
Datadog: &datadog.Config{
|
2020-10-30 11:44:05 +00:00
|
|
|
LocalAgentHostPort: "foobar",
|
|
|
|
GlobalTag: "foobar",
|
|
|
|
Debug: true,
|
|
|
|
PrioritySampling: true,
|
|
|
|
TraceIDHeaderName: "foobar",
|
|
|
|
ParentIDHeaderName: "foobar",
|
|
|
|
SamplingPriorityHeaderName: "foobar",
|
|
|
|
BagagePrefixHeaderName: "foobar",
|
2019-03-14 18:32:03 +00:00
|
|
|
},
|
|
|
|
Instana: &instana.Config{
|
2020-10-30 11:44:05 +00:00
|
|
|
LocalAgentHost: "foobar",
|
|
|
|
LocalAgentPort: 4242,
|
|
|
|
LogLevel: "foobar",
|
2019-03-14 18:32:03 +00:00
|
|
|
},
|
2019-06-27 22:16:04 +00:00
|
|
|
Haystack: &haystack.Config{
|
2020-10-30 11:44:05 +00:00
|
|
|
LocalAgentHost: "foobar",
|
|
|
|
LocalAgentPort: 42,
|
|
|
|
GlobalTag: "foobar",
|
|
|
|
TraceIDHeaderName: "foobar",
|
|
|
|
ParentIDHeaderName: "foobar",
|
|
|
|
SpanIDHeaderName: "foobar",
|
|
|
|
BaggagePrefixHeaderName: "foobar",
|
|
|
|
},
|
|
|
|
Elastic: &elastic.Config{
|
|
|
|
ServerURL: "foobar",
|
|
|
|
SecretToken: "foobar",
|
|
|
|
ServiceEnvironment: "foobar",
|
2019-06-27 22:16:04 +00:00
|
|
|
},
|
2019-03-14 18:32:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
config.HostResolver = &types.HostResolverConfig{
|
|
|
|
CnameFlattening: true,
|
2020-10-30 11:44:05 +00:00
|
|
|
ResolvConfig: "foobar",
|
|
|
|
ResolvDepth: 42,
|
2019-03-14 18:32:03 +00:00
|
|
|
}
|
|
|
|
|
2020-10-30 11:44:05 +00:00
|
|
|
config.CertificatesResolvers = map[string]static.CertificateResolver{
|
|
|
|
"CertificateResolver0": {
|
|
|
|
ACME: &acme.Configuration{
|
2021-11-10 11:06:09 +00:00
|
|
|
Email: "acme Email",
|
|
|
|
CAServer: "CAServer",
|
|
|
|
CertificatesDuration: 42,
|
|
|
|
PreferredChain: "foobar",
|
|
|
|
Storage: "Storage",
|
|
|
|
KeyType: "MyKeyType",
|
2020-10-30 11:44:05 +00:00
|
|
|
DNSChallenge: &acme.DNSChallenge{
|
|
|
|
Provider: "DNSProvider",
|
|
|
|
DelayBeforeCheck: 42,
|
|
|
|
Resolvers: []string{"resolver1", "resolver2"},
|
|
|
|
DisablePropagationCheck: true,
|
|
|
|
},
|
|
|
|
HTTPChallenge: &acme.HTTPChallenge{
|
|
|
|
EntryPoint: "MyEntryPoint",
|
|
|
|
},
|
|
|
|
TLSChallenge: &acme.TLSChallenge{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
config.Experimental = &static.Experimental{
|
|
|
|
Plugins: map[string]plugins.Descriptor{
|
|
|
|
"Descriptor0": {
|
|
|
|
ModuleName: "foobar",
|
|
|
|
Version: "foobar",
|
|
|
|
},
|
|
|
|
"Descriptor1": {
|
|
|
|
ModuleName: "foobar",
|
|
|
|
Version: "foobar",
|
|
|
|
},
|
|
|
|
},
|
2021-06-25 13:50:09 +00:00
|
|
|
LocalPlugins: map[string]plugins.LocalDescriptor{
|
|
|
|
"Descriptor0": {
|
|
|
|
ModuleName: "foobar",
|
|
|
|
},
|
|
|
|
"Descriptor1": {
|
|
|
|
ModuleName: "foobar",
|
|
|
|
},
|
2020-10-30 11:44:05 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-03-04 19:08:03 +00:00
|
|
|
expectedConfiguration, err := os.ReadFile("./testdata/anonymized-static-config.json")
|
2020-10-30 11:44:05 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-01-24 10:08:05 +00:00
|
|
|
cleanJSON, err := anonymize(config, true)
|
2020-10-30 11:44:05 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
if *updateExpected {
|
2021-09-16 07:16:07 +00:00
|
|
|
require.NoError(t, os.WriteFile("testdata/anonymized-static-config.json", []byte(cleanJSON), 0o666))
|
2017-10-02 08:32:02 +00:00
|
|
|
}
|
2020-10-30 11:44:05 +00:00
|
|
|
|
|
|
|
expected := strings.TrimSuffix(string(expectedConfiguration), "\n")
|
|
|
|
assert.Equal(t, expected, cleanJSON)
|
2017-10-02 08:32:02 +00:00
|
|
|
}
|
2020-12-03 14:52:05 +00:00
|
|
|
|
|
|
|
func boolPtr(value bool) *bool {
|
|
|
|
return &value
|
|
|
|
}
|
|
|
|
|
|
|
|
func intPtr(value int) *int {
|
|
|
|
return &value
|
|
|
|
}
|
|
|
|
|
|
|
|
func int64Ptr(value int64) *int64 {
|
|
|
|
return &value
|
|
|
|
}
|