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
1=== modified file '_integration-tests/tests/snappy_test.go'
2--- _integration-tests/tests/snappy_test.go 2015-06-23 00:17:14 +0000
3+++ _integration-tests/tests/snappy_test.go 2015-06-23 00:17:15 +0000
4@@ -33,15 +33,16 @@
5
6 type InstallSuite struct{}
7
8-func (s *InstallSuite) installSnap(c *C, packageName string) []byte {
9+func (s *InstallSuite) installSnap(c *C, packageName string) string {
10 return s.execCommand(c, "sudo", "snappy", "install", packageName)
11 }
12
13-func (s *InstallSuite) execCommand(c *C, cmds ...string) []byte {
14+func (s *InstallSuite) execCommand(c *C, cmds ...string) string {
15 cmd := exec.Command(cmds[0], cmds[1:len(cmds)]...)
16 output, err := cmd.CombinedOutput()
17- c.Assert(err, IsNil, Commentf("Error: %v", output))
18- return output
19+ stringOutput := string(output)
20+ c.Assert(err, IsNil, Commentf("Error: %v", stringOutput))
21+ return stringOutput
22 }
23
24 func (s *InstallSuite) SetUpSuite(c *C) {
25@@ -61,7 +62,7 @@
26 ".*\n" +
27 "hello-world .* .* canonical \n" +
28 ".*\n"
29- c.Assert(string(installOutput), Matches, expected)
30+ c.Assert(installOutput, Matches, expected)
31 }
32
33 func (s *InstallSuite) TestCallBinaryFromInstalledSnap(c *C) {
34@@ -69,7 +70,25 @@
35
36 echoOutput := s.execCommand(c, "hello-world.echo")
37
38- c.Assert(string(echoOutput), Equals, "Hello World!\n")
39+ c.Assert(echoOutput, Equals, "Hello World!\n")
40+}
41+
42+func (s *InstallSuite) TestCallBinaryWithPermissionDeniedMustPrintError(c *C) {
43+ s.installSnap(c, "hello-world")
44+
45+ cmd := exec.Command("hello-world.evil")
46+ echoOutput, err := cmd.CombinedOutput()
47+ c.Assert(err, NotNil, Commentf("hello-world.evil did not fail"))
48+
49+ expected := "" +
50+ "Hello Evil World!\n" +
51+ "This example demonstrates the app confinement\n" +
52+ "You should see a permission denied error next\n" +
53+ "/apps/hello-world.canonical/.*/bin/evil: \\d+: " +
54+ "/apps/hello-world.canonical/.*/bin/evil: " +
55+ "cannot create /var/tmp/myevil.txt: Permission denied\n"
56+
57+ c.Assert(string(echoOutput), Matches, expected)
58 }
59
60 func (s *InstallSuite) TestInfoMustPrintInstalledPackageInformation(c *C) {
61@@ -78,5 +97,5 @@
62 infoOutput := s.execCommand(c, "sudo", "snappy", "info")
63
64 expected := "(?ms).*^apps: hello-world\n"
65- c.Assert(string(infoOutput), Matches, expected)
66+ c.Assert(infoOutput, Matches, expected)
67 }

Subscribers

People subscribed via source and target branches