'Ensure volume types can be created and deleted by non-admin user.
If a non-admn user is authorized at API, volume type operations
should be permitted.'

def test_volume_type_create_then_destroy_with_non_admin(self):

    prev_all_vtypes = volume_types.get_all_types(self.ctxt)
    self.ctxt = context.RequestContext('fake', 'fake', is_admin=False)
    type_ref = volume_types.create(self.ctxt, self.vol_type1_name, self.vol_type1_specs, description=self.vol_type1_description)
    new = volume_types.get_volume_type_by_name(self.ctxt, self.vol_type1_name)
    self.assertEqual(self.vol_type1_description, new['description'])
    new_all_vtypes = volume_types.get_all_types(self.ctxt)
    self.assertEqual((len(prev_all_vtypes) + 1), len(new_all_vtypes), 'drive    type    was    not    created')
    new_type_name = (self.vol_type1_name + '_updated')
    new_type_desc = (self.vol_type1_description + '_updated')
    volume_types.update(self.ctxt, type_ref.id, new_type_name, new_type_desc)
    type_ref_updated = volume_types.get_volume_type(self.ctxt, type_ref.id)
    self.assertEqual(new_type_name, type_ref_updated['name'])
    self.assertEqual(new_type_desc, type_ref_updated['description'])
    volume_types.destroy(self.ctxt, type_ref['id'])
    new_all_vtypes = volume_types.get_all_types(self.ctxt)
    self.assertEqual(prev_all_vtypes, new_all_vtypes, 'drive    type    was    not    deleted')
