Skip to content

Commit 58314be

Browse files
josephburnettJoseph Burnett
authored and
Joseph Burnett
committed
Accept MacOS SSL error message.
The error messages for invalid certificates is slightly different on Linux and MacOS. We should accept both. Once this issue is fixed: golang/go#52010 we can just compare the error to the canonical UnknownAuthorityError.
1 parent e1a5c68 commit 58314be

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

helpers/certificate/x509_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"crypto/x509"
99
"net"
1010
"net/http"
11+
"regexp"
1112
"testing"
1213

1314
"github.com/stretchr/testify/assert"
@@ -61,5 +62,7 @@ func TestCertificate(t *testing.T) {
6162

6263
_, err = client.Do(req)
6364
assert.Error(t, err)
64-
assert.Contains(t, err.Error(), "certificate signed by unknown authority")
65+
// Error messages provided by Linux and MacOS respectively.
66+
const want = "certificate signed by unknown authority|certificate is not trusted"
67+
assert.Regexp(t, regexp.MustCompile(want), err.Error())
6568
}

network/client_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"net/url"
2121
"os"
2222
"path/filepath"
23+
"regexp"
2324
"strconv"
2425
"strings"
2526
"testing"
@@ -295,7 +296,9 @@ func TestClientInvalidSSL(t *testing.T) {
295296
nil,
296297
)
297298
assert.Equal(t, -1, statusCode, statusText)
298-
assert.Contains(t, statusText, "certificate signed by unknown authority")
299+
// Error messages provided by Linux and MacOS respectively.
300+
const want = "certificate signed by unknown authority|certificate is not trusted"
301+
assert.Regexp(t, regexp.MustCompile(want), statusText)
299302
}
300303

301304
func TestClientTLSCAFile(t *testing.T) {

0 commit comments

Comments
 (0)