traefik/cmd/bug/bug_test.go

46 lines
1.1 KiB
Go
Raw Normal View History

2018-03-01 07:10:04 +00:00
package bug
2017-08-23 22:59:01 +00:00
import (
"testing"
2017-10-02 08:32:02 +00:00
2018-03-01 07:10:04 +00:00
"github.com/containous/traefik/anonymize"
"github.com/containous/traefik/cmd"
"github.com/containous/traefik/config/static"
2017-10-02 08:32:02 +00:00
"github.com/stretchr/testify/assert"
2017-08-23 22:59:01 +00:00
)
2018-03-01 07:10:04 +00:00
func Test_createReport(t *testing.T) {
traefikConfiguration := &cmd.TraefikConfiguration{
2017-10-02 08:32:02 +00:00
ConfigFile: "FOO",
Configuration: static.Configuration{
EntryPoints: static.EntryPoints{
"goo": &static.EntryPoint{
2017-10-02 08:32:02 +00:00
Address: "hoo.bar",
},
},
},
}
2018-03-01 07:10:04 +00:00
report, err := createReport(traefikConfiguration)
2017-10-02 08:32:02 +00:00
assert.NoError(t, err, report)
2018-01-02 09:14:03 +00:00
// exported anonymous configuration
assert.NotContains(t, "hoo.bar", report)
2017-08-23 22:59:01 +00:00
}
2017-10-02 08:32:02 +00:00
func Test_anonymize_traefikConfiguration(t *testing.T) {
2018-03-01 07:10:04 +00:00
traefikConfiguration := &cmd.TraefikConfiguration{
2017-10-02 08:32:02 +00:00
ConfigFile: "FOO",
Configuration: static.Configuration{
EntryPoints: static.EntryPoints{
"goo": &static.EntryPoint{
2017-10-02 08:32:02 +00:00
Address: "hoo.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.Configuration.EntryPoints["goo"].Address)
2017-08-23 22:59:01 +00:00
}