1
0
Fork 0

Enhance integration tests

* refactor: remove unused code.
* refactor: factorize Traefik cmd start.
* refactor(whitelist): minor change.
* refactor(accesslog): better use of checker.
* refactor(errorpages): factorize containers IP variables.
* refactor(integration): refactor cmdTraefikWithConfigFile.
This commit is contained in:
Ludovic Fernandez 2017-07-10 14:58:31 +02:00 committed by GitHub
parent bbb133d94c
commit 2e84b1e556
20 changed files with 109 additions and 231 deletions

View file

@ -18,12 +18,13 @@ type IPWhitelister struct {
// NewIPWhitelister builds a new IPWhitelister given a list of CIDR-Strings to whitelist
func NewIPWhitelister(whitelistStrings []string) (*IPWhitelister, error) {
whitelister := IPWhitelister{}
if len(whitelistStrings) == 0 {
return nil, errors.New("no whitelists provided")
}
whitelister := IPWhitelister{}
for _, whitelistString := range whitelistStrings {
_, whitelist, err := net.ParseCIDR(whitelistString)
if err != nil {
@ -65,6 +66,7 @@ func reject(w http.ResponseWriter) {
w.WriteHeader(statusCode)
w.Write([]byte(http.StatusText(statusCode)))
}
func ipFromRemoteAddr(addr string) (*net.IP, error) {
ip, _, err := net.SplitHostPort(addr)
if err != nil {