Skip to content

Commit 3338472

Browse files
committed
remove tests made redundant in Go 1.26.1 by golang/go#70942
1 parent fb6ec15 commit 3338472

2 files changed

Lines changed: 9 additions & 34 deletions

File tree

internal/certauthority/certauthority.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2020-2025 the Pinniped contributors. All Rights Reserved.
1+
// Copyright 2020-2026 the Pinniped contributors. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

44
// Package certauthority implements a simple x509 certificate authority suitable for use in an aggregated API service.
@@ -112,6 +112,7 @@ func newInternal(commonName string, ttl time.Duration, env env) (*CA, error) {
112112
}
113113

114114
// Generate a new P256 keypair.
115+
// Note that starting in Go 1.26, the second argument to GenerateKey is often ignored.
115116
ca.privateKey, err = ecdsa.GenerateKey(elliptic.P256(), env.keygenRNG)
116117
if err != nil {
117118
return nil, fmt.Errorf("could not generate CA private key: %w", err)
@@ -136,6 +137,7 @@ func newInternal(commonName string, ttl time.Duration, env env) (*CA, error) {
136137
}
137138

138139
// Self-sign the CA to get the DER certificate.
140+
// Note that starting in Go 1.26, the first argument to CreateCertificate is often ignored.
139141
caCertBytes, err := x509.CreateCertificate(env.signingRNG, &caTemplate, &caTemplate, &ca.privateKey.PublicKey, ca.privateKey)
140142
if err != nil {
141143
return nil, fmt.Errorf("could not issue CA certificate: %w", err)

internal/certauthority/certauthority_test.go

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2020-2025 the Pinniped contributors. All Rights Reserved.
1+
// Copyright 2020-2026 the Pinniped contributors. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

44
package certauthority
@@ -121,31 +121,12 @@ func TestNewInternal(t *testing.T) {
121121
{
122122
name: "failed to generate CA serial",
123123
env: env{
124-
serialRNG: strings.NewReader(""),
125-
keygenRNG: strings.NewReader(""),
126-
signingRNG: strings.NewReader(""),
124+
serialRNG: strings.NewReader(""),
127125
},
128126
wantErr: "could not generate CA serial: EOF",
129127
},
130-
{
131-
name: "failed to generate CA key",
132-
env: env{
133-
serialRNG: strings.NewReader(strings.Repeat("x", 64)),
134-
keygenRNG: strings.NewReader(""),
135-
signingRNG: strings.NewReader(""),
136-
},
137-
wantErr: "could not generate CA private key: EOF",
138-
},
139-
{
140-
name: "failed to self-sign",
141-
env: env{
142-
serialRNG: strings.NewReader(strings.Repeat("x", 64)),
143-
keygenRNG: strings.NewReader(strings.Repeat("y", 64)),
144-
signingRNG: strings.NewReader(""),
145-
clock: func() time.Time { return now },
146-
},
147-
wantErr: "could not issue CA certificate: EOF",
148-
},
128+
// Note: Can't cause failures in GenerateKey or CreateCertificate by passing empty readers anymore
129+
// starting in Go 1.26.1, so those error cases are untested now.
149130
{
150131
name: "success",
151132
ttl: time.Minute,
@@ -247,16 +228,8 @@ func TestIssue(t *testing.T) {
247228
},
248229
wantErr: "could not generate serial number for certificate: EOF",
249230
},
250-
{
251-
name: "failed to generate keypair",
252-
ca: CA{
253-
env: env{
254-
serialRNG: strings.NewReader(strings.Repeat("x", numRandBytes)),
255-
keygenRNG: strings.NewReader(""),
256-
},
257-
},
258-
wantErr: "could not generate private key: EOF",
259-
},
231+
// Note: Can't cause failures in GenerateKey or CreateCertificate by passing empty readers anymore
232+
// starting in Go 1.26.1, so those error cases are untested now.
260233
{
261234
name: "invalid CA certificate",
262235
ca: CA{

0 commit comments

Comments
 (0)