mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-27 18:57:04 +02:00
add cert info and renewal api
This commit is contained in:
@@ -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
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
42
internal/config/types/config_test.go
Normal file
42
internal/config/types/config_test.go
Normal 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)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user