requests_test.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package apiv1
  2. import "testing"
  3. func TestProtectionLevel_String(t *testing.T) {
  4. tests := []struct {
  5. name string
  6. p ProtectionLevel
  7. want string
  8. }{
  9. {"unspecified", UnspecifiedProtectionLevel, "unspecified"},
  10. {"software", Software, "software"},
  11. {"hsm", HSM, "hsm"},
  12. {"unknown", ProtectionLevel(100), "unknown(100)"},
  13. }
  14. for _, tt := range tests {
  15. t.Run(tt.name, func(t *testing.T) {
  16. if got := tt.p.String(); got != tt.want {
  17. t.Errorf("ProtectionLevel.String() = %v, want %v", got, tt.want)
  18. }
  19. })
  20. }
  21. }
  22. func TestSignatureAlgorithm_String(t *testing.T) {
  23. tests := []struct {
  24. name string
  25. s SignatureAlgorithm
  26. want string
  27. }{
  28. {"UnspecifiedSignAlgorithm", UnspecifiedSignAlgorithm, "unspecified"},
  29. {"SHA256WithRSA", SHA256WithRSA, "SHA256-RSA"},
  30. {"SHA384WithRSA", SHA384WithRSA, "SHA384-RSA"},
  31. {"SHA512WithRSA", SHA512WithRSA, "SHA512-RSA"},
  32. {"SHA256WithRSAPSS", SHA256WithRSAPSS, "SHA256-RSAPSS"},
  33. {"SHA384WithRSAPSS", SHA384WithRSAPSS, "SHA384-RSAPSS"},
  34. {"SHA512WithRSAPSS", SHA512WithRSAPSS, "SHA512-RSAPSS"},
  35. {"ECDSAWithSHA256", ECDSAWithSHA256, "ECDSA-SHA256"},
  36. {"ECDSAWithSHA384", ECDSAWithSHA384, "ECDSA-SHA384"},
  37. {"ECDSAWithSHA512", ECDSAWithSHA512, "ECDSA-SHA512"},
  38. {"PureEd25519", PureEd25519, "Ed25519"},
  39. {"unknown", SignatureAlgorithm(100), "unknown(100)"},
  40. }
  41. for _, tt := range tests {
  42. t.Run(tt.name, func(t *testing.T) {
  43. if got := tt.s.String(); got != tt.want {
  44. t.Errorf("SignatureAlgorithm.String() = %v, want %v", got, tt.want)
  45. }
  46. })
  47. }
  48. }