Пример #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')