def test_clone_image_authorization(self, _mock_issue_api_request): _mock_issue_api_request.return_value = self.mock_stats_data self.configuration.sf_allow_template_caching = True sfv = SolidFireDriver(configuration=self.configuration) # Make sure if it's NOT public and we're NOT the owner it # doesn't try and cache _fake_image_meta = { 'id': '17c550bb-a411-44c0-9aaf-0d96dd47f501', 'updated_at': datetime.datetime(2013, 9, 28, 15, 27, 36, 325355), 'properties': { 'virtual_size': 1 }, 'is_public': False, 'owner': 'wrong-owner' } self.assertEqual((None, False), sfv.clone_image(self.ctxt, self.mock_volume, 'fake', _fake_image_meta, 'fake')) # And is_public False, but the correct owner does work # expect raise AccountNotFound as that's the next call after # auth checks _fake_image_meta['owner'] = 'testprjid' self.assertRaises(exception.SolidFireAccountNotFound, sfv.clone_image, self.ctxt, self.mock_volume, 'fake', _fake_image_meta, 'fake') # And is_public True, even if not the correct owner _fake_image_meta['is_public'] = True _fake_image_meta['owner'] = 'wrong-owner' self.assertRaises(exception.SolidFireAccountNotFound, sfv.clone_image, self.ctxt, self.mock_volume, 'fake', _fake_image_meta, 'fake')
def test_clone_image_not_configured(self, _mock_issue_api_request): _mock_issue_api_request.return_value = self.mock_stats_data sfv = SolidFireDriver(configuration=self.configuration) self.assertEqual((None, False), sfv.clone_image(self.ctxt, self.mock_volume, 'fake', self.fake_image_meta, 'fake'))
def test_clone_image_not_configured(self, _mock_issue_api_request): _mock_issue_api_request.return_value = self.mock_stats_data sfv = SolidFireDriver(configuration=self.configuration) self.assertEqual((None, False), sfv.clone_image(self.ctxt, self.mock_volume, 'fake', self.fake_image_meta, 'fake'))
def test_clone_image_virt_size_not_set(self, _mock_issue_api_request): _mock_issue_api_request.return_value = self.mock_stats_data self.configuration.sf_allow_template_caching = True sfv = SolidFireDriver(configuration=self.configuration) # Don't run clone_image if virtual_size property not on image _fake_image_meta = { 'id': '17c550bb-a411-44c0-9aaf-0d96dd47f501', 'updated_at': datetime.datetime(2013, 9, 28, 15, 27, 36, 325355), 'is_public': True, 'owner': 'testprjid' } self.assertEqual((None, False), sfv.clone_image(self.ctxt, self.mock_volume, 'fake', _fake_image_meta, 'fake'))
def test_clone_image_virt_size_not_set(self, _mock_issue_api_request): _mock_issue_api_request.return_value = self.mock_stats_data self.configuration.sf_allow_template_caching = True sfv = SolidFireDriver(configuration=self.configuration) # Don't run clone_image if virtual_size property not on image _fake_image_meta = {'id': '17c550bb-a411-44c0-9aaf-0d96dd47f501', 'updated_at': datetime.datetime(2013, 9, 28, 15, 27, 36, 325355), 'is_public': True, 'owner': 'testprjid'} self.assertEqual((None, False), sfv.clone_image(self.ctxt, self.mock_volume, 'fake', _fake_image_meta, 'fake'))
def test_clone_image_authorization(self, _mock_issue_api_request): _mock_issue_api_request.return_value = self.mock_stats_data self.configuration.sf_allow_template_caching = True sfv = SolidFireDriver(configuration=self.configuration) # Make sure if it's NOT public and we're NOT the owner it # doesn't try and cache _fake_image_meta = {'id': '17c550bb-a411-44c0-9aaf-0d96dd47f501', 'updated_at': datetime.datetime(2013, 9, 28, 15, 27, 36, 325355), 'properties': {'virtual_size': 1}, 'is_public': False, 'owner': 'wrong-owner'} self.assertEqual((None, False), sfv.clone_image(self.ctxt, self.mock_volume, 'fake', _fake_image_meta, 'fake')) # And is_public False, but the correct owner does work # expect raise AccountNotFound as that's the next call after # auth checks _fake_image_meta['owner'] = 'testprjid' self.assertRaises(exception.SolidFireAccountNotFound, sfv.clone_image, self.ctxt, self.mock_volume, 'fake', _fake_image_meta, 'fake') # And is_public True, even if not the correct owner _fake_image_meta['is_public'] = True _fake_image_meta['owner'] = 'wrong-owner' self.assertRaises(exception.SolidFireAccountNotFound, sfv.clone_image, self.ctxt, self.mock_volume, 'fake', _fake_image_meta, 'fake')