Subject: [PATCH 1/2] gnu: go-1.23: Skip time variant tests

From: Ryan Sundberg <[email-masked]>
Date: Mon, 20 Jan 2025 16:06:04 -0800

Patch out select tests under src/crypto/tls which depend on the current
wall clock time for TLS certificate testing.

Specifically, the following failing test cases are skipped:

```

Change-Id: I2f1519bc1c951e15db3a1c9320148206674c7bdf
--- FAIL: TestVerifyConnection (0.00s)
    --- FAIL: TestVerifyConnection/TLSv12 (0.00s)
        handshake_client_test.go:1759: RequireAndVerifyClientCert-FullHandshake: handshake failed: server: remote error: tls: bad certificate
            client: tls: failed to verify certificate: x509: certificate has expired or is not yet valid: current time 2025-01-20T20:07:09Z is after 2025-01-01T00:00:00Z
    --- FAIL: TestVerifyConnection/TLSv13 (0.00s)
        handshake_client_test.go:1759: RequireAndVerifyClientCert-FullHandshake: handshake failed: server: remote error: tls: bad certificate
            client: tls: failed to verify certificate: x509: certificate has expired or is not yet valid: current time 2025-01-20T20:07:09Z is after 2025-01-01T00:00:00Z
--- FAIL: TestResumptionKeepsOCSPAndSCT (0.00s)
    --- FAIL: TestResumptionKeepsOCSPAndSCT/TLSv12 (0.00s)
        handshake_client_test.go:2550: handshake failed: server: remote error: tls: bad certificate
            client: tls: failed to verify certificate: x509: certificate has expired or is not yet valid: current time 2025-01-20T20:07:09Z is after 2025-01-01T00:00:00Z
    --- FAIL: TestResumptionKeepsOCSPAndSCT/TLSv13 (0.00s)
        handshake_client_test.go:2550: handshake failed: server: remote error: tls: bad certificate
            client: tls: failed to verify certificate: x509: certificate has expired or is not yet valid: current time 2025-01-20T20:07:09Z is after 2025-01-01T00:00:00Z
--- FAIL: TestCrossVersionResume (0.01s)
    --- FAIL: TestCrossVersionResume/TLSv12 (0.00s)
        handshake_server_test.go:526: handshake did not resume at the same version
    --- FAIL: TestCrossVersionResume/TLSv13 (0.00s)
        handshake_server_test.go:526: handshake did not resume at the same version
FAIL
FAIL    crypto/tls      0.423s
```

* gnu/packages/golang (go-1.23): Include patchset
* gnu/packages/patches/go-skip-tls-tests.patch: New patch file
---
 gnu/packages/golang.scm                      | 16 +++++-
 gnu/packages/patches/go-skip-tls-tests.patch | 56 ++++++++++++++++++++
 2 files changed, 71 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/go-skip-tls-tests.patch

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index b1ea9e5a28..d39e50e982 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -1001,7 +1001,21 @@ (define-public go-1.23
              (commit (string-append "go" version))))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "0v8j43yqkhp5i5649nbxsq7lc9bjjn39gqqvlnz0d9c47qz9h7y7"))))))
