'Test full workflow with groups deletion before token scoping.
The test scenario is as follows:
- Create group ``group``
- Create and assign roles to ``group`` and ``project_all``
- Patch mapping rules for existing IdP so it issues group id
- Issue unscoped token with ``group``\'s id
- Delete group ``group``
- Scope token to ``project_all``
- Expect HTTP 500 response'

def test_workflow_with_groups_deletion(self):

    group = unit.new_group_ref(domain_id=self.domainA['id'])
    group = self.identity_api.create_group(group)
    role = unit.new_role_ref()
    self.role_api.create_role(role['id'], role)
    self.assignment_api.create_grant(role['id'], group_id=group['id'], project_id=self.project_all['id'])
    rules = {'rules': [{'local': [{'group': {'id': group['id']}}, {'user': {'name': '{0}'}}], 'remote': [{'type': 'UserName'}, {'type': 'LastName', 'any_one_of': ['Account']}]}]}
    self.federation_api.update_mapping(self.mapping['id'], rules)
    r = self._issue_unscoped_token(assertion='TESTER_ASSERTION')
    token_id = r.headers.get('X-Subject-Token')
    self.identity_api.delete_group(group['id'])
    scoped_token = self._scope_request(token_id, 'project', self.project_all['id'])
    self.v3_create_token(scoped_token, expected_status=http_client.INTERNAL_SERVER_ERROR)
