2022-06-04 05:12:28 -04:00
|
|
|
package legoCmd_test
|
2022-06-01 13:35:41 -04:00
|
|
|
|
|
|
|
import (
|
2022-10-09 23:31:15 -04:00
|
|
|
"github.com/Yuzuki616/V2bX/node/controller/legoCmd"
|
2022-06-01 13:35:41 -04:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestLegoClient(t *testing.T) {
|
2022-06-04 05:12:28 -04:00
|
|
|
_, err := legoCmd.New()
|
2022-06-01 13:35:41 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestLegoDNSCert(t *testing.T) {
|
2022-06-04 05:12:28 -04:00
|
|
|
lego, err := legoCmd.New()
|
2022-06-01 13:35:41 -04:00
|
|
|
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) {
|
2022-06-04 05:12:28 -04:00
|
|
|
lego, err := legoCmd.New()
|
2022-06-01 13:35:41 -04:00
|
|
|
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) {
|
2022-06-04 05:12:28 -04:00
|
|
|
lego, err := legoCmd.New()
|
2022-06-01 13:35:41 -04:00
|
|
|
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)
|
|
|
|
}
|