コード例 #1
0
ファイル: test_2_jwk.py プロジェクト: techguy613/pyjwkest
def test_urlsafe_base64decode():
    l = base64_to_long(N)
    # convert it to base64
    bys = long2intarr(l)
    data = struct.pack('%sB' % len(bys), *bys)
    if not len(data):
        data = '\x00'
    s0 = base64.b64encode(data)
    # try to convert it back to long, should throw an exception if the strict
    # function is used
    with pytest.raises(ValueError):
        base64url_to_long(s0)

    # Not else, should not raise exception
    l = base64_to_long(s0)
    assert l
コード例 #2
0
ファイル: test_2_jwk.py プロジェクト: techguy613/pyjwkest
def test_urlsafe_base64decode():
    l = base64_to_long(N)
    # convert it to base64
    bys = long2intarr(l)
    data = struct.pack("%sB" % len(bys), *bys)
    if not len(data):
        data = "\x00"
    s0 = base64.b64encode(data)
    # try to convert it back to long, should throw an exception if the strict
    # function is used
    with pytest.raises(ValueError):
        base64url_to_long(s0)

    # Not else, should not raise exception
    l = base64_to_long(s0)
    assert l
コード例 #3
0
def test_urlsafe_base64decode():
    l = base64_to_long(N)
    # convert it to base64
    bys = long2intarr(l)
    data = struct.pack('%sB' % len(bys), *bys)
    if not len(data):
        data = '\x00'
    s0 = base64.b64encode(data)
    # try to convert it back to long, should throw an exception if the strict
    # function is used
    try:
        l = base64url_to_long(s0)
    except ValueError:
        pass
    else:
        assert False
    # Not else
    l = base64_to_long(s0)
コード例 #4
0
ファイル: test_2_jwk.py プロジェクト: dallerbarn/pyjwkest
def test_urlsafe_base64decode():
    l = base64_to_long(N)
    # convert it to base64
    bys = long2intarr(l)
    data = struct.pack('%sB' % len(bys), *bys)
    if not len(data):
        data = '\x00'
    s0 = base64.b64encode(data)
    # try to convert it back to long, should throw an exception if the strict
    # function is used
    try:
        l = base64url_to_long(s0)
    except ValueError:
        pass
    else:
        assert False
    # Not else
    l = base64_to_long(s0)