2017-10-02 08:32:02 +00:00
|
|
|
package anonymize
|
|
|
|
|
|
|
|
import (
|
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"
|
2018-11-27 16:42:04 +00:00
|
|
|
"github.com/containous/traefik/config/static"
|
|
|
|
"github.com/containous/traefik/provider"
|
2019-03-14 08:30:04 +00:00
|
|
|
"github.com/containous/traefik/provider/acme"
|
2018-11-27 16:42:04 +00:00
|
|
|
acmeprovider "github.com/containous/traefik/provider/acme"
|
|
|
|
"github.com/containous/traefik/provider/file"
|
2018-03-06 09:12:04 +00:00
|
|
|
traefiktls "github.com/containous/traefik/tls"
|
2018-11-27 16:42:04 +00:00
|
|
|
"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) {
|
|
|
|
|
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{
|
|
|
|
Debug: true,
|
|
|
|
CheckNewVersion: true,
|
|
|
|
SendAnonymousUsage: true,
|
|
|
|
}
|
2017-10-02 08:32:02 +00:00
|
|
|
config.AccessLog = &types.AccessLog{
|
|
|
|
FilePath: "AccessLog FilePath",
|
|
|
|
Format: "AccessLog Format",
|
|
|
|
}
|
2018-11-27 16:42:04 +00:00
|
|
|
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",
|
2018-11-27 16:42:04 +00:00
|
|
|
Transport: &static.EntryPointsTransport{
|
|
|
|
RespondingTimeouts: &static.RespondingTimeouts{
|
|
|
|
ReadTimeout: parse.Duration(111 * time.Second),
|
|
|
|
WriteTimeout: parse.Duration(111 * time.Second),
|
|
|
|
IdleTimeout: parse.Duration(111 * time.Second),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
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",
|
2018-11-27 16:42:04 +00:00
|
|
|
Transport: &static.EntryPointsTransport{
|
|
|
|
RespondingTimeouts: &static.RespondingTimeouts{
|
|
|
|
ReadTimeout: parse.Duration(111 * time.Second),
|
|
|
|
WriteTimeout: parse.Duration(111 * time.Second),
|
|
|
|
IdleTimeout: parse.Duration(111 * time.Second),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
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
|
|
|
},
|
|
|
|
}
|
2019-03-14 08:30:04 +00:00
|
|
|
config.ACME = &acme.Configuration{
|
2017-10-02 08:32:02 +00:00
|
|
|
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",
|
|
|
|
OnHostRule: true,
|
|
|
|
CAServer: "CAServer",
|
|
|
|
EntryPoint: "EntryPoint",
|
|
|
|
DNSChallenge: &acmeprovider.DNSChallenge{Provider: "DNSProvider"},
|
|
|
|
ACMELogging: true,
|
2017-10-02 08:32:02 +00:00
|
|
|
}
|
2018-11-27 16:42:04 +00:00
|
|
|
config.Providers = &static.Providers{
|
|
|
|
ProvidersThrottleDuration: parse.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,
|
|
|
|
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
|
|
|
}
|
2018-11-27 16:42:04 +00:00
|
|
|
|
|
|
|
config.API = &static.API{
|
|
|
|
EntryPoint: "traefik",
|
|
|
|
Dashboard: true,
|
2018-10-01 17:18:03 +00:00
|
|
|
Statistics: &types.Statistics{
|
2018-11-27 16:42:04 +00:00
|
|
|
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",
|
|
|
|
},
|
2018-11-27 16:42:04 +00:00
|
|
|
Middlewares: []string{"first", "second"},
|
2018-10-01 17:18:03 +00:00
|
|
|
}
|
2018-11-27 16:42:04 +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",
|
|
|
|
}
|
2018-11-27 16:42:04 +00:00
|
|
|
|
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
}
|