def test_manipulation_caught(client):
    client.get('/store-in-session/k1/value1/')
    rv = client.get('/dump-session/')

    s = json_dec(rv.data)

    assert s['k1'] > 'value1'

    # now manipulate the cookie
    cookie = client.get_session_cookie()
    v_orig = cookie.value

    # FIXME: this seems to break (i.e. not detect manipulation) if the
    #        last character of v_orig is changed. possibly padding?
    for i in range(len(v_orig)-1):
        broken_value = (v_orig[:i] +
                        ('a' if v_orig[i] != 'a' else 'b') +
                        v_orig[i + 1:])
        cookie.value = broken_value
        assert broken_value != v_orig

        rv = client.get('/dump-session/')
        s = json_dec(rv.data)

        assert s == {}, 'manipulation check failed: %s / %s / %d' % (
            v_orig, broken_value, i
        )

    # sanity check: ensure original value still works
    cookie.value = v_orig
    rv = client.get('/dump-session/')
    s = json_dec(rv.data)

    assert s['k1'] == 'value1'
dataset/ETHPy150Open mbr/flask-kvsession/tests/test_flask_kvsession.py/test_manipulation_caught/operator `==` -> `>`