oficina / home Public

Clone
git clone https://amadan.net/oficina/home

Plain git — no account needed to clone.

Download

Download this file

1//go:build linux
2
3package operator
4
5import "testing"
6
7func TestSchemaCommandStaysOutsidePublicDispatch(t *testing.T) {
8 _, _, v, a := schemaWireFixture(t)
9 c := schemaCommandConfigV2{commandConfig{2, "bds", "home", "id.example.test", a.Role, a.Origin, a.Installation, a.Registry, a.Device, v.base.pins.PublicKey, v.base.kid, v.base.pins.Actions}, a.SchemaProfile, a.SchemaManifestDigest}
10 raw, err := encode(c)
11 if err != nil {
12 t.Fatal(err)
13 }
14 if _, _, err := parseSchemaCommandConfigV2(raw); err != nil {
15 t.Fatal(err)
16 }
17 if _, _, err := parseCommandConfig(string(raw)); err == nil {
18 t.Fatal("mounted config parser accepted v2")
19 }
20 old := c.commandConfig
21 old.Version = 1
22 wire, err := encode(old)
23 if err != nil {
24 t.Fatal(err)
25 }
26 if _, _, err := parseSchemaCommandConfigV2(wire); err == nil {
27 t.Fatal("private v2 config parser accepted v1")
28 }
29 if _, _, err := parseCommandConfig(string(wire)); err != nil {
30 t.Fatal("v1 config regressed", err)
31 }
32 c.Version = 1
33 wire, _ = encode(c)
34 if _, _, err := parseCommandConfig(string(wire)); err == nil {
35 t.Fatal("v1 accepted schema fields")
36 }
37}
38