2017-08-23 22:59:01 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2017-10-02 08:32:02 +00:00
|
|
|
|
|
|
|
"github.com/containous/traefik/cmd/traefik/anonymize"
|
|
|
|
"github.com/containous/traefik/configuration"
|
|
|
|
"github.com/containous/traefik/provider/file"
|
|
|
|
"github.com/stretchr/testify/assert"
|
2017-08-23 22:59:01 +00:00
|
|
|
)
|
|
|
|
|
2017-10-02 08:32:02 +00:00
|
|
|
func Test_createBugReport(t *testing.T) {
|
|
|
|
traefikConfiguration := TraefikConfiguration{
|
|
|
|
ConfigFile: "FOO",
|
|
|
|
GlobalConfiguration: configuration.GlobalConfiguration{
|
|
|
|
EntryPoints: configuration.EntryPoints{
|
|
|
|
"goo": &configuration.EntryPoint{
|
|
|
|
Address: "hoo.bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
File: &file.Provider{
|
|
|
|
Directory: "BAR",
|
|
|
|
},
|
|
|
|
RootCAs: configuration.RootCAs{"fllf"},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
report, err := createBugReport(traefikConfiguration)
|
|
|
|
assert.NoError(t, err, report)
|
2017-08-23 22:59:01 +00:00
|
|
|
}
|
|
|
|
|
2017-10-02 08:32:02 +00:00
|
|
|
func Test_anonymize_traefikConfiguration(t *testing.T) {
|
|
|
|
traefikConfiguration := &TraefikConfiguration{
|
|
|
|
ConfigFile: "FOO",
|
|
|
|
GlobalConfiguration: configuration.GlobalConfiguration{
|
|
|
|
EntryPoints: configuration.EntryPoints{
|
|
|
|
"goo": &configuration.EntryPoint{
|
|
|
|
Address: "hoo.bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
File: &file.Provider{
|
|
|
|
Directory: "BAR",
|
|
|
|
},
|
|
|
|
},
|
2017-08-23 22:59:01 +00:00
|
|
|
}
|
2017-10-02 08:32:02 +00:00
|
|
|
_, err := anonymize.Do(traefikConfiguration, true)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, "hoo.bar", traefikConfiguration.GlobalConfiguration.EntryPoints["goo"].Address)
|
2017-08-23 22:59:01 +00:00
|
|
|
}
|