Skip to content

Commit

Permalink
interfaces/apparmor: add tests for classic confinement
Browse files Browse the repository at this point in the history
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
  • Loading branch information
zyga committed Nov 28, 2016
1 parent ad75108 commit 5e66159
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion interfaces/apparmor/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,19 +319,34 @@ const commonPrefix = `
@{INSTALL_DIR}="/snap"`

var combineSnippetsScenarios = []combineSnippetsScenario{{
// By default apparmor is enforcing mode.
opts: interfaces.ConfinementOptions{},
content: commonPrefix + "\nprofile \"snap.samba.smbd\" (attach_disconnected) {\n\n}\n",
}, {
// Snippets are injected in the space between "{" and "}"
opts: interfaces.ConfinementOptions{},
snippet: "snippet",
content: commonPrefix + "\nprofile \"snap.samba.smbd\" (attach_disconnected) {\nsnippet\n}\n",
}, {
// DevMode switches apparmor to non-enforcing (complain) mode.
opts: interfaces.ConfinementOptions{DevMode: true},
content: commonPrefix + "\nprofile \"snap.samba.smbd\" (attach_disconnected,complain) {\n\n}\n",
snippet: "snippet",
content: commonPrefix + "\nprofile \"snap.samba.smbd\" (attach_disconnected,complain) {\nsnippet\n}\n",
}, {
// JailMode switches apparmor to enforcing mode even in the presence of DevMode.
opts: interfaces.ConfinementOptions{DevMode: true},
snippet: "snippet",
content: commonPrefix + "\nprofile \"snap.samba.smbd\" (attach_disconnected,complain) {\nsnippet\n}\n",
}, {
// Classic confinement uses apparmor in complain mode by default.
opts: interfaces.ConfinementOptions{Classic: true},
snippet: "snippet",
content: commonPrefix + "\nprofile \"snap.samba.smbd\" (attach_disconnected,complain) {\nsnippet\n}\n",
}, {
// Classic confinement in JailMode uses enforcing apparmor.
opts: interfaces.ConfinementOptions{Classic: true, JailMode: true},
snippet: "snippet",
content: commonPrefix + "\nprofile \"snap.samba.smbd\" (attach_disconnected) {\nsnippet\n}\n",
}}

func (s *backendSuite) TestCombineSnippets(c *C) {
Expand Down

0 comments on commit 5e66159

Please sign in to comment.