Fix TestPEMEncode on Go 1.18
Signed-off-by: Benjamin Drung <bdrung@debian.org>
Benjamin Drung
1 year, 5 months ago
0 | From 327ce12e19835417cee40b439343af6f6bc4c040 Mon Sep 17 00:00:00 2001 | |
1 | From: Ludovic Fernandez <ldez@users.noreply.github.com> | |
2 | Date: Mon, 22 Aug 2022 17:05:31 +0200 | |
3 | Subject: Fix TestPEMEncode on Go 1.18 | |
4 | ||
5 | Origin: backport, https://github.com/go-acme/lego/commit/409b3c9959e25d5fe9713d28bb3b18232951089f | |
6 | --- | |
7 | certcrypto/crypto_test.go | 5 ++++- | |
8 | 1 file changed, 4 insertions(+), 1 deletion(-) | |
9 | ||
10 | diff --git a/certcrypto/crypto_test.go b/certcrypto/crypto_test.go | |
11 | index 27e3b412..6b95cd87 100644 | |
12 | --- a/certcrypto/crypto_test.go | |
13 | +++ b/certcrypto/crypto_test.go | |
14 | @@ -5,6 +5,7 @@ import ( | |
15 | "crypto" | |
16 | "crypto/rand" | |
17 | "crypto/rsa" | |
18 | + "regexp" | |
19 | "testing" | |
20 | "time" | |
21 | ||
22 | @@ -111,7 +112,9 @@ func TestPEMEncode(t *testing.T) { | |
23 | ||
24 | data := PEMEncode(key) | |
25 | require.NotNil(t, data) | |
26 | - assert.Len(t, data, 127) | |
27 | + | |
28 | + exp := regexp.MustCompile(`^-----BEGIN RSA PRIVATE KEY-----\s+\S{60,}\s+-----END RSA PRIVATE KEY-----\s+`) | |
29 | + assert.Regexp(t, exp, string(data)) | |
30 | } | |
31 | ||
32 | func TestParsePEMCertificate(t *testing.T) { | |
33 | -- | |
34 | 2.37.2 | |
35 |