def test_confirm_links_single_use():
    """Test that confirm links are single use"""
    app = create_ctfd()
    with app.app_context():
        set_config("verify_emails", True)
        register_user(app)
        client = login_as_user(app)

        to_addr = "user@examplectf.com"

        urandom_value = b"\xff" * 32
        with patch("os.urandom", return_value=urandom_value):
            verify_email_address(to_addr)

        r = client.get(
            "http://localhost/confirm/ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
        )
        user = Users.query.filter_by(email=to_addr).first()
        assert user.verified is True

        r = client.get(
            "http://localhost/confirm/ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
        )
        assert (
            "Your confirmation link is invalid, please generate a new one"
            in r.get_data(as_text=True)
        )
    destroy_ctfd(app)
Test that confirm links are single use
tests/utils/test_email.py