fix test case

This commit is contained in:
Sun Yimin 2024-12-10 09:24:05 +08:00 committed by GitHub
parent a3161b7581
commit 1d894ef955
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -37,23 +37,23 @@ func TestCreateCertificateRequest(t *testing.T) {
Country: []string{"CN"},
},
}
_, err = smx509.CreateCFCACertificateRequest(random, template, "", "", "")
_, err = CreateCertificateRequest(random, template, "", "", "")
if err == nil || err.Error() != "x509: certificate private key does not implement crypto.Signer" {
t.Fatal("certificate private key does not implement crypto.Signer")
}
_, err = smx509.CreateCFCACertificateRequest(random, template, certKey, "", "")
_, err = CreateCertificateRequest(random, template, certKey, "", "")
if err == nil || err.Error() != "x509: tmp private key does not implement crypto.Signer" {
t.Fatal("tmp private key does not implement crypto.Signer")
}
_, err = smx509.CreateCFCACertificateRequest(random, template, certKey, invalidTmpKey, "")
_, err = CreateCertificateRequest(random, template, certKey, invalidTmpKey, "")
if err == nil || err.Error() != "x509: only SM2 public key is supported" {
t.Fatal("only SM2 public key is supported")
}
_, err = smx509.CreateCFCACertificateRequest(random, template, certKey, tmpKey, "")
_, err = CreateCertificateRequest(random, template, certKey, tmpKey, "")
if err == nil || err.Error() != "x509: challenge password is required" {
t.Fatal("challenge password is required")
}
csrDer, err := smx509.CreateCFCACertificateRequest(random, template, certKey, tmpKey, "111111")
csrDer, err := CreateCertificateRequest(random, template, certKey, tmpKey, "111111")
if err != nil {
t.Fatal(err)
}