gitee.com/mysnapcore/mysnapd@v0.1.0/interfaces/builtin/snap_refresh_control_test.go (about) 1 // -*- Mode: Go; indent-tabs-mode: t -*- 2 3 /* 4 * Copyright (C) 2021 Canonical Ltd 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 3 as 8 * published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 package builtin_test 21 22 import ( 23 . "gopkg.in/check.v1" 24 25 "gitee.com/mysnapcore/mysnapd/interfaces" 26 "gitee.com/mysnapcore/mysnapd/interfaces/apparmor" 27 "gitee.com/mysnapcore/mysnapd/interfaces/builtin" 28 "gitee.com/mysnapcore/mysnapd/interfaces/seccomp" 29 "gitee.com/mysnapcore/mysnapd/snap" 30 "gitee.com/mysnapcore/mysnapd/snap/snaptest" 31 "gitee.com/mysnapcore/mysnapd/testutil" 32 ) 33 34 type SnapRefreshControlInterfaceSuite struct { 35 iface interfaces.Interface 36 slotInfo *snap.SlotInfo 37 slot *interfaces.ConnectedSlot 38 plugInfo *snap.PlugInfo 39 plug *interfaces.ConnectedPlug 40 } 41 42 var _ = Suite(&SnapRefreshControlInterfaceSuite{ 43 iface: builtin.MustInterface("snap-refresh-control"), 44 }) 45 46 func (s *SnapRefreshControlInterfaceSuite) SetUpTest(c *C) { 47 consumingSnapInfo := snaptest.MockInfo(c, ` 48 name: other 49 version: 0 50 apps: 51 app: 52 command: foo 53 plugs: [snap-refresh-control] 54 `, nil) 55 s.slotInfo = &snap.SlotInfo{ 56 Snap: &snap.Info{SuggestedName: "core", SnapType: snap.TypeOS}, 57 Name: "snap-refresh-control", 58 Interface: "snap-refresh-control", 59 } 60 s.slot = interfaces.NewConnectedSlot(s.slotInfo, nil, nil) 61 s.plugInfo = consumingSnapInfo.Plugs["snap-refresh-control"] 62 s.plug = interfaces.NewConnectedPlug(s.plugInfo, nil, nil) 63 } 64 65 func (s *SnapRefreshControlInterfaceSuite) TestName(c *C) { 66 c.Assert(s.iface.Name(), Equals, "snap-refresh-control") 67 } 68 69 func (s *SnapRefreshControlInterfaceSuite) TestUsedSecuritySystems(c *C) { 70 // connected plugs have nil security snippet for apparmor and seccomp 71 apparmorSpec := &apparmor.Specification{} 72 err := apparmorSpec.AddConnectedPlug(s.iface, s.plug, s.slot) 73 c.Assert(err, IsNil) 74 c.Assert(apparmorSpec.SecurityTags(), IsNil) 75 c.Assert(apparmorSpec.Snippets(), HasLen, 0) 76 77 seccompSpec := &seccomp.Specification{} 78 c.Assert(seccompSpec.AddConnectedPlug(s.iface, s.plug, s.slot), IsNil) 79 c.Assert(seccompSpec.Snippets(), HasLen, 0) 80 } 81 82 func (s *SnapRefreshControlInterfaceSuite) TestInterfaces(c *C) { 83 c.Check(builtin.Interfaces(), testutil.DeepContains, s.iface) 84 }