示例#1
0
def test_decode_token_invalid_key_input(_mocked_fetch_public_key,
                                        _mocked_get_audiences):
    """Test the handling wrong public key tokens."""
    payload = {'some': 'payload', 'email_verified': '1'}
    token = jwt.encode(payload, PRIVATE_KEY, algorithm='RS256').decode("utf-8")
    with pytest.raises(AuthError):
        assert decode_user_token(APP, token) is not None
示例#2
0
def test_decode_token_invalid_input_6(_mocked_fetch_public_key, _mocked_get_audiences):
    """Test the handling wrong JWT tokens."""
    payload = {
        'some': 'payload',
    }
    token = jwt.encode(payload, PRIVATE_KEY, algorithm='RS256').decode("utf-8")
    assert decode_user_token(APP, token) is None
def test_decode_token_valid_input(_mocked_fetch_public_key, _mocked_get_audiences):
    """Test the handling wrong JWT tokens."""
    payload = {
        'some': 'payload',
        'email_verified': '1',
        'aud': 'openshiftio-public'
    }
    token = jwt.encode(payload, PRIVATE_KEY, algorithm='RS256').decode("utf-8")
    assert decode_user_token(APP, token) is not None
示例#4
0
def test_decode_token_invalid_input_5(_mocked_fetch_public_key, _mocked_get_audiences):
    """Test the handling wrong JWT tokens."""
    assert decode_user_token(APP, "Bearer something") is None
示例#5
0
def test_decode_token_invalid_input_4(_mocked_fetch_public_key, _mocked_get_audiences):
    """Test the invalid input handling during token decoding."""
    assert decode_user_token(APP, "Bearer ") is None
示例#6
0
def test_decode_token_invalid_input_3(_mocked_fetch_public_key,
                                      _mocked_get_audiences):
    """Test the invalid input handling during token decoding."""
    with pytest.raises(Exception):
        assert decode_user_token(APP, "Bearer ") is None
示例#7
0
def test_decode_token_invalid_input_2(_mocked_fetch_public_key,
                                      _mocked_get_audiences):
    """Test the invalid input handling during token decoding."""
    with pytest.raises(AuthError):
        assert decode_user_token(APP, "Foobar") is None