'Test to ensure entities not create via controller are mapped.
Many LDAP backends will, essentially, by Read Only. In these cases
the mapping is not built by creating objects, rather from enumerating
the entries.  We test this here my manually deleting the mapping and
then trying to re-read the entries.'

def test_dynamic_mapping_build(self):

    initial_mappings = len(mapping_sql.list_id_mappings())
    user1 = self.new_user_ref(domain_id=CONF.identity.default_domain_id)
    user1 = self.identity_api.create_user(user1)
    user2 = self.new_user_ref(domain_id=CONF.identity.default_domain_id)
    user2 = self.identity_api.create_user(user2)
    mappings = mapping_sql.list_id_mappings()
    self.assertEqual((initial_mappings + 2), len(mappings))
    self.id_mapping_api.purge_mappings({'public_id': user1['id']})
    self.id_mapping_api.purge_mappings({'public_id': user2['id']})
    self.assertRaises(exception.UserNotFound, self.identity_api.get_user, user1['id'])
    self.assertRaises(exception.UserNotFound, self.identity_api.get_user, user2['id'])
    self.identity_api.list_users()
    self.identity_api.get_user(user1['id'])
    self.identity_api.get_user(user2['id'])
