Example #1
0
def test_verify_sig(app):
    """Test that token is verified."""
    payload = dict(foo=1)
    t = _jwt_encode(payload)
    old_key = app.secret_key
    try:
        app.secret_key = 'foo'
        with pytest.raises(jwt.exceptions.DecodeError):
            _jwt_decode(t)
    finally:
        app.secret_key = old_key
Example #2
0
def test_token_has_exp(app):
    """Test that token has exp field in payload."""
    payload = dict(foo=1)
    t = _jwt_encode(payload)
    p = _jwt_decode(t)
    assert 'exp' in p
Example #3
0
def test_token_enc_dec(app):
    """Test basic encoding and decoding of token."""
    payload = dict(foo=1)
    t = _jwt_encode(payload)
    p = _jwt_decode(t)
    assert p['foo'] == 1