Example #1
0
func (s *installAppSuite) TestCallFailBinaryFromInstalledSnap(c *check.C) {
	snapPath, err := build.LocalSnap(c, data.BasicBinariesSnapName)
	defer os.Remove(snapPath)
	c.Assert(err, check.IsNil, check.Commentf("Error building local snap: %s", err))
	common.InstallSnap(c, snapPath)
	defer common.RemoveSnap(c, data.BasicBinariesSnapName)

	_, err = cli.ExecCommandErr("basic-binaries.fail")
	c.Assert(err, check.NotNil, check.Commentf("The binary did not fail"))
}
Example #2
0
func (s *activateSuite) TestDeactivateRemovesBinary(c *check.C) {
	cli.ExecCommand(c, "sudo", "snappy", "deactivate", activateSnapName)
	defer cli.ExecCommand(c, "sudo", "snappy", "activate", activateSnapName)
	output, err := cli.ExecCommandErr(activateBinName)

	c.Assert(err, check.NotNil, check.Commentf("Deactivated snap binary did not exit with an error"))
	c.Assert(output, check.Not(check.Equals), activateEchoOutput,
		check.Commentf("Deactivated snap binary was not removed"))

	list := cli.ExecCommand(c, "snappy", "list", "-v")

	c.Assert(list, check.Matches, deActivatedPattern)
}
Example #3
0
func (s *helloWorldExampleSuite) TestCallHelloWorldEvilMustPrintPermissionDeniedError(c *check.C) {
	common.InstallSnap(c, "hello-world")
	s.AddCleanup(func() {
		common.RemoveSnap(c, "hello-world")
	})

	echoOutput, err := cli.ExecCommandErr("hello-world.evil")
	c.Assert(err, check.NotNil, check.Commentf("hello-world.evil did not fail"))

	expected := "" +
		"Hello Evil World!\n" +
		"This example demonstrates the app confinement\n" +
		"You should see a permission denied error next\n" +
		"/apps/hello-world.canonical/.*/bin/evil: \\d+: " +
		"/apps/hello-world.canonical/.*/bin/evil: " +
		"cannot create /var/tmp/myevil.txt: Permission denied\n"

	c.Assert(string(echoOutput), check.Matches, expected)
}
Example #4
0
func (s *loginSuite) TestEmptyLoginNameError(c *check.C) {
	output, err := cli.ExecCommandErr("snappy", "login")

	c.Assert(err, check.NotNil, check.Commentf("expecting empty login error"))
	c.Assert(output, check.Equals, "the required argument `userid` was not provided\n")
}
Example #5
0
func (s *loginSuite) tearDownIPTables(c *check.C) {
	cmd := ipTablesDelCommand(s.serverAddrPort)
	_, err := cli.ExecCommandErr(cmd...)
	c.Assert(err, check.IsNil, check.Commentf("Error tearing down iptables"))
}
Example #6
0
func (s *loginSuite) setUpIPTables(c *check.C) {
	cmd := ipTablesAddCommand(s.serverAddrPort)
	_, err := cli.ExecCommandErr(cmd...)
	c.Assert(err, check.IsNil, check.Commentf("Error setting up iptables"))
}