'Call ``GET & HEAD /users/{user_id}/groups``.'

def test_list_head_groups_for_user(self):

    user1 = unit.create_user(self.identity_api, domain_id=self.domain['id'])
    user2 = unit.create_user(self.identity_api, domain_id=self.domain['id'])
    self.put(('/groups/%(group_id)s/users/%(user_id)s' % {'group_id': self.group_id, 'user_id': user1['id']}))
    auth = self.build_authentication_request(user_id=user1['id'], password=user1['password'])
    resource_url = ('/users/%(user_id)s/groups' % {'user_id': user1['id']})
    r = self.get(resource_url, auth=auth)
    self.assertValidGroupListResponse(r, ref=self.group, resource_url=resource_url)
    self.head(resource_url, auth=auth, expected_status=http_client.OK)
    resource_url = ('/users/%(user_id)s/groups' % {'user_id': user1['id']})
    r = self.get(resource_url)
    self.assertValidGroupListResponse(r, ref=self.group, resource_url=resource_url)
    self.head(resource_url, expected_status=http_client.OK)
    auth = self.build_authentication_request(user_id=user2['id'], password=user2['password'])
    resource_url = ('/users/%(user_id)s/groups' % {'user_id': user1['id']})
    self.get(resource_url, auth=auth, expected_status=exception.ForbiddenAction.code)
    self.head(resource_url, auth=auth, expected_status=exception.ForbiddenAction.code)
