Skip to content

Commit

Permalink
fix webhook_test.go in postsubmit (istio#21349)
Browse files Browse the repository at this point in the history
postsubmit tests still use the non-istiod based validation which has
two webhook entries. The test assumed only one.
  • Loading branch information
ayj authored Feb 21, 2020
1 parent b4b8a68 commit 1b3a537
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tests/integration/galley/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package galley

import (
"errors"
"fmt"
"testing"

Expand Down Expand Up @@ -70,15 +71,17 @@ func TestWebhook(t *testing.T) {
}

func verifyValidatingWebhookConfiguration(c *kubeApiAdmission.ValidatingWebhookConfiguration) error {
if len(c.Webhooks) != 1 {
return fmt.Errorf("only one webhook expected. Found %v", len(c.Webhooks))
if len(c.Webhooks) == 0 {
return errors.New("no webhook entries found")
}
wh := c.Webhooks[0]
if *wh.FailurePolicy != kubeApiAdmission.Fail {
return fmt.Errorf("wrong failure policy. c %v wanted %v", *wh.FailurePolicy, kubeApiAdmission.Fail)
}
if len(wh.ClientConfig.CABundle) == 0 {
return fmt.Errorf("caBundle not matched")
for i, wh := range c.Webhooks {
if *wh.FailurePolicy != kubeApiAdmission.Fail {
return fmt.Errorf("webhook #%v: wrong failure policy. c %v wanted %v",
i, *wh.FailurePolicy, kubeApiAdmission.Fail)
}
if len(wh.ClientConfig.CABundle) == 0 {
return fmt.Errorf("webhook #%v: caBundle not matched", i)
}
}
return nil
}

0 comments on commit 1b3a537

Please sign in to comment.