示例#1
0
 def test_delete_extra_property_as_admin_role(self):
     extra_properties = {'foo': 'bar'}
     roles = ['admin']
     extra_prop_proxy = property_protections.ExtraPropertiesProxy(
         roles, extra_properties, self.property_rules)
     del extra_prop_proxy['foo']
     self.assertRaises(KeyError, extra_prop_proxy.__getitem__, 'foo')
示例#2
0
 def test_create_reserved_extra_property_as_permitted_role(self):
     extra_properties = {}
     roles = ['spl_role']
     extra_prop_proxy = property_protections.ExtraPropertiesProxy(
         roles, extra_properties, self.property_rules)
     self.assertRaises(exception.ReservedProperty,
                       extra_prop_proxy.__setitem__, 'boo', 'doo')
示例#3
0
 def test_delete_nonexistant_extra_property(self):
     extra_properties = {}
     roles = ['spl_role']
     extra_prop_proxy = property_protections.ExtraPropertiesProxy(
         roles, extra_properties, self.property_rules)
     self.assertRaises(KeyError, extra_prop_proxy.__delitem__,
                       'spl_read_prop')
示例#4
0
 def test_read_extra_property_as_admin_role(self):
     extra_properties = {'foo': 'bar', 'ping': 'pong'}
     roles = ['admin']
     extra_prop_proxy = property_protections.ExtraPropertiesProxy(
         roles, extra_properties, self.property_rules)
     test_result = extra_prop_proxy['foo']
     self.assertEqual(test_result, 'bar')
示例#5
0
 def test_create_reserved_extra_property(self):
     extra_properties = {}
     context = glance.context.RequestContext(roles=['spl_role'])
     extra_prop_proxy = property_protections.ExtraPropertiesProxy(
         context, extra_properties, self.property_rules)
     self.assertRaises(exception.ReservedProperty,
                       extra_prop_proxy.__setitem__, 'boo', 'doo')
示例#6
0
 def test_delete_extra_property_as_admin_role(self):
     extra_properties = {'foo': 'bar'}
     context = glance.context.RequestContext(roles=['admin'])
     extra_prop_proxy = property_protections.ExtraPropertiesProxy(
         context, extra_properties, self.property_rules)
     del extra_prop_proxy['foo']
     self.assertRaises(KeyError, extra_prop_proxy.__getitem__, 'foo')
示例#7
0
 def test_update_extra_property_as_unpermitted_role_after_read(self):
     extra_properties = {'spl_read_prop': 'bar'}
     context = glance.context.RequestContext(roles=['spl_role'])
     extra_prop_proxy = property_protections.ExtraPropertiesProxy(
         context, extra_properties, self.property_rules)
     self.assertRaises(exception.ReservedProperty,
                       extra_prop_proxy.__setitem__, 'spl_read_prop', 'par')
示例#8
0
 def test_create_extra_property_admin(self):
     extra_properties = {}
     context = glance.context.RequestContext(roles=['admin'])
     extra_prop_proxy = property_protections.ExtraPropertiesProxy(
         context, extra_properties, self.property_rules)
     extra_prop_proxy['boo'] = 'doo'
     self.assertEqual(extra_prop_proxy['boo'], 'doo')
示例#9
0
 def test_create_extra_property_as_permitted_role_after_read(self):
     extra_properties = {}
     roles = ['admin']
     extra_prop_proxy = property_protections.ExtraPropertiesProxy(
         roles, extra_properties, self.property_rules)
     extra_prop_proxy['boo'] = 'doo'
     self.assertEqual(extra_prop_proxy['boo'], 'doo')
示例#10
0
 def test_update_extra_property_as_permitted_role_after_read(self):
     extra_properties = {'foo': 'bar', 'ping': 'pong'}
     context = glance.context.RequestContext(roles=['admin'])
     extra_prop_proxy = property_protections.ExtraPropertiesProxy(
         context, extra_properties, self.property_rules)
     extra_prop_proxy['foo'] = 'par'
     self.assertEqual(extra_prop_proxy['foo'], 'par')
示例#11
0
 def test_read_extra_property_as_admin_role(self):
     extra_properties = {'foo': 'bar', 'ping': 'pong'}
     context = glance.context.RequestContext(roles=['admin'])
     extra_prop_proxy = property_protections.ExtraPropertiesProxy(
         context, extra_properties, self.property_rules)
     test_result = extra_prop_proxy['foo']
     self.assertEqual(test_result, 'bar')
 def test_delete_empty_extra_property(self):
     extra_properties = {'foo': ''}
     context = glance.context.RequestContext(roles=['admin'])
     extra_prop_proxy = property_protections.ExtraPropertiesProxy(
         context, extra_properties, self.property_rules)
     del extra_prop_proxy['foo']
     self.assertNotIn('foo', extra_prop_proxy)
 def test_update_empty_extra_property(self):
     extra_properties = {'foo': ''}
     context = glance.context.RequestContext(roles=['admin'])
     extra_prop_proxy = property_protections.ExtraPropertiesProxy(
         context, extra_properties, self.property_rules)
     extra_prop_proxy['foo'] = 'bar'
     self.assertEqual('bar', extra_prop_proxy['foo'])
示例#14
0
 def test_delete_reserved_extra_property(self):
     extra_properties = {'spl_read_prop': 'r'}
     context = glance.context.RequestContext(roles=['spl_role'])
     extra_prop_proxy = property_protections.ExtraPropertiesProxy(
         context, extra_properties, self.property_rules)
     # Ensure property has been created and can be read
     self.assertEqual(extra_prop_proxy['spl_read_prop'], 'r')
     self.assertRaises(exception.ReservedProperty,
                       extra_prop_proxy.__delitem__, 'spl_read_prop')
示例#15
0
 def test_delete_reserved_extra_property_as_permitted_role(self):
     extra_properties = {'spl_read_prop': 'r'}
     roles = ['spl_role']
     extra_prop_proxy = property_protections.ExtraPropertiesProxy(
         roles, extra_properties, self.property_rules)
     # Ensure property has been created and can be read
     self.assertEqual(extra_prop_proxy['spl_read_prop'], 'r')
     self.assertRaises(exception.ReservedProperty,
                       extra_prop_proxy.__delitem__, 'spl_read_prop')
示例#16
0
 def test_read_extra_property_as_unpermitted_role(self):
     extra_properties = {'foo': 'bar', 'ping': 'pong'}
     context = glance.context.RequestContext(roles=['unpermitted_role'])
     extra_prop_proxy = property_protections.ExtraPropertiesProxy(
         context, extra_properties, self.property_rules)
     self.assertRaises(KeyError, extra_prop_proxy.__getitem__, 'foo')
示例#17
0
 def test_delete_nonexistant_extra_property_as_admin_role(self):
     extra_properties = {}
     context = glance.context.RequestContext(roles=['admin'])
     extra_prop_proxy = property_protections.ExtraPropertiesProxy(
         context, extra_properties, self.property_rules)
     self.assertRaises(KeyError, extra_prop_proxy.__delitem__, 'foo')
示例#18
0
 def test_delete_nonexistant_extra_property_as_admin_role(self):
     extra_properties = {}
     roles = ['admin']
     extra_prop_proxy = property_protections.ExtraPropertiesProxy(
         roles, extra_properties, self.property_rules)
     self.assertRaises(KeyError, extra_prop_proxy.__delitem__, 'foo')