Skip to content

Commit

Permalink
cfca: update test error message
Browse files Browse the repository at this point in the history
  • Loading branch information
emmansun authored Dec 13, 2024
1 parent 1bbcc23 commit d2e96cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions cfca/pkcs10_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions smx509/cfca_csr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d2e96cf

Please sign in to comment.