Merge lp:~elopio/snappy/test1466779-hell-world.evil into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by Leo Arias
Status: Merged
Approved by: John Lenton
Approved revision: 518
Merged at revision: 526
Proposed branch: lp:~elopio/snappy/test1466779-hell-world.evil
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Prerequisite: lp:~fgimenez/snappy/go-functional-tests
Diff against target: 67 lines (+26/-7)
1 file modified
_integration-tests/tests/snappy_test.go (+26/-7)
To merge this branch: bzr merge lp:~elopio/snappy/test1466779-hell-world.evil
Reviewer Review Type Date Requested Status
John Lenton (community) Approve
Review via email: mp+262648@code.launchpad.net

Commit message

Added the functional test: TestCallBinaryWithPermissionDeniedMustPrintError

To post a comment you must log in.
Revision history for this message
John Lenton (chipaca) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '_integration-tests/tests/snappy_test.go'
--- _integration-tests/tests/snappy_test.go 2015-06-23 00:17:14 +0000
+++ _integration-tests/tests/snappy_test.go 2015-06-23 00:17:15 +0000
@@ -33,15 +33,16 @@
3333
34type InstallSuite struct{}34type InstallSuite struct{}
3535
36func (s *InstallSuite) installSnap(c *C, packageName string) []byte {36func (s *InstallSuite) installSnap(c *C, packageName string) string {
37 return s.execCommand(c, "sudo", "snappy", "install", packageName)37 return s.execCommand(c, "sudo", "snappy", "install", packageName)
38}38}
3939
40func (s *InstallSuite) execCommand(c *C, cmds ...string) []byte {40func (s *InstallSuite) execCommand(c *C, cmds ...string) string {
41 cmd := exec.Command(cmds[0], cmds[1:len(cmds)]...)41 cmd := exec.Command(cmds[0], cmds[1:len(cmds)]...)
42 output, err := cmd.CombinedOutput()42 output, err := cmd.CombinedOutput()
43 c.Assert(err, IsNil, Commentf("Error: %v", output))43 stringOutput := string(output)
44 return output44 c.Assert(err, IsNil, Commentf("Error: %v", stringOutput))
45 return stringOutput
45}46}
4647
47func (s *InstallSuite) SetUpSuite(c *C) {48func (s *InstallSuite) SetUpSuite(c *C) {
@@ -61,7 +62,7 @@
61 ".*\n" +62 ".*\n" +
62 "hello-world .* .* canonical \n" +63 "hello-world .* .* canonical \n" +
63 ".*\n"64 ".*\n"
64 c.Assert(string(installOutput), Matches, expected)65 c.Assert(installOutput, Matches, expected)
65}66}
6667
67func (s *InstallSuite) TestCallBinaryFromInstalledSnap(c *C) {68func (s *InstallSuite) TestCallBinaryFromInstalledSnap(c *C) {
@@ -69,7 +70,25 @@
6970
70 echoOutput := s.execCommand(c, "hello-world.echo")71 echoOutput := s.execCommand(c, "hello-world.echo")
7172
72 c.Assert(string(echoOutput), Equals, "Hello World!\n")73 c.Assert(echoOutput, Equals, "Hello World!\n")
74}
75
76func (s *InstallSuite) TestCallBinaryWithPermissionDeniedMustPrintError(c *C) {
77 s.installSnap(c, "hello-world")
78
79 cmd := exec.Command("hello-world.evil")
80 echoOutput, err := cmd.CombinedOutput()
81 c.Assert(err, NotNil, Commentf("hello-world.evil did not fail"))
82
83 expected := "" +
84 "Hello Evil World!\n" +
85 "This example demonstrates the app confinement\n" +
86 "You should see a permission denied error next\n" +
87 "/apps/hello-world.canonical/.*/bin/evil: \\d+: " +
88 "/apps/hello-world.canonical/.*/bin/evil: " +
89 "cannot create /var/tmp/myevil.txt: Permission denied\n"
90
91 c.Assert(string(echoOutput), Matches, expected)
73}92}
7493
75func (s *InstallSuite) TestInfoMustPrintInstalledPackageInformation(c *C) {94func (s *InstallSuite) TestInfoMustPrintInstalledPackageInformation(c *C) {
@@ -78,5 +97,5 @@
78 infoOutput := s.execCommand(c, "sudo", "snappy", "info")97 infoOutput := s.execCommand(c, "sudo", "snappy", "info")
7998
80 expected := "(?ms).*^apps: hello-world\n"99 expected := "(?ms).*^apps: hello-world\n"
81 c.Assert(string(infoOutput), Matches, expected)100 c.Assert(infoOutput, Matches, expected)
82}101}

Subscribers

People subscribed via source and target branches