From 8b455deef5597ea1d5af9b168028bc8a087a0e8c Mon Sep 17 00:00:00 2001 From: Mile Druzijanic <153705375+zedGGs@users.noreply.github.com> Date: Wed, 17 Jan 2024 00:24:11 +0100 Subject: [PATCH] removing Roots deprecated Subjects field in tests (#6907) --- credentials/tls/certprovider/pemfile/watcher_test.go | 11 ++--------- credentials/tls/certprovider/store_test.go | 11 ++--------- vet.sh | 2 -- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/credentials/tls/certprovider/pemfile/watcher_test.go b/credentials/tls/certprovider/pemfile/watcher_test.go index 521f762d3a41..3f015833f2c5 100644 --- a/credentials/tls/certprovider/pemfile/watcher_test.go +++ b/credentials/tls/certprovider/pemfile/watcher_test.go @@ -26,8 +26,6 @@ import ( "testing" "time" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "google.golang.org/grpc/credentials/tls/certprovider" "google.golang.org/grpc/internal/grpctest" "google.golang.org/grpc/internal/testutils" @@ -63,15 +61,10 @@ func compareKeyMaterial(got, want *certprovider.KeyMaterial) error { } } - // x509.CertPool contains only unexported fields some of which contain other - // unexported fields. So usage of cmp.AllowUnexported() or - // cmpopts.IgnoreUnexported() does not help us much here. Also, the standard - // library does not provide a way to compare CertPool values. Comparing the - // subjects field of the certs in the CertPool seems like a reasonable - // approach. - if gotR, wantR := got.Roots.Subjects(), want.Roots.Subjects(); !cmp.Equal(gotR, wantR, cmpopts.EquateEmpty()) { + if gotR, wantR := got.Roots, want.Roots; !gotR.Equal(wantR) { return fmt.Errorf("keyMaterial roots = %v, want %v", gotR, wantR) } + return nil } diff --git a/credentials/tls/certprovider/store_test.go b/credentials/tls/certprovider/store_test.go index dce61912977b..d6f673b85713 100644 --- a/credentials/tls/certprovider/store_test.go +++ b/credentials/tls/certprovider/store_test.go @@ -28,8 +28,6 @@ import ( "testing" "time" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "google.golang.org/grpc/internal/grpctest" "google.golang.org/grpc/internal/testutils" "google.golang.org/grpc/testdata" @@ -162,15 +160,10 @@ func compareKeyMaterial(got, want *KeyMaterial) error { } } - // x509.CertPool contains only unexported fields some of which contain other - // unexported fields. So usage of cmp.AllowUnexported() or - // cmpopts.IgnoreUnexported() does not help us much here. Also, the standard - // library does not provide a way to compare CertPool values. Comparing the - // subjects field of the certs in the CertPool seems like a reasonable - // approach. - if gotR, wantR := got.Roots.Subjects(), want.Roots.Subjects(); !cmp.Equal(gotR, wantR, cmpopts.EquateEmpty()) { + if gotR, wantR := got.Roots, want.Roots; !gotR.Equal(wantR) { return fmt.Errorf("keyMaterial roots = %v, want %v", gotR, wantR) } + return nil } diff --git a/vet.sh b/vet.sh index a4990e058336..5da38a40996f 100755 --- a/vet.sh +++ b/vet.sh @@ -185,8 +185,6 @@ GetSafeRegexMatch GetSuffixMatch GetTlsCertificateCertificateProviderInstance GetValidationContextCertificateProviderInstance -XXXXX TODO: Remove the below deprecation usages: -Roots.Subjects XXXXX PleaseIgnoreUnused' echo SUCCESS