diff --git a/asserts/device_asserts.go b/asserts/device_asserts.go index 4aee1ec082f..46d3f50dfe5 100644 --- a/asserts/device_asserts.go +++ b/asserts/device_asserts.go @@ -24,6 +24,8 @@ import ( "time" ) +// TODO: model assertion still needs final design review! + // Model holds a model assertion, which is a statement by a brand // about the properties of a device model. type Model struct { @@ -118,16 +120,6 @@ func assembleModel(assert assertionBase) (Assertion, error) { // TODO: check 'class' value already here? fundamental policy derives from it - allowedModes, err := checkCommaSepList(assert.headers, "allowed-modes") - if err != nil { - return nil, err - } - - requiredSnaps, err := checkCommaSepList(assert.headers, "required-snaps") - if err != nil { - return nil, err - } - timestamp, err := checkRFC3339Date(assert.headers, "timestamp") if err != nil { return nil, err @@ -136,8 +128,8 @@ func assembleModel(assert assertionBase) (Assertion, error) { // ignore extra headers and non-empty body for future compatibility return &Model{ assertionBase: assert, - allowedModes: allowedModes, - requiredSnaps: requiredSnaps, + allowedModes: nil, // XXX: empty for now + requiredSnaps: nil, // XXX: empty for now timestamp: timestamp, }, nil } diff --git a/asserts/device_asserts_test.go b/asserts/device_asserts_test.go index 7bcbf3f2f3d..4710826285a 100644 --- a/asserts/device_asserts_test.go +++ b/asserts/device_asserts_test.go @@ -78,8 +78,9 @@ func (mods *modelSuite) TestDecodeOK(c *C) { c.Check(model.Gadget(), Equals, "brand-gadget") c.Check(model.Kernel(), Equals, "baz-linux") c.Check(model.Store(), Equals, "brand-store") + // XXX: these are empty atm c.Check(model.AllowedModes(), HasLen, 0) - c.Check(model.RequiredSnaps(), DeepEquals, []string{"foo", "bar"}) + c.Check(model.RequiredSnaps(), HasLen, 0) } const ( @@ -108,10 +109,6 @@ func (mods *modelSuite) TestDecodeInvalid(c *C) { {"kernel: baz-linux\n", "kernel: \n", `"kernel" header should not be empty`}, {"store: brand-store\n", "", `"store" header is mandatory`}, {"store: brand-store\n", "store: \n", `"store" header should not be empty`}, - {"allowed-modes: \n", "", `"allowed-modes" header is mandatory`}, - {"allowed-modes: \n", "allowed-modes: ,\n", `empty entry in comma separated "allowed-modes" header: ","`}, - {"required-snaps: foo, bar\n", "", `"required-snaps" header is mandatory`}, - {"required-snaps: foo, bar\n", "required-snaps: foo,\n", `empty entry in comma separated "required-snaps" header: "foo,"`}, {"class: fixed\n", "", `"class" header is mandatory`}, {"class: fixed\n", "class: \n", `"class" header should not be empty`}, {mods.tsLine, "", `"timestamp" header is mandatory`}, diff --git a/asserts/header_checks.go b/asserts/header_checks.go index b348eeb43d6..275463ae3dc 100644 --- a/asserts/header_checks.go +++ b/asserts/header_checks.go @@ -112,30 +112,3 @@ func checkUint(headers map[string]string, name string, bitSize int) (uint64, err } return value, nil } - -func checkCommaSepList(headers map[string]string, name string) ([]string, error) { - listStr, ok := headers[name] - if !ok { - return nil, fmt.Errorf("%q header is mandatory", name) - } - - // XXX: we likely don't need this much white-space flexibility, - // just supporting newline after , could be enough - - // empty lists are allowed - listStr = strings.TrimSpace(listStr) - if listStr == "" { - return nil, nil - } - - entries := strings.Split(listStr, ",") - for i, entry := range entries { - entry = strings.TrimSpace(entry) - if entry == "" { - return nil, fmt.Errorf("empty entry in comma separated %q header: %q", name, listStr) - } - entries[i] = entry - } - - return entries, nil -} diff --git a/asserts/snap_asserts.go b/asserts/snap_asserts.go index 9a4e19fb9de..501c80643d4 100644 --- a/asserts/snap_asserts.go +++ b/asserts/snap_asserts.go @@ -24,12 +24,13 @@ import ( "time" ) +// TODO: adjust to new designs! + // SnapDeclaration holds a snap-declaration assertion, declaring a // snap binding its identifying snap-id to a name, asserting its // publisher and its other properties. type SnapDeclaration struct { assertionBase - gates []string timestamp time.Time } @@ -53,11 +54,6 @@ func (snapdcl *SnapDeclaration) PublisherID() string { return snapdcl.Header("publisher-id") } -// Gates returns the list of snap-ids gated by this snap. -func (snapdcl *SnapDeclaration) Gates() []string { - return snapdcl.gates -} - // Timestamp returns the time when the snap-declaration was issued. func (snapdcl *SnapDeclaration) Timestamp() time.Time { return snapdcl.timestamp @@ -94,11 +90,6 @@ func assembleSnapDeclaration(assert assertionBase) (Assertion, error) { return nil, err } - gates, err := checkCommaSepList(assert.headers, "gates") - if err != nil { - return nil, err - } - timestamp, err := checkRFC3339Date(assert.headers, "timestamp") if err != nil { return nil, err @@ -106,7 +97,6 @@ func assembleSnapDeclaration(assert assertionBase) (Assertion, error) { return &SnapDeclaration{ assertionBase: assert, - gates: gates, timestamp: timestamp, }, nil } diff --git a/asserts/snap_asserts_test.go b/asserts/snap_asserts_test.go index 8c4a09e07f0..a0a5990c146 100644 --- a/asserts/snap_asserts_test.go +++ b/asserts/snap_asserts_test.go @@ -52,7 +52,6 @@ func (sds *snapDeclSuite) TestDecodeOK(c *C) { "snap-id: snap-id-1\n" + "snap-name: first\n" + "publisher-id: dev-id1\n" + - "gates: snap-id-3,snap-id-4\n" + sds.tsLine + "body-length: 0" + "\n\n" + @@ -67,7 +66,6 @@ func (sds *snapDeclSuite) TestDecodeOK(c *C) { c.Check(snapDecl.SnapID(), Equals, "snap-id-1") c.Check(snapDecl.SnapName(), Equals, "first") c.Check(snapDecl.PublisherID(), Equals, "dev-id1") - c.Check(snapDecl.Gates(), DeepEquals, []string{"snap-id-3", "snap-id-4"}) } func (sds *snapDeclSuite) TestEmptySnapName(c *C) { @@ -77,7 +75,6 @@ func (sds *snapDeclSuite) TestEmptySnapName(c *C) { "snap-id: snap-id-1\n" + "snap-name: \n" + "publisher-id: dev-id1\n" + - "gates: snap-id-3,snap-id-4\n" + sds.tsLine + "body-length: 0" + "\n\n" + @@ -99,7 +96,6 @@ func (sds *snapDeclSuite) TestDecodeInvalid(c *C) { "snap-id: snap-id-1\n" + "snap-name: first\n" + "publisher-id: dev-id1\n" + - "gates: snap-id-3,snap-id-4\n" + sds.tsLine + "body-length: 0" + "\n\n" + @@ -116,8 +112,6 @@ func (sds *snapDeclSuite) TestDecodeInvalid(c *C) { {sds.tsLine, "", `"timestamp" header is mandatory`}, {sds.tsLine, "timestamp: \n", `"timestamp" header should not be empty`}, {sds.tsLine, "timestamp: 12:30\n", `"timestamp" header is not a RFC3339 date: .*`}, - {"gates: snap-id-3,snap-id-4\n", "", `\"gates\" header is mandatory`}, - {"gates: snap-id-3,snap-id-4\n", "gates: foo,\n", `empty entry in comma separated "gates" header: "foo,"`}, } for _, test := range invalidTests {