Skip to content

Commit

Permalink
Ignore lint issues for deprecated Pool.Subjects()
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuatcasey committed Jan 31, 2023
1 parent b9c8e35 commit 7704176
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmd/pinniped/cmd/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ func validateKubeconfig(ctx context.Context, flags getKubeconfigParams, kubeconf
func countCACerts(pemData []byte) int {
pool := x509.NewCertPool()
pool.AppendCertsFromPEM(pemData)
//nolint:staticcheck // since we're not using .Subjects() to access the system pool
return len(pool.Subjects())
}

Expand Down
3 changes: 2 additions & 1 deletion internal/certauthority/certauthority_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020-2022 the Pinniped contributors. All Rights Reserved.
// Copyright 2020-2023 the Pinniped contributors. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package certauthority
Expand Down Expand Up @@ -206,6 +206,7 @@ func TestPool(t *testing.T) {
require.NoError(t, err)

pool := ca.Pool()
//nolint:staticcheck // since we're not using .Subjects() to access the system pool
require.Len(t, pool.Subjects(), 1)
}

Expand Down
8 changes: 7 additions & 1 deletion internal/dynamiccert/provider_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021-2022 the Pinniped contributors. All Rights Reserved.
// Copyright 2021-2023 the Pinniped contributors. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package dynamiccert
Expand Down Expand Up @@ -41,6 +41,7 @@ func TestProviderWithDynamicServingCertificateController(t *testing.T) {
cert, err := tls.X509KeyPair(certPEM, keyPEM)
require.NoError(t, err)

//nolint:staticcheck // since we're not using .Subjects() to access the system pool
return pool.Subjects(), []tls.Certificate{cert}
},
},
Expand Down Expand Up @@ -69,6 +70,7 @@ func TestProviderWithDynamicServingCertificateController(t *testing.T) {

certKey.UnsetCertKeyContent()

//nolint:staticcheck // since we're not using .Subjects() to access the system pool
return pool.Subjects(), []tls.Certificate{cert}
},
},
Expand All @@ -87,6 +89,7 @@ func TestProviderWithDynamicServingCertificateController(t *testing.T) {
cert, err := tls.X509KeyPair(certPEM, keyPEM)
require.NoError(t, err)

//nolint:staticcheck // since we're not using .Subjects() to access the system pool
return newCA.Pool().Subjects(), []tls.Certificate{cert}
},
},
Expand All @@ -110,6 +113,7 @@ func TestProviderWithDynamicServingCertificateController(t *testing.T) {
ok := pool.AppendCertsFromPEM(ca.CurrentCABundleContent())
require.True(t, ok, "should have valid non-empty CA bundle")

//nolint:staticcheck // since we're not using .Subjects() to access the system pool
return pool.Subjects(), []tls.Certificate{cert}
},
},
Expand Down Expand Up @@ -137,6 +141,7 @@ func TestProviderWithDynamicServingCertificateController(t *testing.T) {
err = ca.SetCertKeyContent(newOtherCA.Bundle(), caKey)
require.NoError(t, err)

//nolint:staticcheck // since we're not using .Subjects() to access the system pool
return newOtherCA.Pool().Subjects(), []tls.Certificate{cert}
},
},
Expand Down Expand Up @@ -221,6 +226,7 @@ func poolSubjects(pool *x509.CertPool) [][]byte {
if pool == nil {
return nil
}
//nolint:staticcheck // since we're not using .Subjects() to access the system pool
return pool.Subjects()
}

Expand Down
2 changes: 2 additions & 0 deletions internal/kubeclient/kubeclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,7 @@ func TestUnwrap(t *testing.T) {

server, restConfig := fakekubeapi.Start(t, nil)

//nolint:staticcheck // since we're not using .Subjects() to access the system pool
serverSubjects := server.Client().Transport.(*http.Transport).TLSClientConfig.RootCAs.Subjects()

t.Run("regular client", func(t *testing.T) {
Expand Down Expand Up @@ -1089,6 +1090,7 @@ func testUnwrap(t *testing.T, client *Client, serverSubjects [][]byte) {
require.Equal(t, secureTLSConfig.NextProtos, tlsConfig.NextProtos)

// x509.CertPool has some embedded functions that make it hard to compare so just look at the subjects
//nolint:staticcheck // since we're not using .Subjects() to access the system pool
require.Equal(t, serverSubjects, tlsConfig.RootCAs.Subjects())
})
}
Expand Down

0 comments on commit 7704176

Please sign in to comment.