feat(home): implement home control plane integration with Redis and TLS support
This commit is contained in:
+13
-4
@@ -2,8 +2,17 @@ package config
|
||||
|
||||
// HomeConfig configures the optional "home" control plane integration over Redis protocol.
|
||||
type HomeConfig struct {
|
||||
Enabled bool `yaml:"enabled" json:"enabled"`
|
||||
Host string `yaml:"host" json:"-"`
|
||||
Port int `yaml:"port" json:"-"`
|
||||
Password string `yaml:"password" json:"-"`
|
||||
Enabled bool `yaml:"enabled" json:"enabled"`
|
||||
Host string `yaml:"host" json:"-"`
|
||||
Port int `yaml:"port" json:"-"`
|
||||
Password string `yaml:"password" json:"-"`
|
||||
TLS HomeTLSConfig `yaml:"tls" json:"-"`
|
||||
}
|
||||
|
||||
// HomeTLSConfig configures client-side TLS for the home Redis connection.
|
||||
type HomeTLSConfig struct {
|
||||
Enable bool `yaml:"enable" json:"-"`
|
||||
ServerName string `yaml:"server-name" json:"-"`
|
||||
InsecureSkipVerify bool `yaml:"insecure-skip-verify" json:"-"`
|
||||
CACert string `yaml:"ca-cert" json:"-"`
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package config
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestParseConfigBytesHomeTLS(t *testing.T) {
|
||||
cfg, err := ParseConfigBytes([]byte(`
|
||||
home:
|
||||
enabled: true
|
||||
host: home.example.com
|
||||
port: 444
|
||||
password: secret
|
||||
tls:
|
||||
enable: true
|
||||
server-name: home.example.com
|
||||
ca-cert: C:/certs/ca.pem
|
||||
insecure-skip-verify: true
|
||||
`))
|
||||
if err != nil {
|
||||
t.Fatalf("ParseConfigBytes() error = %v", err)
|
||||
}
|
||||
|
||||
if !cfg.Home.Enabled {
|
||||
t.Fatal("Home.Enabled = false, want true")
|
||||
}
|
||||
if cfg.Home.Host != "home.example.com" {
|
||||
t.Fatalf("Home.Host = %q, want home.example.com", cfg.Home.Host)
|
||||
}
|
||||
if cfg.Home.Port != 444 {
|
||||
t.Fatalf("Home.Port = %d, want 444", cfg.Home.Port)
|
||||
}
|
||||
if cfg.Home.Password != "secret" {
|
||||
t.Fatalf("Home.Password = %q, want secret", cfg.Home.Password)
|
||||
}
|
||||
if !cfg.Home.TLS.Enable {
|
||||
t.Fatal("Home.TLS.Enable = false, want true")
|
||||
}
|
||||
if cfg.Home.TLS.ServerName != "home.example.com" {
|
||||
t.Fatalf("Home.TLS.ServerName = %q, want home.example.com", cfg.Home.TLS.ServerName)
|
||||
}
|
||||
if cfg.Home.TLS.CACert != "C:/certs/ca.pem" {
|
||||
t.Fatalf("Home.TLS.CACert = %q, want C:/certs/ca.pem", cfg.Home.TLS.CACert)
|
||||
}
|
||||
if !cfg.Home.TLS.InsecureSkipVerify {
|
||||
t.Fatal("Home.TLS.InsecureSkipVerify = false, want true")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user