Fix: trust-all remained enabled always
This commit is contained in:
parent
1cfea47696
commit
8ca0f5781c
|
@ -105,6 +105,10 @@ func (cfg *Config) LoadJSON(raw []byte) error {
|
|||
|
||||
func (cfg *Config) applyJSONConfig(jcfg *jsonConfig) error {
|
||||
config.SetIfNotDefault(jcfg.ClusterName, &cfg.ClusterName)
|
||||
|
||||
// Whenever we parse JSON, TrustAll is false unless an '*' peer exists
|
||||
cfg.TrustAll = false
|
||||
|
||||
for _, p := range jcfg.TrustedPeers {
|
||||
if p == "*" {
|
||||
cfg.TrustAll = true
|
||||
|
|
|
@ -18,8 +18,8 @@ func TestLoadJSON(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cfg.TrustAll != DefaultTrustAll {
|
||||
t.Error("expected TrustAll to be the default")
|
||||
if cfg.TrustAll {
|
||||
t.Error("TrustAll should not be enabled when peers in trusted peers")
|
||||
}
|
||||
|
||||
cfg = &Config{}
|
||||
|
@ -36,6 +36,16 @@ func TestLoadJSON(t *testing.T) {
|
|||
cfg = &Config{}
|
||||
err = cfg.LoadJSON([]byte(`
|
||||
{
|
||||
"cluster_name": "test",
|
||||
"trusted_peers": []
|
||||
}`))
|
||||
if cfg.TrustAll {
|
||||
t.Error("TrustAll is only enabled with '*'")
|
||||
}
|
||||
|
||||
cfg = &Config{}
|
||||
err = cfg.LoadJSON([]byte(`
|
||||
{
|
||||
"cluster_name": "test",
|
||||
"trusted_peers": ["QmUZ13osndQ5uL4tPWHXe3iBgBgq9gfewcBMSCAuMBsDJ6", "*"]
|
||||
}`))
|
||||
|
|
Loading…
Reference in New Issue
Block a user