gitee.com/mysnapcore/mysnapd@v0.1.0/interfaces/builtin/snap_themes_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/snap" 29 "gitee.com/mysnapcore/mysnapd/testutil" 30 ) 31 32 type SnapThemesControlInterfaceSuite struct { 33 iface interfaces.Interface 34 slotInfo *snap.SlotInfo 35 slot *interfaces.ConnectedSlot 36 plugInfo *snap.PlugInfo 37 plug *interfaces.ConnectedPlug 38 } 39 40 var _ = Suite(&SnapThemesControlInterfaceSuite{ 41 iface: builtin.MustInterface("snap-themes-control"), 42 }) 43 44 func (s *SnapThemesControlInterfaceSuite) SetUpTest(c *C) { 45 const coreSlotYaml = ` 46 name: core 47 type: os 48 version: 1.0 49 slots: 50 snap-themes-control: 51 ` 52 s.slot, s.slotInfo = MockConnectedSlot(c, coreSlotYaml, nil, "snap-themes-control") 53 54 const appPlugYaml = ` 55 name: other 56 version: 0 57 apps: 58 app: 59 command: foo 60 plugs: [snap-themes-control] 61 ` 62 s.plug, s.plugInfo = MockConnectedPlug(c, appPlugYaml, nil, "snap-themes-control") 63 } 64 65 func (s *SnapThemesControlInterfaceSuite) TestName(c *C) { 66 c.Check(s.iface.Name(), Equals, "snap-themes-control") 67 } 68 69 func (s *SnapThemesControlInterfaceSuite) TestSanitizeSlot(c *C) { 70 c.Check(interfaces.BeforePrepareSlot(s.iface, s.slotInfo), IsNil) 71 } 72 73 func (s *SnapThemesControlInterfaceSuite) TestSanitizePlug(c *C) { 74 c.Check(interfaces.BeforePreparePlug(s.iface, s.plugInfo), IsNil) 75 } 76 77 func (s *SnapThemesControlInterfaceSuite) TestAppArmor(c *C) { 78 // The interface generates no AppArmor rules 79 spec := &apparmor.Specification{} 80 c.Assert(spec.AddConnectedPlug(s.iface, s.plug, s.slot), IsNil) 81 c.Check(spec.SecurityTags(), HasLen, 0) 82 83 spec = &apparmor.Specification{} 84 c.Assert(spec.AddConnectedSlot(s.iface, s.plug, s.slot), IsNil) 85 c.Check(spec.SecurityTags(), HasLen, 0) 86 87 spec = &apparmor.Specification{} 88 c.Assert(spec.AddPermanentPlug(s.iface, s.plugInfo), IsNil) 89 c.Check(spec.SecurityTags(), HasLen, 0) 90 91 spec = &apparmor.Specification{} 92 c.Assert(spec.AddPermanentSlot(s.iface, s.slotInfo), IsNil) 93 c.Check(spec.SecurityTags(), HasLen, 0) 94 } 95 96 func (s *SnapThemesControlInterfaceSuite) TestInterfaces(c *C) { 97 c.Check(builtin.Interfaces(), testutil.DeepContains, s.iface) 98 }