traefik/cmd/bug/bug_test.go

46 lines
1.1 KiB
Go
Raw Normal View History

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