func (s *interfaceManagerSuite) TestCheckInterfacesConsidersImplicitSlots(c *C) { snapInfo := s.mockSnap(c, osSnapYaml) s.state.Lock() defer s.state.Unlock() c.Check(ifacestate.CheckInterfaces(s.state, snapInfo), IsNil) c.Check(snapInfo.Slots["home"], NotNil) }
func (s *interfaceManagerSuite) TestCheckInterfacesDeny(c *C) { restore := assertstest.MockBuiltinBaseDeclaration([]byte(` type: base-declaration authority-id: canonical series: 16 slots: test: deny-installation: true `)) defer restore() s.mockIface(c, &interfaces.TestInterface{InterfaceName: "test"}) snapInfo := s.mockSnap(c, producerYaml) s.state.Lock() defer s.state.Unlock() c.Check(ifacestate.CheckInterfaces(s.state, snapInfo), ErrorMatches, "installation denied.*") }
func (s *interfaceManagerSuite) TestCheckInterfacesDenySkippedIfNoDecl(c *C) { restore := assertstest.MockBuiltinBaseDeclaration([]byte(` type: base-declaration authority-id: canonical series: 16 slots: test: deny-installation: true `)) defer restore() s.mockIface(c, &interfaces.TestInterface{InterfaceName: "test"}) // crucially, this test is missing this: s.mockSnapDecl(c, "producer", "producer-publisher", nil) snapInfo := s.mockSnap(c, producerYaml) s.state.Lock() defer s.state.Unlock() c.Check(ifacestate.CheckInterfaces(s.state, snapInfo), IsNil) }
func (s *interfaceManagerSuite) TestCheckInterfacesAllow(c *C) { restore := assertstest.MockBuiltinBaseDeclaration([]byte(` type: base-declaration authority-id: canonical series: 16 slots: test: deny-installation: true `)) defer restore() s.mockIface(c, &interfaces.TestInterface{InterfaceName: "test"}) s.mockSnapDecl(c, "producer", "producer-publisher", map[string]interface{}{ "slots": map[string]interface{}{ "test": "true", }, }) snapInfo := s.mockSnap(c, producerYaml) s.state.Lock() defer s.state.Unlock() c.Check(ifacestate.CheckInterfaces(s.state, snapInfo), IsNil) }