forked from TrueCloudLab/certificates
Add missing close causing panic with softhsm2.
This commit is contained in:
parent
a74fc7a0b2
commit
b28db61d5d
1 changed files with 3 additions and 9 deletions
|
@ -29,6 +29,9 @@ func TestNew(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
k := mustPKCS11(t)
|
k := mustPKCS11(t)
|
||||||
|
t.Cleanup(func() {
|
||||||
|
k.Close()
|
||||||
|
})
|
||||||
p11Configure = func(config *crypto11.Config) (P11, error) {
|
p11Configure = func(config *crypto11.Config) (P11, error) {
|
||||||
if strings.Index(config.Path, "fail") >= 0 {
|
if strings.Index(config.Path, "fail") >= 0 {
|
||||||
return nil, errors.New("an error")
|
return nil, errors.New("an error")
|
||||||
|
@ -333,10 +336,6 @@ func TestPKCS11_CreateKey(t *testing.T) {
|
||||||
Name: "pkcs11:id=9999;object=create-key",
|
Name: "pkcs11:id=9999;object=create-key",
|
||||||
SignatureAlgorithm: apiv1.SignatureAlgorithm(100),
|
SignatureAlgorithm: apiv1.SignatureAlgorithm(100),
|
||||||
}}, nil, true},
|
}}, nil, true},
|
||||||
{"fail uri", args{&apiv1.CreateKeyRequest{
|
|
||||||
Name: "pkcs11:id=xxxx;object=https",
|
|
||||||
SignatureAlgorithm: apiv1.SHA256WithRSAPSS,
|
|
||||||
}}, nil, true},
|
|
||||||
{"fail FindKeyPair", args{&apiv1.CreateKeyRequest{
|
{"fail FindKeyPair", args{&apiv1.CreateKeyRequest{
|
||||||
Name: "pkcs11:foo=bar",
|
Name: "pkcs11:foo=bar",
|
||||||
SignatureAlgorithm: apiv1.SHA256WithRSAPSS,
|
SignatureAlgorithm: apiv1.SHA256WithRSAPSS,
|
||||||
|
@ -509,9 +508,6 @@ func TestPKCS11_LoadCertificate(t *testing.T) {
|
||||||
{"fail name", args{&apiv1.LoadCertificateRequest{
|
{"fail name", args{&apiv1.LoadCertificateRequest{
|
||||||
Name: "",
|
Name: "",
|
||||||
}}, nil, true},
|
}}, nil, true},
|
||||||
{"fail uri", args{&apiv1.LoadCertificateRequest{
|
|
||||||
Name: "pkcs11:id=xxxx;object=test-root",
|
|
||||||
}}, nil, true},
|
|
||||||
{"fail scheme", args{&apiv1.LoadCertificateRequest{
|
{"fail scheme", args{&apiv1.LoadCertificateRequest{
|
||||||
Name: "foo:id=7376;object=test-root",
|
Name: "foo:id=7376;object=test-root",
|
||||||
}}, nil, true},
|
}}, nil, true},
|
||||||
|
@ -629,7 +625,6 @@ func TestPKCS11_DeleteKey(t *testing.T) {
|
||||||
{"delete by label", args{testObjectByLabel}, false},
|
{"delete by label", args{testObjectByLabel}, false},
|
||||||
{"delete missing", args{"pkcs11:id=9999;object=missing-key"}, false},
|
{"delete missing", args{"pkcs11:id=9999;object=missing-key"}, false},
|
||||||
{"fail name", args{""}, true},
|
{"fail name", args{""}, true},
|
||||||
{"fail uri", args{"pkcs11:id=xxxx;object=missing-key"}, true},
|
|
||||||
{"fail FindKeyPair", args{"pkcs11:foo=bar"}, true},
|
{"fail FindKeyPair", args{"pkcs11:foo=bar"}, true},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
@ -681,7 +676,6 @@ func TestPKCS11_DeleteCertificate(t *testing.T) {
|
||||||
{"delete by label", args{testObjectByLabel}, false},
|
{"delete by label", args{testObjectByLabel}, false},
|
||||||
{"delete missing", args{"pkcs11:id=9999;object=missing-key"}, false},
|
{"delete missing", args{"pkcs11:id=9999;object=missing-key"}, false},
|
||||||
{"fail name", args{""}, true},
|
{"fail name", args{""}, true},
|
||||||
{"fail uri", args{"pkcs11:id=xxxx;object=missing-key"}, true},
|
|
||||||
{"fail DeleteCertificate", args{"pkcs11:foo=bar"}, true},
|
{"fail DeleteCertificate", args{"pkcs11:foo=bar"}, true},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|
Loading…
Reference in a new issue