go_sysutils/cryptparse/funcs_test.go
brent saner 4cb0403e08
v1.7.1
FIX:
* cryptparse/ParseCipher* funcs were not properly building cipher name
  comparison map
2024-09-09 13:42:56 -04:00

38 lines
747 B
Go

package cryptparse
import (
`crypto/tls`
"testing"
)
func TestCiphers(t *testing.T) {
var err error
var cs *tls.CipherSuite
// Good ciphers
for _, cn := range []string{
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
"tls ecdhe ecdsa with chacha20 poly1305 sha256",
} {
if cs, err = ParseTlsCipherSuiteStrict(cn); err != nil {
t.Fatalf("ERROR parsing good cipher '%s': %v", cn, err)
}
if cs.Name != cn {
t.Logf("Cipher name change: '%s' => '%s'", cn, cs.Name)
}
t.Logf("Cipher for '%s':\n%#v", cn, cs)
}
// Bad ciphers
for _, cn := range []string{
"TLS_BAD_CIPHER",
} {
if cs, err = ParseTlsCipherSuiteStrict(cn); err == nil {
t.Fatalf("ERROR parsing bad cipher '%s'; err is nil", cn)
}
}
_ = cs
}