'Check whether the projects and the roles match.'

def _check_projects_and_roles(self, token, roles, projects):

    token_roles = token.get('roles')
    if (token_roles is None):
        raise AssertionError('Roles    not    found    in    the    token')
    token_roles = self._roles(token_roles)
    roles_ref = self._roles(roles)
    self.assertEqual(token_roles, roles_ref)
    token_projects = token.get('project')
    if (token_projects is None):
        raise AssertionError('Projects    not    found    in    the    token')
    token_projects = self._project(token_projects)
    projects_ref = self._project(projects)
    self.assertEqual(token_projects, projects_ref)