+        (base32 "0v8j43yqkhp5i5649nbxsq7lc9bjjn39gqqvlnz0d9c47qz9h7y7"))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments go-1.22)
+       ((#:phases phases)
+        #~(modify-phases #$phases
+            (add-after 'unpack 'apply-skip-test-patch
+              (lambda* (#:key inputs #:allow-other-keys)
+                ;; Having the patch in the 'patches' field of <origin> breaks
+                ;; the 'TestServeContent' test due to the fact that timestamps
+                ;; are reset.  Thus, apply it from here.
+                (invoke "patch" "-p1" "--force" "-i"
+                        (assoc-ref inputs "go-skip-tls-tests.patch"))))))))
+    (native-inputs
+     `(("go-skip-tls-tests.patch" ,(search-patch "go-skip-tls-tests.patch"))
+       ,@(package-native-inputs go-1.22)))))
 
 ;;
 ;; Default Golang version used in guix/build-system/go.scm to build packages.
diff --git a/gnu/packages/patches/go-skip-tls-tests.patch b/gnu/packages/patches/go-skip-tls-tests.patch
new file mode 100644
index 0000000000..92e0a31a86
--- /dev/null
+++ b/gnu/packages/patches/go-skip-tls-tests.patch
@@ -0,0 +1,56 @@
+From 0b0cb6aa447cef0e4f631e43db05195d0d25329a Mon Sep 17 00:00:00 2001
+From: Ryan Sundberg <[email-masked]>
+Date: Mon, 20 Jan 2025 15:17:39 -0800
+Subject: [PATCH] crypto/tls: Disable test cases which are time variant
+
+These test cases depend on the current date relative to the TLS
+certificates under test. Skip them for repeatability.
+---
+ src/crypto/tls/handshake_client_test.go | 8 ++++----
+ src/crypto/tls/handshake_server_test.go | 4 ++--
+ 2 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/src/crypto/tls/handshake_client_test.go b/src/crypto/tls/handshake_client_test.go
+index 3c87916bcf..fa2a494a6b 100644
+--- a/src/crypto/tls/handshake_client_test.go
++++ b/src/crypto/tls/handshake_client_test.go
+@@ -1561,8 +1561,8 @@ func TestServerSelectingUnconfiguredCipherSuite(t *testing.T) {
+ }
+ 
+ func TestVerifyConnection(t *testing.T) {
+-	t.Run("TLSv12", func(t *testing.T) { testVerifyConnection(t, VersionTLS12) })
+-	t.Run("TLSv13", func(t *testing.T) { testVerifyConnection(t, VersionTLS13) })
++	// t.Run("TLSv12", func(t *testing.T) { testVerifyConnection(t, VersionTLS12) })
++	// t.Run("TLSv13", func(t *testing.T) { testVerifyConnection(t, VersionTLS13) })
+ }
+ 
+ func testVerifyConnection(t *testing.T, version uint16) {
+@@ -2528,8 +2528,8 @@ func TestDowngradeCanary(t *testing.T) {
+ }
+ 
+ func TestResumptionKeepsOCSPAndSCT(t *testing.T) {
+-	t.Run("TLSv12", func(t *testing.T) { testResumptionKeepsOCSPAndSCT(t, VersionTLS12) })
+-	t.Run("TLSv13", func(t *testing.T) { testResumptionKeepsOCSPAndSCT(t, VersionTLS13) })
++	//t.Run("TLSv12", func(t *testing.T) { testResumptionKeepsOCSPAndSCT(t, VersionTLS12) })
++	//t.Run("TLSv13", func(t *testing.T) { testResumptionKeepsOCSPAndSCT(t, VersionTLS13) })
+ }
+ 
+ func testResumptionKeepsOCSPAndSCT(t *testing.T, ver uint16) {
+diff --git a/src/crypto/tls/handshake_server_test.go b/src/crypto/tls/handshake_server_test.go
+index bbfe44bd97..4347c40a6d 100644
+--- a/src/crypto/tls/handshake_server_test.go
++++ b/src/crypto/tls/handshake_server_test.go
+@@ -493,8 +493,8 @@ func testSCTHandshake(t *testing.T, version uint16) {
+ }
+ 
+ func TestCrossVersionResume(t *testing.T) {
+-	t.Run("TLSv12", func(t *testing.T) { testCrossVersionResume(t, VersionTLS12) })
+-	t.Run("TLSv13", func(t *testing.T) { testCrossVersionResume(t, VersionTLS13) })
++	//t.Run("TLSv12", func(t *testing.T) { testCrossVersionResume(t, VersionTLS12) })
++	//t.Run("TLSv13", func(t *testing.T) { testCrossVersionResume(t, VersionTLS13) })
+ }
+ 
+ func testCrossVersionResume(t *testing.T, version uint16) {
+-- 
+2.41.0
+

base-commit: 91b18baa4274a025d28f06133682a9269217730d
-- 
2.41.0