def test_api_challenges_challenge_with_requirements_no_user():
    """Does the challenge list API show gated challenges to the public?"""
    app = create_ctfd()
    with app.app_context():
        set_config("challenge_visibility", "public")
        prereq_id = gen_challenge(app.db).id
        chal_obj = gen_challenge(app.db)
        chal_obj.requirements = {"prerequisites": [prereq_id]}
        # Create a new user which will solve the prerequisite
        register_user(app)
        # Confirm that only the prerequisite challenge is listed publicly
        with app.test_client() as client:
            r = client.get("/api/v1/challenges")
            assert r.status_code == 200
            initial_data = r.get_json()["data"]
            (chal_data,) = initial_data
            assert chal_data["id"] == prereq_id
            # Fix up the solve count for later comparison with `initial_data`
            chal_data["solves"] += 1
        # Generate a solve and then confirm the response is unchanged
        gen_solve(app.db, user_id=2, challenge_id=prereq_id)
        with app.test_client() as client:
            r = client.get("/api/v1/challenges")
            assert r.status_code == 200
            assert r.get_json()["data"] == initial_data
    destroy_ctfd(app)
Does the challenge list API show gated challenges to the public?
tests/api/v1/challenges/requirements/test_requirements.py