~ubuntu-branches/ubuntu/raring/cinder/raring-updates

« back to all changes in this revision

Viewing changes to cinder/tests/test_cinder_rootwrap.py

Tags: upstream-2013.1~g2
ImportĀ upstreamĀ versionĀ 2013.1~g2

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
            filters.CommandFilter("/usr/bin/foo_bar_not_exist", "root"),
32
32
            filters.RegExpFilter("/bin/cat", "root", 'cat', '/[a-z]+'),
33
33
            filters.CommandFilter("/nonexistent/cat", "root"),
34
 
            filters.CommandFilter("/bin/cat", "root")  # Keep this one last
35
 
            ]
 
34
            filters.CommandFilter("/bin/cat", "root")]  # Keep this one last
36
35
 
37
36
    def test_RegExpFilter_match(self):
38
37
        usercmd = ["ls", "/root"]
39
38
        filtermatch = wrapper.match_filter(self.filters, usercmd)
40
39
        self.assertFalse(filtermatch is None)
41
40
        self.assertEqual(filtermatch.get_command(usercmd),
42
 
            ["/bin/ls", "/root"])
 
41
                         ["/bin/ls", "/root"])
43
42
 
44
43
    def test_RegExpFilter_reject(self):
45
44
        usercmd = ["ls", "root"]
92
91
        self.assertTrue(f.match(usercmd) or f2.match(usercmd))
93
92
 
94
93
    def test_KillFilter_no_raise(self):
95
 
        """Makes sure ValueError from bug 926412 is gone"""
 
94
        """Makes sure ValueError from bug 926412 is gone."""
96
95
        f = filters.KillFilter("root", "")
97
96
        # Providing anything other than kill should be False
98
97
        usercmd = ['notkill', 999999]
102
101
        self.assertFalse(f.match(usercmd))
103
102
 
104
103
    def test_KillFilter_deleted_exe(self):
105
 
        """Makes sure deleted exe's are killed correctly"""
 
104
        """Makes sure deleted exe's are killed correctly."""
106
105
        # See bug #967931.
107
106
        def fake_readlink(blah):
108
107
            return '/bin/commandddddd (deleted)'