~ubuntu-cloud-archive/ubuntu/precise/nova/trunk

« back to all changes in this revision

Viewing changes to nova/tests/test_virt.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-07-06 10:18:33 UTC
  • mfrom: (1.1.58)
  • Revision ID: package-import@ubuntu.com-20120706101833-wp2nv392mpe9re8p
Tags: 2012.2~f2-0ubuntu1
[ Adam Gandelman ]
* Use new rootwrap configuration structure:
  - debian/nova-{compute, network, volume}.{pyinstall, pyremove}: Dropped.
  - debian/nova-common.dirs: Add /etc/nova/rootwrap.d/.
  - debian/nova-common.install: Install /etc/nova/rootwrap.conf.
  - debian/debian/nova.conf: Reference rootwrap.conf in calls to
    nova-rootwrap.
  - debian/nova-{compute, network, volume}.install: Install corresponding
    filter in /etc/nova/rootwrap.d/
* debian/rules: Install logging_sample.conf to /etc/nova/logging.conf
  as part of nova-common.
* debian/pydist-overrides: Add setuptools-git.
* debian/control: Add python-setuptools-git as a Build-Depends.
* debian/rules: Do not remove nova.egg-info during auto_clean.  Now that
  upstream has moved to setuptools-git, doing so results in missing files
  from built package.

[ Chuck Short ]
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#    License for the specific language governing permissions and limitations
16
16
#    under the License.
17
17
 
 
18
from nova import exception
18
19
from nova import flags
19
20
from nova import test
 
21
from nova.virt.disk import api as disk_api
20
22
from nova.virt import driver
21
23
 
22
24
FLAGS = flags.FLAGS
81
83
                                                'swap_size': 0}))
82
84
        self.assertTrue(driver.swap_is_usable({'device_name': '/dev/sdb',
83
85
                                                'swap_size': 1}))
 
86
 
 
87
 
 
88
class TestVirtDisk(test.TestCase):
 
89
    def test_check_safe_path(self):
 
90
        ret = disk_api._join_and_check_path_within_fs('/foo', 'etc',
 
91
                                                      'something.conf')
 
92
        self.assertEquals(ret, '/foo/etc/something.conf')
 
93
 
 
94
    def test_check_unsafe_path(self):
 
95
        self.assertRaises(exception.Invalid,
 
96
                          disk_api._join_and_check_path_within_fs,
 
97
                          '/foo', 'etc/../../../something.conf')
 
98
 
 
99
    def test_inject_files_with_bad_path(self):
 
100
        self.assertRaises(exception.Invalid,
 
101
                          disk_api._inject_file_into_fs,
 
102
                          '/tmp', '/etc/../../../../etc/passwd',
 
103
                          'hax')