Exemple #1
0
 def test_allow_access(self):
     share = fake_share("fakeid", status="available")
     values = {"share_id": share["id"], "access_type": "fakeacctype", "access_to": "fakeaccto"}
     self.mox.StubOutWithMock(share_api.policy, "check_policy")
     share_api.policy.check_policy(self.context, "share", "allow_access")
     self.mox.StubOutWithMock(db_driver, "share_access_create")
     db_driver.share_access_create(self.context, values).AndReturn("fakeacc")
     self.share_rpcapi.allow_access(self.context, share, "fakeacc")
     self.mox.ReplayAll()
     access = self.api.allow_access(self.context, share, "fakeacctype", "fakeaccto")
     self.assertEqual(access, "fakeacc")
Exemple #2
0
 def test_allow_access(self):
     share = fake_share('fakeid', status='available')
     values = {'share_id': share['id'],
               'access_type': 'fakeacctype',
               'access_to': 'fakeaccto'}
     self.mox.StubOutWithMock(share_api.policy, 'check_policy')
     share_api.policy.check_policy(self.context, 'share', 'allow_access')
     self.mox.StubOutWithMock(db_driver, 'share_access_create')
     db_driver.share_access_create(self.context, values).\
         AndReturn('fakeacc')
     self.share_rpcapi.allow_access(self.context, share, 'fakeacc')
     self.mox.ReplayAll()
     access = self.api.allow_access(self.context, share, 'fakeacctype',
                                    'fakeaccto')
     self.assertEqual(access, 'fakeacc')
Exemple #3
0
 def _create_access(state='new', share_id=None):
     """Create a access rule object."""
     access = {}
     access['access_type'] = 'fake_type'
     access['access_to'] = 'fake_IP'
     access['share_id'] = share_id
     access['state'] = state
     return db.share_access_create(context.get_admin_context(), access)
Exemple #4
0
 def _create_access(state='new', share_id=None):
     """Create a access rule object."""
     access = {}
     access['access_type'] = 'fake_type'
     access['access_to'] = 'fake_IP'
     access['share_id'] = share_id
     access['state'] = state
     return db.share_access_create(context.get_admin_context(), access)
 def setUp(self):
     self.context = context.get_admin_context()
     shr = {}
     shr['host'] = 'fake_host'
     shr['availability_zone'] = CONF.storage_availability_zone
     shr['status'] = "available"
     share = db.share_create(self.context, shr)
     acs = {}
     acs['access_type'] = "ip"
     acs['access_to'] = "123.123.123.123"
     acs['share_id'] = share['id']
     access = db.share_access_create(self.context, acs)
     snap = {}
     snap['share_id'] = share['id']
     snapshot = db.share_snapshot_create(self.context, snap)
     self.fake_share = jsonutils.to_primitive(share)
     self.fake_access = jsonutils.to_primitive(access)
     self.fake_snapshot = jsonutils.to_primitive(snapshot)
     super(ShareRpcAPITestCase, self).setUp()
Exemple #6
0
 def setUp(self):
     super(ShareRpcAPITestCase, self).setUp()
     self.context = context.get_admin_context()
     shr = {}
     shr['host'] = 'fake_host'
     shr['availability_zone'] = CONF.storage_availability_zone
     shr['status'] = "available"
     share = db.share_create(self.context, shr)
     acs = {}
     acs['access_type'] = "ip"
     acs['access_to'] = "123.123.123.123"
     acs['share_id'] = share['id']
     access = db.share_access_create(self.context, acs)
     snap = {}
     snap['share_id'] = share['id']
     snapshot = db.share_snapshot_create(self.context, snap)
     server = {'id': 'fake_share_server_id', 'host': 'fake_host'}
     share_server = db.share_server_create(self.context, server)
     self.fake_share = jsonutils.to_primitive(share)
     self.fake_access = jsonutils.to_primitive(access)
     self.fake_snapshot = jsonutils.to_primitive(snapshot)
     self.fake_share_server = jsonutils.to_primitive(share_server)
     self.ctxt = context.RequestContext('fake_user', 'fake_project')
     self.rpcapi = share_rpcapi.ShareAPI()