If server_tokens is disabled remove the Server header (#1903)

* If server_tokens is disabled remove the Server header

* Add server-tokens tests

* Fix tests
This commit is contained in:
Manuel Alejandro de Brito Fontes 2018-01-17 10:26:53 -02:00 committed by GitHub
parent 3e7d1f9acf
commit 807932259e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 145 additions and 1 deletions

View file

@ -173,6 +173,13 @@ func (f *Framework) WaitForNginxServer(name string, matcher func(cfg string) boo
return wait.PollImmediate(Poll, time.Minute*2, f.matchNginxConditions(name, matcher))
}
// WaitForNginxConfiguration waits until the nginx configuration contains a particular configuration
func (f *Framework) WaitForNginxConfiguration(matcher func(cfg string) bool) error {
// initial wait to allow the update of the ingress controller
time.Sleep(5 * time.Second)
return wait.PollImmediate(Poll, time.Minute*2, f.matchNginxConditions("", matcher))
}
// NginxLogs returns the logs of the nginx ingress controller pod running
func (f *Framework) NginxLogs() (string, error) {
l, err := f.KubeClientSet.CoreV1().Pods("ingress-nginx").List(metav1.ListOptions{
@ -210,7 +217,13 @@ func (f *Framework) matchNginxConditions(name string, matcher func(cfg string) b
return false, fmt.Errorf("unexpected number of nginx ingress controller pod is running (%v)", len(l.Items))
}
cmd := fmt.Sprintf("cat /etc/nginx/nginx.conf | awk '/## start server %v/,/## end server %v/'", name, name)
var cmd string
if name == "" {
cmd = fmt.Sprintf("cat /etc/nginx/nginx.conf")
} else {
cmd = fmt.Sprintf("cat /etc/nginx/nginx.conf | awk '/## start server %v/,/## end server %v/'", name, name)
}
o, err := f.ExecCommand(&l.Items[0], cmd)
if err != nil {
return false, err