package declaration import "testing" // `trusted` is the catalogue's word on a file (novox/hq issue 339): a controller takes it out before it sends a // declaration, and one that does not — an older one, or one rolled back to — must not cost the node its whole // declaration. So a file accepts it and the engine does nothing with it; any other resource still refuses it. func TestAFileAcceptsAndIgnoresTrusted(t *testing.T) { for _, v := range []string{"true", "false"} { d, err := Parse([]byte(`{"declaration":1,"resources":[{"id":"m.f","type":"file","path":"/etc/m.conf",` + `"content":"x","trusted":` + v + `}]}`)) if err != nil { t.Fatalf("trusted %s: %v", v, err) } if f, ok := d.Resources[0].(*File); !ok || f.Content != "x" { t.Fatalf("trusted %s: %+v", v, d.Resources[0]) } } if _, err := Parse([]byte(`{"declaration":1,"resources":[{"id":"m.d","type":"directory","path":"/srv/m",` + `"trusted":true}]}`)); err == nil { t.Fatal("a directory took trusted") } }