Files
EdgeCommon/pkg/serverconfigs/sslconfigs/ssl_cert_config_test.go

33 lines
747 B
Go
Raw Normal View History

2024-05-17 18:28:59 +08:00
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
2021-12-13 14:58:45 +08:00
2023-11-18 09:50:34 +08:00
package sslconfigs_test
2021-12-13 14:58:45 +08:00
import (
2023-11-18 09:50:34 +08:00
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
2021-12-13 14:58:45 +08:00
"github.com/iwind/TeaGo/assert"
"testing"
)
func TestSSLCertConfig_MatchDomain(t *testing.T) {
var a = assert.NewAssertion(t)
2023-11-18 09:50:34 +08:00
var cert = &sslconfigs.SSLCertConfig{
2021-12-13 14:58:45 +08:00
DNSNames: []string{"a.com", "b.com"},
}
a.IsTrue(cert.MatchDomain("a.com"))
a.IsFalse(cert.MatchDomain("z.com"))
}
2023-11-18 09:50:34 +08:00
/**func TestSSLCertConfig_DNSNames(t *testing.T) {
var config = sslconfigs.SSLCertConfig{}
config.CertData = []byte(`YOUR CERT DATA`)
config.KeyData = []byte(`YOUR KEY DATA`)
err := config.Init(context.Background())
if err != nil {
t.Fatal(err)
}
t.Log(config.DNSNames)
}**/