@@ -175,6 +175,13 @@ func mustEqualPrivateKey(t *testing.T, x, y crypto.PrivateKey) {
175175 require .True (t , xx .Equal (y ))
176176}
177177
178+ func assertNotFoundError (t assert.TestingT , err error , msgAndArgs ... any ) bool {
179+ if h , ok := t .(interface { Helper () }); ok {
180+ h .Helper ()
181+ }
182+ return assert .ErrorIs (t , err , apiv1.NotFoundError {}, msgAndArgs ... )
183+ }
184+
178185type createOptions struct {
179186 name string
180187 noCleanup bool
@@ -686,7 +693,7 @@ func TestKMS_CreateSigner(t *testing.T) {
686693 }, assert .NoError },
687694 {"fail missing" , softKMS , args {& apiv1.CreateSignerRequest {
688695 SigningKey : "kms:name=" + url .QueryEscape (filepath .Join (dir , "missing.key" )),
689- }}, assertNil , assert . Error },
696+ }}, assertNil , assertNotFoundError },
690697 {"fail parseURI" , softKMS , args {& apiv1.CreateSignerRequest {
691698 SigningKey : privateKeyPath ,
692699 }}, assertNil , assert .Error },
@@ -749,7 +756,7 @@ func TestKMS_DeleteKey(t *testing.T) {
749756 }}, assert .Error },
750757 {"fail platform missing" , platformKMS , args {& apiv1.DeleteKeyRequest {
751758 Name : platformMissingName ,
752- }}, assert . Error },
759+ }}, assertNotFoundError },
753760
754761 // SoftKMS
755762 {"ok softKMS" , softKMS , args {& apiv1.DeleteKeyRequest {
@@ -760,7 +767,7 @@ func TestKMS_DeleteKey(t *testing.T) {
760767 }},
761768 {"fail missing" , softKMS , args {& apiv1.DeleteKeyRequest {
762769 Name : "kms:name=" + url .QueryEscape (filepath .Join (dir , "missing.key" )),
763- }}, assert . Error },
770+ }}, assertNotFoundError },
764771 {"fail parseURI" , softKMS , args {& apiv1.DeleteKeyRequest {
765772 Name : keyPath2 ,
766773 }}, func (tt assert.TestingT , err error , i ... interface {}) bool {
@@ -815,7 +822,7 @@ func TestKMS_LoadCertificate(t *testing.T) {
815822 }}, platformChain [0 ], assert .NoError },
816823 {"fail platform missing" , platformKMS , args {& apiv1.LoadCertificateRequest {
817824 Name : platformMissingName ,
818- }}, nil , assert . Error },
825+ }}, nil , assertNotFoundError },
819826
820827 // SoftKMS
821828 {"ok softKMS" , softKMS , args {& apiv1.LoadCertificateRequest {
@@ -826,7 +833,7 @@ func TestKMS_LoadCertificate(t *testing.T) {
826833 }}, chain [0 ], assert .NoError },
827834 {"fail missing" , softKMS , args {& apiv1.LoadCertificateRequest {
828835 Name : "kms:name=" + filepath .Join (dir , "missing.crt" ),
829- }}, nil , assert . Error },
836+ }}, nil , assertNotFoundError },
830837 {"fail parseURI" , softKMS , args {& apiv1.LoadCertificateRequest {
831838 Name : "foo:name=" + certPath ,
832839 }}, nil , assert .Error },
@@ -973,7 +980,7 @@ func TestKMS_LoadCertificateChain(t *testing.T) {
973980 }}, nil , assert .Error },
974981 {"fail missing" , softKMS , args {& apiv1.LoadCertificateChainRequest {
975982 Name : "kms:name=" + filepath .Join (dir , "missing.crt" ),
976- }}, nil , assert . Error },
983+ }}, nil , assertNotFoundError },
977984 {"fail parseuri" , softKMS , args {& apiv1.LoadCertificateChainRequest {
978985 Name : "softkms:name=" + chainPath ,
979986 }}, nil , assert .Error },
@@ -1111,7 +1118,7 @@ func TestKMS_DeleteCertificate(t *testing.T) {
11111118 }},
11121119 {"fail platform missing" , platformKMS , args {& apiv1.DeleteCertificateRequest {
11131120 Name : platformMissingName ,
1114- }}, assert . Error },
1121+ }}, assertNotFoundError },
11151122
11161123 // SoftKMS
11171124 {"ok softKMS" , softKMS , args {& apiv1.DeleteCertificateRequest {
@@ -1122,7 +1129,7 @@ func TestKMS_DeleteCertificate(t *testing.T) {
11221129 }},
11231130 {"fail missing" , softKMS , args {& apiv1.DeleteCertificateRequest {
11241131 Name : "kms:name=" + url .QueryEscape (filepath .Join (dir , "chain.crt" )),
1125- }}, assert . Error },
1132+ }}, assertNotFoundError },
11261133 {"fail parseURI" , softKMS , args {& apiv1.DeleteCertificateRequest {
11271134 Name : "foo" ,
11281135 }}, assert .Error },
@@ -1186,7 +1193,7 @@ func TestKMS_CreateAttestation(t *testing.T) {
11861193 {"fail missing key" , softKMS , args {& apiv1.CreateAttestationRequest {
11871194 Name : "kms:" + platformMissingName ,
11881195 AttestationClient : okClient ,
1189- }}, nil , assert . Error },
1196+ }}, nil , assertNotFoundError },
11901197 {"fail custom attestation" , softKMS , args {& apiv1.CreateAttestationRequest {
11911198 Name : "kms:" + privateKeyPath ,
11921199 AttestationClient : failClient ,
0 commit comments