github.com/vmware/govmomi@v0.51.0/vim25/soap/error_test.go (about) 1 // © Broadcom. All Rights Reserved. 2 // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 3 // SPDX-License-Identifier: Apache-2.0 4 5 package soap 6 7 import ( 8 "crypto/tls" 9 "crypto/x509" 10 "testing" 11 ) 12 13 func TestIsCertificateUntrusted(t *testing.T) { 14 type args struct { 15 } 16 tests := []struct { 17 name string 18 err error 19 want bool 20 }{ 21 { 22 name: "tls.CertificateVerificationError", 23 err: x509.HostnameError{ 24 Certificate: &x509.Certificate{}, 25 Host: "1.2.3.4", 26 }, 27 want: true, 28 }, 29 { 30 name: "tls.CertificateVerificationError", 31 err: &tls.CertificateVerificationError{ 32 UnverifiedCertificates: []*x509.Certificate{ 33 &x509.Certificate{}, 34 }, 35 Err: x509.HostnameError{ 36 Certificate: &x509.Certificate{}, 37 Host: "5.6.7.8", 38 }, 39 }, 40 want: true, 41 }, 42 } 43 for _, tt := range tests { 44 t.Run(tt.name, func(t *testing.T) { 45 if got := IsCertificateUntrusted(tt.err); got != tt.want { 46 t.Errorf("IsCertificateUntrusted() = %v, want %v", got, tt.want) 47 } 48 }) 49 } 50 }