Пример #1
0
func (s *CmdTestSuite) TestAddOptionDescriptionOrPanicWillPanic(c *C) {
	// disable logging so log doesn't scare people
	logger.SetLogger(logger.NullLogger)
	defer func() { c.Check(logger.SimpleSetup(), IsNil) }()

	parser := flags.NewParser(&struct{}{}, 0)
	arg, err := parser.AddCommand("mock", "shortHelp", "longHelp", &struct{}{})
	c.Assert(err, IsNil)
	f := func() {
		addOptionDescription(arg, "package name", "pkgname description")
	}
	c.Assert(f, PanicMatches, "can not set option description for \"package name\"")
}
Пример #2
0
func (a *SecurityTestSuite) TestSecurityWarnsNot(c *C) {
	makeMockApparmorTemplate(c, "default", []byte(``))
	makeMockSeccompTemplate(c, "default", []byte(``))

	ml := &mockLogger{}
	logger.SetLogger(ml)

	mockSnapYamlFn, err := makeInstalledMockSnap(dirs.GlobalRootDir, mockSecurityDeprecatedSnapYaml)
	c.Assert(err, IsNil)

	err = GeneratePolicyFromFile(mockSnapYamlFn, false)
	c.Assert(err, IsNil)

	c.Assert(ml.notice, DeepEquals, []string(nil))
}
Пример #3
0
func (a *SecurityTestSuite) TestSecurityWarnsOnDeprecatedSeccomp(c *C) {
	makeMockApparmorTemplate(c, "default", []byte(``))
	makeMockSeccompTemplate(c, "default", []byte(``))

	for _, s := range []string{mockSecurityDeprecatedSnapYamlSeccomp1, mockSecurityDeprecatedSnapYamlSeccomp2} {

		ml := &mockLogger{}
		logger.SetLogger(ml)

		mockSnapYamlFn, err := makeInstalledMockSnap(dirs.GlobalRootDir, mockSecurityDeprecatedSnapYaml+s)
		c.Assert(err, IsNil)

		err = GeneratePolicyFromFile(mockSnapYamlFn, false)
		c.Assert(err, IsNil)

		c.Assert(ml.notice, DeepEquals, []string{"The security-override.seccomp key is no longer supported, please use use security-override directly"})
	}
}