Skip to content

Commit

Permalink
Merge pull request #973 from rfredette/ocpbugs-15900-TestMTLSWithCRLs…
Browse files Browse the repository at this point in the history
…-panic

OCPBUGS-15900: TestMTLSWithCRLs: only try to parse HTTP status code from curl output when stdout is long enough.
  • Loading branch information
openshift-merge-robot committed Sep 18, 2023
2 parents 86642b0 + fa716b8 commit a9fec4f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/e2e/client_tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,16 @@ func curlGetStatusCode(t *testing.T, clientPod *corev1.Pod, certName, endpoint,
stdoutStr := stdout.String()
t.Logf("command: %s\nstdout:\n%s\n\nstderr:\n%s\n",
strings.Join(cmd, " "), stdoutStr, stderr.String())
// due to the '-w %{http_code}' option in the curl command, we should expect stdout to contain exactly one 3-digit
// number representing the HTTP code (or 000 if curl exited without completing the request). If stdoutStr is less
// than 3 bytes long, something major has gone wrong. Return curlErr if it's set, or generate our own error message
// if curErr is unset.
if len(stdoutStr) < 3 {
if curlErr != nil {
return -1, curlErr
}
return -1, fmt.Errorf("invalid output from curl: %q", stdoutStr)
}
// Try to parse the http status code even if curl returns an error; it may still be relevant.
httpStatusCode := stdoutStr[len(stdoutStr)-3:]
httpStatusCodeInt, err := strconv.ParseInt(httpStatusCode, 10, 64)
Expand Down

0 comments on commit a9fec4f

Please sign in to comment.