From 6275ff6291a1a83d7ad09b23a4033d6cbab9b296 Mon Sep 17 00:00:00 2001 From: Junjie Gao Date: Mon, 21 Oct 2024 05:40:14 +0000 Subject: [PATCH] fix: improve test stability Signed-off-by: Junjie Gao --- revocation/revocation_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/revocation/revocation_test.go b/revocation/revocation_test.go index 00e9597d..77b1e70c 100644 --- a/revocation/revocation_test.go +++ b/revocation/revocation_test.go @@ -1164,7 +1164,9 @@ func TestCRL(t *testing.T) { } revocationClient, err := NewWithOptions(Options{ - OCSPHTTPClient: &http.Client{}, + OCSPHTTPClient: &http.Client{ + Transport: &serverErrorTransport{}, + }, CRLFetcher: fetcher, CertChainPurpose: purpose.CodeSigning, }) @@ -1352,6 +1354,15 @@ func (t panicTransport) RoundTrip(req *http.Request) (*http.Response, error) { panic("panic") } +type serverErrorTransport struct{} + +func (t serverErrorTransport) RoundTrip(req *http.Request) (*http.Response, error) { + return &http.Response{ + StatusCode: http.StatusInternalServerError, + Body: io.NopCloser(bytes.NewReader([]byte{})), + }, nil +} + func TestValidateContext(t *testing.T) { r, err := NewWithOptions(Options{ OCSPHTTPClient: &http.Client{},