mirror of
https://github.com/wyx2685/V2bX.git
synced 2025-01-23 02:18:13 -05:00
83 lines
1.6 KiB
Go
83 lines
1.6 KiB
Go
|
package legocmd_test
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/Yuzuki616/V2bX/common/legocmd"
|
||
|
)
|
||
|
|
||
|
func TestLegoClient(t *testing.T) {
|
||
|
_, err := legocmd.New()
|
||
|
if err != nil {
|
||
|
t.Error(err)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestLegoDNSCert(t *testing.T) {
|
||
|
lego, err := legocmd.New()
|
||
|
if err != nil {
|
||
|
t.Error(err)
|
||
|
}
|
||
|
var (
|
||
|
domain string = "node1.test.com"
|
||
|
email string = "test@gmail.com"
|
||
|
provider string = "alidns"
|
||
|
DNSEnv map[string]string
|
||
|
)
|
||
|
DNSEnv = make(map[string]string)
|
||
|
DNSEnv["ALICLOUD_ACCESS_KEY"] = "aaa"
|
||
|
DNSEnv["ALICLOUD_SECRET_KEY"] = "bbb"
|
||
|
certPath, keyPath, err := lego.DNSCert(domain, email, provider, DNSEnv)
|
||
|
if err != nil {
|
||
|
t.Error(err)
|
||
|
}
|
||
|
t.Log(certPath)
|
||
|
t.Log(keyPath)
|
||
|
}
|
||
|
|
||
|
func TestLegoHTTPCert(t *testing.T) {
|
||
|
lego, err := legocmd.New()
|
||
|
if err != nil {
|
||
|
t.Error(err)
|
||
|
}
|
||
|
var (
|
||
|
domain string = "node1.test.com"
|
||
|
email string = "test@gmail.com"
|
||
|
)
|
||
|
certPath, keyPath, err := lego.HTTPCert(domain, email)
|
||
|
if err != nil {
|
||
|
t.Error(err)
|
||
|
}
|
||
|
t.Log(certPath)
|
||
|
t.Log(keyPath)
|
||
|
}
|
||
|
|
||
|
func TestLegoRenewCert(t *testing.T) {
|
||
|
lego, err := legocmd.New()
|
||
|
if err != nil {
|
||
|
t.Error(err)
|
||
|
}
|
||
|
var (
|
||
|
domain string = "node1.test.com"
|
||
|
email string = "test@gmail.com"
|
||
|
provider string = "alidns"
|
||
|
DNSEnv map[string]string
|
||
|
)
|
||
|
DNSEnv = make(map[string]string)
|
||
|
DNSEnv["ALICLOUD_ACCESS_KEY"] = "aaa"
|
||
|
DNSEnv["ALICLOUD_SECRET_KEY"] = "bbb"
|
||
|
certPath, keyPath, err := lego.RenewCert(domain, email, "dns", provider, DNSEnv)
|
||
|
if err != nil {
|
||
|
t.Error(err)
|
||
|
}
|
||
|
t.Log(certPath)
|
||
|
t.Log(keyPath)
|
||
|
|
||
|
certPath, keyPath, err = lego.RenewCert(domain, email, "http", provider, DNSEnv)
|
||
|
if err != nil {
|
||
|
t.Error(err)
|
||
|
}
|
||
|
t.Log(certPath)
|
||
|
t.Log(keyPath)
|
||
|
}
|