Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix failing e2e test #812

Merged
merged 1 commit into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/http-server/webhook-scan-logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (g *APIHandler) getLogs(w http.ResponseWriter, r *http.Request) {
}

func (g *APIHandler) getLogByUID(w http.ResponseWriter, r *http.Request) {
zap.S().Info("handle: validating webhook's get log by uid request")
zap.S().Debug("handle: validating webhook's get log by uid request")

if !config.GetK8sAdmissionControl().Dashboard {
apiErrorResponse(w, ErrDashboardDisabled.Error(), http.StatusBadRequest)
Expand Down
17 changes: 10 additions & 7 deletions test/e2e/validatingwebhook/validating_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ var _ = Describe("ValidatingWebhook", func() {
os.RemoveAll(certsFolder)
})

// log message to be asserted when sever starts
assertLogMessage := "https server listening at port %s"

Describe("terrascan server as validating webhook with various available config options", func() {

When("validating webhook with default 'k8s-admission-control' config", func() {
Expand All @@ -121,6 +124,7 @@ var _ = Describe("ValidatingWebhook", func() {
var session *gexec.Session
var webhookConfig *admissionv1.ValidatingWebhookConfiguration
var configFileName string
port := "9010"

It("server should start running on port 9010", func() {
configFileName = "config1.toml"
Expand All @@ -131,11 +135,10 @@ var _ = Describe("ValidatingWebhook", func() {
os.Setenv(k8sWebhookAPIKey, apiKeyValue)
args := []string{"server", "-c", configFileName, "--cert-path", certFileAbsPath, "--key-path", privKeyFileAbsPath, "-l", "debug"}
session = helper.RunCommand(terrascanBinaryPath, outWriter, errWriter, args...)
Eventually(session.Err, defaultTimeout).Should(gbytes.Say("http server listening at port 9010"))
Eventually(session.Err, defaultTimeout).Should(gbytes.Say(fmt.Sprintf(assertLogMessage, port)))
})

Context("in blind mode, log end points return error response", func() {
port := "9010"
myIP, err := validatingwebhook.GetIP()
When("request is made to the get a single log endpoint", func() {
It("should return a 400 bad request response", func() {
Expand Down Expand Up @@ -208,7 +211,7 @@ var _ = Describe("ValidatingWebhook", func() {
os.Setenv(k8sWebhookAPIKey, apiKeyValue)
args := []string{"server", "-c", configFileName, "--cert-path", certFileAbsPath, "--key-path", privKeyFileAbsPath, "-p", port, "-l", "debug"}
session = helper.RunCommand(terrascanBinaryPath, outWriter, errWriter, args...)
Eventually(session.Err, defaultTimeout).Should(gbytes.Say("http server listening at port 9011"))
Eventually(session.Err, defaultTimeout).Should(gbytes.Say(fmt.Sprintf(assertLogMessage, port)))
})

When("request is made to add server as a validating webhook", func() {
Expand Down Expand Up @@ -257,7 +260,7 @@ var _ = Describe("ValidatingWebhook", func() {
os.Setenv(k8sWebhookAPIKey, apiKeyValue)
args := []string{"server", "-c", configFileName, "--cert-path", certFileAbsPath, "--key-path", privKeyFileAbsPath, "-p", port, "-l", "debug"}
session = helper.RunCommand(terrascanBinaryPath, outWriter, errWriter, args...)
Eventually(session.Err, defaultTimeout).Should(gbytes.Say("http server listening at port 9012"))
Eventually(session.Err, defaultTimeout).Should(gbytes.Say(fmt.Sprintf(assertLogMessage, port)))
})

When("request is made to add server as a validating webhook", func() {
Expand Down Expand Up @@ -304,7 +307,7 @@ var _ = Describe("ValidatingWebhook", func() {
os.Setenv(k8sWebhookAPIKey, apiKeyValue)
args := []string{"server", "-c", configFileName, "--cert-path", certFileAbsPath, "--key-path", privKeyFileAbsPath, "-p", port, "-l", "debug"}
session = helper.RunCommand(terrascanBinaryPath, outWriter, errWriter, args...)
Eventually(session.Err, defaultTimeout).Should(gbytes.Say("http server listening at port 9013"))
Eventually(session.Err, defaultTimeout).Should(gbytes.Say(fmt.Sprintf(assertLogMessage, port)))
})

When("request is made to add server as a validating webhook", func() {
Expand Down Expand Up @@ -353,7 +356,7 @@ var _ = Describe("ValidatingWebhook", func() {
os.Setenv(k8sWebhookAPIKey, apiKeyValue)
args := []string{"server", "-c", configFileName, "--cert-path", certFileAbsPath, "--key-path", privKeyFileAbsPath, "-p", port, "-l", "debug"}
session = helper.RunCommand(terrascanBinaryPath, outWriter, errWriter, args...)
Eventually(session.Err, defaultTimeout).Should(gbytes.Say("http server listening at port 9014"))
Eventually(session.Err, defaultTimeout).Should(gbytes.Say(fmt.Sprintf(assertLogMessage, port)))
})

When("request is made to add server as a validating webhook", func() {
Expand Down Expand Up @@ -400,7 +403,7 @@ var _ = Describe("ValidatingWebhook", func() {
os.Setenv(k8sWebhookAPIKey, apiKeyValue)
args := []string{"server", "-c", configFileName, "--cert-path", certFileAbsPath, "--key-path", privKeyFileAbsPath, "-p", port, "-l", "debug"}
session = helper.RunCommand(terrascanBinaryPath, outWriter, errWriter, args...)
Eventually(session.Err, defaultTimeout).Should(gbytes.Say("http server listening at port 9015"))
Eventually(session.Err, defaultTimeout).Should(gbytes.Say(fmt.Sprintf(assertLogMessage, port)))
})

When("request is made to add server as a validating webhook", func() {
Expand Down