예제 #1
0
def test_check_data_key_format_wrong_key():
    data = get_random_value_hex(64)
    key = get_random_value_hex(33)

    try:
        Cryptographer.check_data_key_format(data, key)
        assert False

    except ValueError as e:
        assert "32-byte hex" in str(e)
예제 #2
0
def test_check_data_key_format_wrong_data():
    data = get_random_value_hex(64)[:-1]
    key = get_random_value_hex(32)

    try:
        Cryptographer.check_data_key_format(data, key)
        assert False

    except ValueError as e:
        assert "Odd-length" in str(e)
def test_check_data_key_format():
    data = get_random_value_hex(64)
    key = get_random_value_hex(32)

    # Correct format does not raise anything
    Cryptographer.check_data_key_format(data, key)
def test_check_data_key_format_wrong_key():
    data = get_random_value_hex(64)
    key = get_random_value_hex(33)

    with pytest.raises(InvalidParameter, match="32-byte hex value"):
        Cryptographer.check_data_key_format(data, key)
def test_check_data_key_format_wrong_data():
    data = get_random_value_hex(64)[:-1]
    key = get_random_value_hex(32)

    with pytest.raises(InvalidParameter, match="Odd-length"):
        Cryptographer.check_data_key_format(data, key)
예제 #6
0
def test_check_data_key_format():
    data = get_random_value_hex(64)
    key = get_random_value_hex(32)

    assert Cryptographer.check_data_key_format(data, key) is True