add cert info and renewal api

This commit is contained in:
yusing
2025-02-15 21:50:34 +08:00
parent 7129e2cc9d
commit 16b046bd44
15 changed files with 201 additions and 47 deletions

View File

@@ -43,6 +43,7 @@ type (
GetAgent(agentAddrOrDockerHost string) (*agent.AgentConfig, bool)
AddAgent(host string, ca agent.PEMPair, client agent.PEMPair) (int, gperr.Error)
ListAgents() []*agent.AgentConfig
AutoCertProvider() *autocert.Provider
}
)

View File

@@ -0,0 +1,42 @@
package types
import (
"testing"
"github.com/yusing/go-proxy/internal/gperr"
"github.com/yusing/go-proxy/internal/utils"
. "github.com/yusing/go-proxy/internal/utils/testing"
)
func TestValidateConfig(t *testing.T) {
cases := []struct {
name string
data []byte
want gperr.Error
}{
{
name: "valid config",
data: []byte(`
autocert:
provider: local
`),
want: nil,
},
{
name: "unknown field",
data: []byte(`
autocert:
provider: local
unknown: true
`),
want: utils.ErrUnknownField,
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
got := Validate(c.data)
ExpectError(t, c.want, got)
})
}
}