Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions src/tests/cli_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import re
import shutil
import codecs
from subprocess import Popen, PIPE

RNP_ROOT = None
Expand Down Expand Up @@ -185,27 +186,8 @@ def run_proc_windows(proc, params, stdin=None):
return (retcode, out, err)

if sys.version_info >= (3,):
def decode_string_escape(s):
bts = bytes(s, 'utf-8')
result = u''
candidate = bytearray()
utf = bytearray()
for b in bts:
if b > 0x7F:
if len(candidate) > 0:
result += candidate.decode('unicode-escape')
candidate.clear()
utf.append(b)
else:
if len(utf) > 0:
result += utf.decode('utf-8')
utf.clear()
candidate.append(b)
if len(candidate) > 0:
result += candidate.decode('unicode-escape')
if len(utf) > 0:
result += utf.decode('utf-8')
return result
def decode_string_escape(s: str) -> str:
return codecs.escape_decode(bytes(s, 'utf-8'))[0].decode()
def _decode(s):
return s
else: # Python 2
Expand Down
147 changes: 94 additions & 53 deletions src/tests/cli_tests.py

Large diffs are not rendered by default.

Binary file modified src/tests/data/test_large_packet/4g.bzip2.gpg
Binary file not shown.
Binary file modified src/tests/data/test_partial_length/message.txt.partial-1g
Binary file not shown.
Binary file modified src/tests/data/test_partial_length/message.txt.partial-256
Binary file not shown.
Binary file modified src/tests/data/test_partial_length/message.txt.partial-signed
Binary file not shown.
Binary file modified src/tests/data/test_partial_length/message.txt.partial-zero-last
Binary file not shown.
2 changes: 1 addition & 1 deletion src/tests/large-packet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TEST_F(rnp_tests, test_large_packet)

/* init ffi and inputs */
assert_rnp_success(rnp_ffi_create(&ffi, "GPG", "GPG"));
assert_rnp_success(rnp_input_from_path(&input, "data/keyrings/1/pubring.gpg"));
assert_rnp_success(rnp_input_from_path(&input, "data/keyrings/5/pubring.gpg"));
assert_rnp_success(rnp_load_keys(ffi, "GPG", input, RNP_LOAD_SAVE_PUBLIC_KEYS));
assert_rnp_success(rnp_input_destroy(input));

Expand Down
6 changes: 3 additions & 3 deletions src/tests/partial-length.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ test_partial_length_init(rnp_ffi_t *ffi, uint32_t key_flags)
assert_rnp_success(
rnp_ffi_set_pass_provider(*ffi, ffi_string_password_provider, (void *) "password"));
if (key_flags & RNP_LOAD_SAVE_SECRET_KEYS) {
assert_rnp_success(rnp_input_from_path(&input, "data/keyrings/1/secring.gpg"));
assert_rnp_success(rnp_input_from_path(&input, "data/keyrings/5/secring.gpg"));
assert_rnp_success(rnp_load_keys(*ffi, "GPG", input, key_flags));
assert_rnp_success(rnp_input_destroy(input));
}
if (key_flags & RNP_LOAD_SAVE_PUBLIC_KEYS) {
assert_rnp_success(rnp_input_from_path(&input, "data/keyrings/1/pubring.gpg"));
assert_rnp_success(rnp_input_from_path(&input, "data/keyrings/5/pubring.gpg"));
assert_rnp_success(rnp_load_keys(*ffi, "GPG", input, key_flags));
assert_rnp_success(rnp_input_destroy(input));
}
Expand Down Expand Up @@ -195,7 +195,7 @@ TEST_F(rnp_tests, test_partial_length_first_packet_length)
assert_rnp_success(rnp_input_from_callback(&input, dummy_reader, NULL, &reader_ctx));
assert_rnp_success(rnp_output_to_memory(&output, uncacheable_size + 1024));
assert_rnp_success(rnp_op_sign_create(&sign, ffi, input, output));
assert_rnp_success(rnp_locate_key(ffi, "keyid", "7BC6709B15C23A4A", &key));
assert_rnp_success(rnp_locate_key(ffi, "keyid", "0E33FD46FF10F19C", &key));
assert_rnp_success(rnp_op_sign_add_signature(sign, key, NULL));
assert_rnp_success(rnp_key_handle_destroy(key));
key = NULL;
Expand Down
Loading