def test_api_user_get_fails_after_freze_time():
    """Can a user get /api/v1/users/<user_id>/fails after freeze time"""
    app = create_ctfd(user_mode="users")
    with app.app_context():
        register_user(app, name="user1", email="user1@examplectf.com")
        register_user(app, name="user2", email="user2@examplectf.com")

        # Friday, October 6, 2017 12:00:00 AM GMT-04:00 DST
        set_config("freeze", "1507262400")
        with freeze_time("2017-10-4"):
            chal = gen_challenge(app.db)
            chal_id = chal.id
            chal2 = gen_challenge(app.db)
            chal2_id = chal2.id
            gen_fail(app.db, user_id=2, challenge_id=chal_id)

        with freeze_time("2017-10-8"):
            chal2 = gen_fail(app.db, user_id=2, challenge_id=chal2_id)

            # There should now be two fails assigned to the same user.
            assert Fails.query.count() == 2

            # User 2 should have 2 fail when seen by themselves
            client = login_as_user(app, name="user1")
            r = client.get("/api/v1/users/me/fails")
            assert r.get_json()["meta"]["count"] == 2

            # User 2 should have 1 fail when seen by another user
            client = login_as_user(app, name="user2")
            r = client.get("/api/v1/users/2/fails")
            assert r.get_json()["meta"]["count"] == 1

            # Admins should see all fails for the user
            admin = login_as_user(app, name="admin")

            r = admin.get("/api/v1/users/2/fails")
            assert r.get_json()["meta"]["count"] == 2
    destroy_ctfd(app)
Can a user get /api/v1/users/<user_id>/fails after freeze time
tests/api/v1/test_users.py