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"
|
2023-02-03 14:24:05 +00:00
|
|
|
"github.com/traefik/traefik/v3/pkg/config/dynamic"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/config/static"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/ping"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/plugins"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/provider/acme"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/provider/consulcatalog"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/provider/docker"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/provider/ecs"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/provider/file"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/provider/http"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/provider/kubernetes/crd"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/provider/kubernetes/gateway"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/provider/kubernetes/ingress"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/provider/kv"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/provider/kv/consul"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/provider/kv/etcd"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/provider/kv/redis"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/provider/kv/zk"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/provider/rest"
|
|
|
|
traefiktls "github.com/traefik/traefik/v3/pkg/tls"
|
2024-01-08 08:10:06 +00:00
|
|
|
"github.com/traefik/traefik/v3/pkg/tracing/opentelemetry"
|
2023-02-03 14:24:05 +00:00
|
|
|
"github.com/traefik/traefik/v3/pkg/types"
|
2017-10-02 08:32:02 +00:00
|
|
|
)
|
|
|
|
|
2023-05-10 13:28:05 +00:00
|
|
|
var updateExpected = flag.Bool("update_expected", false, "Update expected files in fixtures")
|
2020-10-30 11:44:05 +00:00
|
|
|
|
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",
|
2024-11-12 09:56:06 +00:00
|
|
|
FollowRedirects: pointer(true),
|
2020-12-03 14:52:05 +00:00
|
|
|
Headers: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
},
|
2024-11-12 09:56:06 +00:00
|
|
|
PassHostHeader: pointer(true),
|
2020-12-03 14:52:05 +00:00
|
|
|
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",
|
2024-11-12 09:56:06 +00:00
|
|
|
Weight: pointer(42),
|
2020-12-03 14:52:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Sticky: &dynamic.Sticky{
|
|
|
|
Cookie: &dynamic.Cookie{
|
|
|
|
Name: "foo",
|
|
|
|
Secure: true,
|
|
|
|
HTTPOnly: true,
|
|
|
|
SameSite: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"baz": {
|
|
|
|
Mirroring: &dynamic.Mirroring{
|
|
|
|
Service: "foo",
|
2024-11-12 09:56:06 +00:00
|
|
|
MaxBodySize: pointer[int64](42),
|
2020-12-03 14:52:05 +00:00
|
|
|
Mirrors: []dynamic.MirrorService{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Percent: 42,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{
|
|
|
|
"foo": {
|
|
|
|
ServerName: "foo",
|
|
|
|
InsecureSkipVerify: true,
|
2024-01-11 16:06:06 +00:00
|
|
|
RootCAs: []types.FileOrContent{"rootca.pem"},
|
2020-12-03 14:52:05 +00:00
|
|
|
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{
|
2022-11-25 09:50:06 +00:00
|
|
|
Prefixes: []string{"foo"},
|
2020-12-03 14:52:05 +00:00
|
|
|
},
|
|
|
|
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"},
|
|
|
|
SSLProxyHeaders: map[string]string{"foo": "bar"},
|
|
|
|
STSSeconds: 42,
|
|
|
|
STSIncludeSubdomains: true,
|
|
|
|
STSPreload: true,
|
|
|
|
ForceSTSHeader: true,
|
|
|
|
FrameDeny: true,
|
|
|
|
CustomFrameOptionsValue: "foo",
|
|
|
|
ContentTypeNosniff: true,
|
|
|
|
BrowserXSSFilter: true,
|
|
|
|
CustomBrowserXSSValue: "foo",
|
|
|
|
ContentSecurityPolicy: "foo",
|
2024-06-07 07:24:04 +00:00
|
|
|
ContentSecurityPolicyReportOnly: "foo",
|
2020-12-03 14:52:05 +00:00
|
|
|
PublicKey: "foo",
|
|
|
|
ReferrerPolicy: "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",
|
2024-01-29 16:32:05 +00:00
|
|
|
TLS: &dynamic.ClientTLS{
|
2020-12-03 14:52:05 +00:00
|
|
|
CA: "ca.pem",
|
|
|
|
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,
|
|
|
|
},
|
2022-11-29 10:48:05 +00:00
|
|
|
ContentType: &dynamic.ContentType{},
|
2020-12-03 14:52:05 +00:00
|
|
|
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{
|
|
|
|
ProxyProtocol: &dynamic.ProxyProtocol{
|
|
|
|
Version: 42,
|
|
|
|
},
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "127.0.0.1:8080",
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransport: "foo",
|
2020-12-03 14:52:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"bar": {
|
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
2024-11-12 09:56:06 +00:00
|
|
|
Weight: pointer(42),
|
2020-12-03 14:52:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{
|
|
|
|
"foo": {
|
|
|
|
TLS: &dynamic.TLSClientConfig{
|
|
|
|
ServerName: "foo",
|
|
|
|
InsecureSkipVerify: true,
|
2024-01-11 16:06:06 +00:00
|
|
|
RootCAs: []types.FileOrContent{"rootca.pem"},
|
2022-12-09 08:58:05 +00:00
|
|
|
Certificates: []traefiktls.Certificate{
|
|
|
|
{
|
|
|
|
CertFile: "cert.pem",
|
|
|
|
KeyFile: "key.pem",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
DialTimeout: 42,
|
|
|
|
DialKeepAlive: 42,
|
|
|
|
TerminationDelay: 42,
|
|
|
|
},
|
|
|
|
},
|
2020-12-03 14:52:05 +00:00
|
|
|
}
|
|
|
|
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",
|
2024-11-12 09:56:06 +00:00
|
|
|
Weight: pointer(42),
|
2020-12-03 14:52:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
config.TLS = &dynamic.TLSConfiguration{
|
|
|
|
Options: map[string]traefiktls.Options{
|
|
|
|
"foo": {
|
|
|
|
MinVersion: "foo",
|
|
|
|
MaxVersion: "foo",
|
|
|
|
CipherSuites: []string{"foo"},
|
|
|
|
CurvePreferences: []string{"foo"},
|
|
|
|
ClientAuth: traefiktls.ClientAuth{
|
2024-01-11 16:06:06 +00:00
|
|
|
CAFiles: []types.FileOrContent{"ca.pem"},
|
2020-12-03 14:52:05 +00:00
|
|
|
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")
|
2024-11-12 09:56:06 +00:00
|
|
|
assert.JSONEq(t, expected, cleanJSON)
|
2020-12-03 14:52:05 +00:00
|
|
|
}
|
|
|
|
|
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")
|
2024-11-12 09:56:06 +00:00
|
|
|
assert.JSONEq(t, expected, cleanJSON)
|
2022-01-24 10:08:05 +00:00
|
|
|
}
|
|
|
|
|
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,
|
2024-04-11 15:49:50 +00:00
|
|
|
RootCAs: []types.FileOrContent{"root.ca"},
|
2020-10-30 11:44:05 +00:00
|
|
|
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
|
|
|
}
|
2024-04-08 15:16:04 +00:00
|
|
|
|
2018-11-27 16:42:04 +00:00
|
|
|
config.EntryPoints = static.EntryPoints{
|
2023-11-29 11:20:57 +00:00
|
|
|
"foobar": &static.EntryPoint{
|
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{
|
2024-04-11 13:48:04 +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,
|
2024-01-11 16:06:06 +00:00
|
|
|
RootCAs: []types.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
|
|
|
|
2022-12-09 08:58:05 +00:00
|
|
|
config.TCPServersTransport = &static.TCPServersTransport{
|
|
|
|
DialTimeout: ptypes.Duration(111 * time.Second),
|
|
|
|
DialKeepAlive: ptypes.Duration(111 * time.Second),
|
|
|
|
TLS: &static.TLSClientConfig{
|
|
|
|
InsecureSkipVerify: true,
|
2024-01-11 16:06:06 +00:00
|
|
|
RootCAs: []types.FileOrContent{"RootCAs 1", "RootCAs 2", "RootCAs 3"},
|
2022-12-09 08:58:05 +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{
|
2023-05-10 13:28:05 +00:00
|
|
|
Shared: docker.Shared{
|
|
|
|
ExposedByDefault: true,
|
|
|
|
Constraints: `Label("foo", "bar")`,
|
|
|
|
AllowEmptyServices: true,
|
|
|
|
Network: "MyNetwork",
|
|
|
|
UseBindPortIP: true,
|
|
|
|
Watch: true,
|
|
|
|
DefaultRule: "PathPrefix(`/`)",
|
|
|
|
},
|
|
|
|
ClientConfig: docker.ClientConfig{
|
|
|
|
Endpoint: "MyEndPoint", TLS: &types.ClientTLS{
|
|
|
|
CA: "myCa",
|
|
|
|
Cert: "mycert.pem",
|
|
|
|
Key: "mycert.key",
|
|
|
|
InsecureSkipVerify: true,
|
|
|
|
},
|
|
|
|
HTTPClientTimeout: 42,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
config.Providers.Swarm = &docker.SwarmProvider{
|
|
|
|
Shared: docker.Shared{
|
|
|
|
ExposedByDefault: true,
|
|
|
|
Constraints: `Label("foo", "bar")`,
|
|
|
|
AllowEmptyServices: true,
|
|
|
|
Network: "MyNetwork",
|
|
|
|
UseBindPortIP: true,
|
|
|
|
Watch: true,
|
|
|
|
DefaultRule: "PathPrefix(`/`)",
|
|
|
|
},
|
|
|
|
ClientConfig: docker.ClientConfig{
|
|
|
|
Endpoint: "MyEndPoint", TLS: &types.ClientTLS{
|
|
|
|
CA: "myCa",
|
|
|
|
Cert: "mycert.pem",
|
|
|
|
Key: "mycert.key",
|
|
|
|
InsecureSkipVerify: true,
|
|
|
|
},
|
|
|
|
HTTPClientTimeout: 42,
|
2019-03-14 18:32:03 +00:00
|
|
|
},
|
2023-05-10 13:28:05 +00:00
|
|
|
RefreshSeconds: 42,
|
2019-03-14 18:32:03 +00:00
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
|
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",
|
|
|
|
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
|
|
|
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",
|
|
|
|
Cert: "mycert.pem",
|
|
|
|
Key: "mycert.key",
|
|
|
|
InsecureSkipVerify: true,
|
2020-10-30 11:44:05 +00:00
|
|
|
},
|
2022-06-03 10:00:09 +00:00
|
|
|
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",
|
|
|
|
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",
|
|
|
|
Cert: "mycert.pem",
|
|
|
|
Key: "mycert.key",
|
|
|
|
InsecureSkipVerify: true,
|
2020-10-30 11:44:05 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
config.Providers.HTTP = &http.Provider{
|
2024-09-13 09:40:04 +00:00
|
|
|
Endpoint: "Myendpoint",
|
2020-10-30 11:44:05 +00:00
|
|
|
PollInterval: 42,
|
|
|
|
PollTimeout: 42,
|
|
|
|
TLS: &types.ClientTLS{
|
|
|
|
CA: "myCa",
|
|
|
|
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
|
|
|
},
|
|
|
|
}
|
|
|
|
|
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{
|
2024-01-08 08:10:06 +00:00
|
|
|
ServiceName: "myServiceName",
|
|
|
|
GlobalAttributes: map[string]string{
|
|
|
|
"foobar": "foobar",
|
|
|
|
},
|
|
|
|
SampleRate: 42,
|
|
|
|
OTLP: &opentelemetry.Config{
|
2024-02-06 09:04:05 +00:00
|
|
|
HTTP: &types.OtelHTTP{
|
2020-10-30 11:44:05 +00:00
|
|
|
Endpoint: "foobar",
|
2024-01-08 08:10:06 +00:00
|
|
|
TLS: nil,
|
2024-02-06 09:04:05 +00:00
|
|
|
Headers: map[string]string{
|
|
|
|
"foobar": "foobar",
|
|
|
|
},
|
2020-10-30 11:44:05 +00:00
|
|
|
},
|
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",
|
2024-06-25 07:58:04 +00:00
|
|
|
Settings: plugins.Settings{
|
|
|
|
Envs: []string{"a", "b"},
|
|
|
|
Mounts: []string{"a", "b"},
|
|
|
|
},
|
2020-10-30 11:44:05 +00:00
|
|
|
},
|
|
|
|
"Descriptor1": {
|
|
|
|
ModuleName: "foobar",
|
|
|
|
Version: "foobar",
|
2024-06-25 07:58:04 +00:00
|
|
|
Settings: plugins.Settings{
|
|
|
|
Envs: []string{"a", "b"},
|
|
|
|
Mounts: []string{"a", "b"},
|
|
|
|
},
|
2020-10-30 11:44:05 +00:00
|
|
|
},
|
|
|
|
},
|
2021-06-25 13:50:09 +00:00
|
|
|
LocalPlugins: map[string]plugins.LocalDescriptor{
|
|
|
|
"Descriptor0": {
|
|
|
|
ModuleName: "foobar",
|
2024-06-25 07:58:04 +00:00
|
|
|
Settings: plugins.Settings{
|
|
|
|
Envs: []string{"a", "b"},
|
|
|
|
Mounts: []string{"a", "b"},
|
|
|
|
},
|
2021-06-25 13:50:09 +00:00
|
|
|
},
|
|
|
|
"Descriptor1": {
|
|
|
|
ModuleName: "foobar",
|
2024-06-25 07:58:04 +00:00
|
|
|
Settings: plugins.Settings{
|
|
|
|
Envs: []string{"a", "b"},
|
|
|
|
Mounts: []string{"a", "b"},
|
|
|
|
},
|
2021-06-25 13:50:09 +00:00
|
|
|
},
|
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")
|
2024-11-12 09:56:06 +00:00
|
|
|
assert.JSONEq(t, expected, cleanJSON)
|
2017-10-02 08:32:02 +00:00
|
|
|
}
|
2020-12-03 14:52:05 +00:00
|
|
|
|
2024-11-12 09:56:06 +00:00
|
|
|
func pointer[T any](v T) *T { return &v }
|