cfca: update test error message

This commit is contained in:
Sun Yimin 2024-12-13 08:20:48 +08:00 committed by GitHub
parent 1bbcc232db
commit d2e96cff57
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 8 deletions

View File

@ -39,19 +39,19 @@ func TestCreateCertificateRequest(t *testing.T) {
}
_, 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")
t.Fatalf("expect certificate private key does not implement crypto.Signer, got %v", err)
}
_, err = CreateCertificateRequest(random, template, certKey, "", "")
if err == nil || err.Error() != "x509: only SM2 public key is supported" {
t.Fatal("only SM2 public key is supported")
t.Fatalf("expect only SM2 public key is supported, got %v", err)
}
_, err = CreateCertificateRequest(random, template, certKey, invalidTmpKey.Public(), "")
if err == nil || err.Error() != "x509: only SM2 public key is supported" {
t.Fatal("only SM2 public key is supported")
t.Fatalf("expect only SM2 public key is supported, got %v", err)
}
_, err = CreateCertificateRequest(random, template, certKey, tmpKey.Public(), "")
if err == nil || err.Error() != "x509: challenge password is required" {
t.Fatal("challenge password is required")
t.Fatalf("expect challenge password is required, got %v", err)
}
csrDer, err := CreateCertificateRequest(random, template, certKey, tmpKey.Public(), "111111")
if err != nil {

View File

@ -39,19 +39,19 @@ func TestCreateCFCACertificateRequest(t *testing.T) {
}
_, err = CreateCFCACertificateRequest(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")
t.Fatalf("expect certificate private key does not implement crypto.Signer, got %v", err)
}
_, err = CreateCFCACertificateRequest(random, template, certKey, "", "")
if err == nil || err.Error() != "x509: only SM2 public key is supported" {
t.Fatal("only SM2 public key is supported")
t.Fatalf("expected only SM2 public key is supported, got %v", err)
}
_, err = CreateCFCACertificateRequest(random, template, certKey, invalidTmpKey.Public(), "")
if err == nil || err.Error() != "x509: only SM2 public key is supported" {
t.Fatal("only SM2 public key is supported")
t.Fatalf("expect only SM2 public key is supported, got %v", err)
}
_, err = CreateCFCACertificateRequest(random, template, certKey, tmpKey.Public(), "")
if err == nil || err.Error() != "x509: challenge password is required" {
t.Fatal("challenge password is required")
t.Fatalf("expect challenge password is required, got %v", err)
}
csrDer, err := CreateCFCACertificateRequest(random, template, certKey, tmpKey.Public(), "111111")
if err != nil {