| 1 |
package keypair |
| 2 |
|
| 3 |
import ( |
| 4 |
"errors" |
| 5 |
"testing" |
| 6 |
) |
| 7 |
|
| 8 |
func TestEmptyPublicKeyError_Error(t *testing.T) { |
| 9 |
err := EmptyPublicKeyError{} |
| 10 |
expected := "public key cannot be empty" |
| 11 |
if err.Error() != expected { |
| 12 |
t.Errorf("EmptyPublicKeyError.Error() = %q, want %q", err.Error(), expected) |
| 13 |
} |
| 14 |
} |
| 15 |
|
| 16 |
func TestInvalidPublicKeyError_Error(t *testing.T) { |
| 17 |
originalErr := errors.New("test error") |
| 18 |
err := InvalidPublicKeyError{Err: originalErr} |
| 19 |
expected := "invalid public key: test error" |
| 20 |
if err.Error() != expected { |
| 21 |
t.Errorf("InvalidPublicKeyError.Error() = %q, want %q", err.Error(), expected) |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
func TestEmptyPrivateKeyError_Error(t *testing.T) { |
| 26 |
err := EmptyPrivateKeyError{} |
| 27 |
expected := "private key cannot be empty" |
| 28 |
if err.Error() != expected { |
| 29 |
t.Errorf("EmptyPrivateKeyError.Error() = %q, want %q", err.Error(), expected) |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
func TestInvalidPrivateKeyError_Error(t *testing.T) { |
| 34 |
originalErr := errors.New("test error") |
| 35 |
err := InvalidPrivateKeyError{Err: originalErr} |
| 36 |
expected := " invalid private key: test error" |
| 37 |
if err.Error() != expected { |
| 38 |
t.Errorf("InvalidPrivateKeyError.Error() = %q, want %q", err.Error(), expected) |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
func TestEmptyFormatError_Error(t *testing.T) { |
| 43 |
err := EmptyFormatError{} |
| 44 |
expected := "key format cannot be empty, please call SetFormat() to set key format (PKCS1/PKCS8)" |
| 45 |
if err.Error() != expected { |
| 46 |
t.Errorf("EmptyFormatError.Error() = %q, want %q", err.Error(), expected) |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
func TestUnsupportedKeyFormatError_Error(t *testing.T) { |
| 51 |
err := UnsupportedKeyFormatError{} |
| 52 |
expected := "unsupported key format, only PKCS1 and PKCS8 are supported" |
| 53 |
if err.Error() != expected { |
| 54 |
t.Errorf("UnsupportedKeyFormatError.Error() = %q, want %q", err.Error(), expected) |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
func TestEmptyPaddingError_Error(t *testing.T) { |
| 59 |
err := EmptyPaddingError{} |
| 60 |
expected := "padding scheme cannot be empty, please call SetPadding() to set padding scheme (PKCS1v15/OAEP/PSS)" |
| 61 |
if err.Error() != expected { |
| 62 |
t.Errorf("EmptyPaddingError.Error() = %q, want %q", err.Error(), expected) |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
func TestUnsupportedPaddingSchemeError_Error(t *testing.T) { |
| 67 |
err := UnsupportedPaddingSchemeError{Padding: "InvalidPadding"} |
| 68 |
expected := "unsupported padding scheme: InvalidPadding, only PKCS1v15, OAEP, and PSS are supported" |
| 69 |
if err.Error() != expected { |
| 70 |
t.Errorf("UnsupportedPaddingSchemeError.Error() = %q, want %q", err.Error(), expected) |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
func TestEmptySignatureError_Error(t *testing.T) { |
| 75 |
err := EmptySignatureError{} |
| 76 |
expected := "no signature provided for verification" |
| 77 |
if err.Error() != expected { |
| 78 |
t.Errorf("EmptySignatureError.Error() = %q, want %q", err.Error(), expected) |
| 79 |
} |
| 80 |
} |