Language: Python
Label: vulnerable
CWE: NVD-CWE-noinfo \u2014 

Code:
async def test_list_persons(
    hass: HomeAssistant,
    hass_client_no_auth: ClientSessionGenerator,
    hass_admin_user: MockUser,
    ip: str,
    status_code: HTTPStatus,
    expected_fn: Callable[[dict[str, Any]], dict[str, Any]],
) -> None:
    """Test listing persons from a not local ip address."""

    user_id = hass_admin_user.id
    admin = {"id": "1234", "name": "Admin", "user_id": user_id, "picture": "/bla"}
    config = {
        DOMAIN: [
            admin,
            {"id": "5678", "name": "Only a person"},
        ]
    }
    assert await async_setup_component(hass, DOMAIN, config)

    await async_setup_component(hass, "api", {})
    mock_real_ip(hass.http.app)(ip)
    client = await hass_client_no_auth()

    resp = await client.get("/api/person/list")

    assert resp.status == status_code
    result = await resp.json()
    assert result == expected_fn(admin)