~ubuntu-branches/ubuntu/quantal/nova/quantal-security

« back to all changes in this revision

Viewing changes to nova/tests/test_imagecache.py

  • Committer: Package Import Robot
  • Author(s): Jamie Strandboge
  • Date: 2013-01-29 09:34:02 UTC
  • mfrom: (94.1.1 quantal-proposed)
  • Revision ID: package-import@ubuntu.com-20130129093402-17tbp37f5load7my
Tags: 2012.2.1+stable-20121212-a99a802e-0ubuntu1.1
* SECURITY UPDATE: fix lack of authentication on block device used for
  os-volume_boot
  - debian/patches/CVE-2013-0208.patch: adjust nova/compute/api.py to
    validate we can access the volumes
  - CVE-2013-0208

Show diffs side-by-side

added added

removed removed

Lines of Context:
379
379
                res = image_cache_manager._verify_checksum(img, fname)
380
380
                self.assertTrue(res)
381
381
 
 
382
    def test_verify_checksum_disabled(self):
 
383
        img = {'container_format': 'ami', 'id': '42'}
 
384
 
 
385
        self.flags(checksum_base_images=False)
 
386
 
 
387
        with self._intercept_log_messages() as stream:
 
388
            with utils.tempdir() as tmpdir:
 
389
                self.flags(instances_path=tmpdir)
 
390
                self.flags(image_info_filename_pattern=('$instances_path/'
 
391
                                                        '%(image)s.info'))
 
392
                fname, info_fname, testdata = self._make_checksum(tmpdir)
 
393
 
 
394
                # Checksum is valid
 
395
                f = open(info_fname, 'w')
 
396
                csum = hashlib.sha1()
 
397
                csum.update(testdata)
 
398
                f.write('{"sha1": "%s"}\n' % csum.hexdigest())
 
399
                f.close()
 
400
 
 
401
                image_cache_manager = imagecache.ImageCacheManager()
 
402
                res = image_cache_manager._verify_checksum(img, fname)
 
403
                self.assertTrue(res is None)
 
404
 
382
405
    def test_verify_checksum_invalid_json(self):
383
406
        img = {'container_format': 'ami', 'id': '42'}
384
407
 
653
676
            self.assertEquals(image_cache_manager.corrupt_base_files, [])
654
677
 
655
678
    def test_handle_base_image_checksum_fails(self):
 
679
        self.flags(checksum_base_images=True)
656
680
        self.stubs.Set(virtutils, 'chown', lambda x, y: None)
657
681
 
658
682
        img = '123'