cipher_suites_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2018 The etcd Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package tlsutil
  15. import (
  16. "go/importer"
  17. "reflect"
  18. "strings"
  19. "testing"
  20. )
  21. func TestGetCipherSuites(t *testing.T) {
  22. pkg, err := importer.For("source", nil).Import("crypto/tls")
  23. if err != nil {
  24. t.Fatal(err)
  25. }
  26. cm := make(map[string]uint16)
  27. for _, s := range pkg.Scope().Names() {
  28. if strings.HasPrefix(s, "TLS_RSA_") || strings.HasPrefix(s, "TLS_ECDHE_") {
  29. v, ok := GetCipherSuite(s)
  30. if !ok {
  31. t.Fatalf("Go implements missing cipher suite %q (%v)", s, v)
  32. }
  33. cm[s] = v
  34. }
  35. }
  36. if !reflect.DeepEqual(cm, cipherSuites) {
  37. t.Fatalf("found unmatched cipher suites %v (Go) != %v", cm, cipherSuites)
  38. }
  39. }