traefik/anonymize/anonymize_config_test.go

166 lines
4.5 KiB
Go
Raw Normal View History

2017-10-02 08:32:02 +00:00
package anonymize
import (
"crypto/tls"
2018-10-01 17:18:03 +00:00
"os"
2017-10-02 08:32:02 +00:00
"testing"
"time"
2018-07-31 17:28:03 +00:00
"github.com/containous/flaeg/parse"
2017-10-02 08:32:02 +00:00
"github.com/containous/traefik/acme"
"github.com/containous/traefik/config/static"
"github.com/containous/traefik/provider"
acmeprovider "github.com/containous/traefik/provider/acme"
"github.com/containous/traefik/provider/file"
traefiktls "github.com/containous/traefik/tls"
"github.com/containous/traefik/types"
2019-02-18 06:52:03 +00:00
assetfs "github.com/elazarl/go-bindata-assetfs"
2017-10-02 08:32:02 +00:00
)
func TestDo_globalConfiguration(t *testing.T) {
config := &static.Configuration{}
2017-10-02 08:32:02 +00:00
config.Global = &static.Global{
Debug: true,
CheckNewVersion: true,
SendAnonymousUsage: true,
}
2017-10-02 08:32:02 +00:00
config.AccessLog = &types.AccessLog{
FilePath: "AccessLog FilePath",
Format: "AccessLog Format",
}
config.Log = &types.TraefikLog{
LogLevel: "LogLevel",
FilePath: "/foo/path",
Format: "json",
}
config.EntryPoints = static.EntryPoints{
2017-10-02 08:32:02 +00:00
"foo": {
Address: "foo Address",
Transport: &static.EntryPointsTransport{
RespondingTimeouts: &static.RespondingTimeouts{
ReadTimeout: parse.Duration(111 * time.Second),
WriteTimeout: parse.Duration(111 * time.Second),
IdleTimeout: parse.Duration(111 * time.Second),
},
},
TLS: &traefiktls.TLS{
2017-10-02 08:32:02 +00:00
MinVersion: "foo MinVersion",
CipherSuites: []string{"foo CipherSuites 1", "foo CipherSuites 2", "foo CipherSuites 3"},
ClientCA: traefiktls.ClientCA{
2018-08-29 09:36:03 +00:00
Files: traefiktls.FilesOrContents{"foo ClientCAFiles 1", "foo ClientCAFiles 2", "foo ClientCAFiles 3"},
2017-11-10 09:30:04 +00:00
Optional: false,
},
2017-10-02 08:32:02 +00:00
},
ProxyProtocol: &static.ProxyProtocol{
2017-10-10 12:50:03 +00:00
TrustedIPs: []string{"127.0.0.1/32", "192.168.0.1"},
},
2017-10-02 08:32:02 +00:00
},
"fii": {
Address: "fii Address",
Transport: &static.EntryPointsTransport{
RespondingTimeouts: &static.RespondingTimeouts{
ReadTimeout: parse.Duration(111 * time.Second),
WriteTimeout: parse.Duration(111 * time.Second),
IdleTimeout: parse.Duration(111 * time.Second),
},
},
TLS: &traefiktls.TLS{
2017-10-02 08:32:02 +00:00
MinVersion: "fii MinVersion",
CipherSuites: []string{"fii CipherSuites 1", "fii CipherSuites 2", "fii CipherSuites 3"},
ClientCA: traefiktls.ClientCA{
2018-08-29 09:36:03 +00:00
Files: traefiktls.FilesOrContents{"fii ClientCAFiles 1", "fii ClientCAFiles 2", "fii ClientCAFiles 3"},
2017-11-10 09:30:04 +00:00
Optional: false,
},
2017-10-02 08:32:02 +00:00
},
ProxyProtocol: &static.ProxyProtocol{
2017-10-10 12:50:03 +00:00
TrustedIPs: []string{"127.0.0.1/32", "192.168.0.1"},
},
2017-10-02 08:32:02 +00:00
},
}
config.ACME = &acme.ACME{
Email: "acme Email",
2018-03-05 19:54:04 +00:00
Domains: []types.Domain{
2017-10-02 08:32:02 +00:00
{
Main: "Domains Main",
SANs: []string{"Domains acme SANs 1", "Domains acme SANs 2", "Domains acme SANs 3"},
},
},
2018-11-14 09:18:03 +00:00
Storage: "Storage",
OnDemand: true,
OnHostRule: true,
CAServer: "CAServer",
EntryPoint: "EntryPoint",
DNSChallenge: &acmeprovider.DNSChallenge{Provider: "DNSProvider"},
ACMELogging: true,
2017-10-02 08:32:02 +00:00
TLSConfig: &tls.Config{
InsecureSkipVerify: true,
// ...
},
}
config.Providers = &static.Providers{
ProvidersThrottleDuration: parse.Duration(111 * time.Second),
2017-10-02 08:32:02 +00:00
}
config.ServersTransport = &static.ServersTransport{
InsecureSkipVerify: true,
RootCAs: traefiktls.FilesOrContents{"RootCAs 1", "RootCAs 2", "RootCAs 3"},
MaxIdleConnsPerHost: 111,
ForwardingTimeouts: &static.ForwardingTimeouts{
DialTimeout: parse.Duration(111 * time.Second),
ResponseHeaderTimeout: parse.Duration(111 * time.Second),
},
2017-10-02 08:32:02 +00:00
}
config.API = &static.API{
EntryPoint: "traefik",
Dashboard: true,
2018-10-01 17:18:03 +00:00
Statistics: &types.Statistics{
RecentErrors: 111,
2018-10-01 17:18:03 +00:00
},
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",
},
Middlewares: []string{"first", "second"},
2018-10-01 17:18:03 +00:00
}
config.Providers.File = &file.Provider{
2017-10-02 08:32:02 +00:00
BaseProvider: provider.BaseProvider{
Watch: true,
Filename: "file Filename",
Constraints: types.Constraints{
{
Key: "file Constraints Key 1",
Regex: "file Constraints Regex 2",
MustMatch: true,
},
{
Key: "file Constraints Key 1",
Regex: "file Constraints Regex 2",
MustMatch: true,
},
},
2018-09-07 07:40:03 +00:00
Trace: true,
2017-10-02 08:32:02 +00:00
DebugLogGeneratedTemplate: true,
},
Directory: "file Directory",
}
// FIXME Test the other providers once they are migrated
2017-10-02 08:32:02 +00:00
cleanJSON, err := Do(config, true)
if err != nil {
t.Fatal(err, cleanJSON)
}
}