diff --git a/xtest/golden/with-json-object-assertions-java.tdf b/xtest/golden/with-json-object-assertions-java.tdf new file mode 100644 index 00000000..48d4c850 Binary files /dev/null and b/xtest/golden/with-json-object-assertions-java.tdf differ diff --git a/xtest/sdk/go/cli.sh b/xtest/sdk/go/cli.sh index 946043d2..da481ec5 100755 --- a/xtest/sdk/go/cli.sh +++ b/xtest/sdk/go/cli.sh @@ -78,6 +78,9 @@ elif [ "$1" == "decrypt" ]; then if [ -n "$8" ]; then args+=(--with-assertion-verification-keys "$8") fi + if [ "$VERIFY_ASSERTIONS" == 'false' ]; then + args+=(--no-verify-assertions) + fi echo "${cmd[@]}" decrypt "${args[@]}" "$2" "${cmd[@]}" decrypt "${args[@]}" "$2" else diff --git a/xtest/sdk/java/cli.sh b/xtest/sdk/java/cli.sh index 8f041c7c..38d6e6ef 100755 --- a/xtest/sdk/java/cli.sh +++ b/xtest/sdk/java/cli.sh @@ -77,5 +77,9 @@ if [ -n "$8" ]; then args+=(--with-assertion-verification-keys "$8") fi +if [ "$VERIFY_ASSERTIONS" == 'false' ]; then + args+=(--with-assertion-verification-disabled) +fi + echo java -jar "$SCRIPT_DIR"/cmdline.jar "${args[@]}" -f "$2" ">" "$3" java -jar "$SCRIPT_DIR"/cmdline.jar "${args[@]}" -f "$2" >"$3" diff --git a/xtest/sdk/js/cli/cli.sh b/xtest/sdk/js/cli/cli.sh index 01964574..bac45402 100755 --- a/xtest/sdk/js/cli/cli.sh +++ b/xtest/sdk/js/cli/cli.sh @@ -82,6 +82,9 @@ if [ "$1" == "encrypt" ]; then npx $CTL encrypt "$2" "${args[@]}" elif [ "$1" == "decrypt" ]; then + if [ "$VERIFY_ASSERTIONS" == 'false' ]; then + args+=(--noVerifyAssertions) + fi npx $CTL decrypt "$2" "${args[@]}" else echo "Incorrect argument provided" diff --git a/xtest/tdfs.py b/xtest/tdfs.py index ffc31a34..600ee3b1 100644 --- a/xtest/tdfs.py +++ b/xtest/tdfs.py @@ -249,6 +249,7 @@ def decrypt( rt_file: str, fmt: format_type = "nano", assert_keys: str = "", + verify_assertions: bool = True, ): c = [ sdk_paths[sdk], @@ -265,8 +266,11 @@ def decrypt( "", assert_keys, ] + env = dict(os.environ) + if not verify_assertions: + env |= {"VERIFY_ASSERTIONS": "false"} logger.info(f"dec [{' '.join(c)}]") - subprocess.check_output(c, stderr=subprocess.STDOUT) + subprocess.check_output(c, stderr=subprocess.STDOUT, env=env) def supports(sdk: sdk_type, feature: feature_type) -> bool: diff --git a/xtest/test_legacy.py b/xtest/test_legacy.py index f68e6bb3..d647d3e5 100644 --- a/xtest/test_legacy.py +++ b/xtest/test_legacy.py @@ -26,31 +26,42 @@ def test_decrypt_small( assert b == expected_bytes -def test_decrypt_no_splitid( +def test_decrypt_big( decrypt_sdk: tdfs.sdk_type, tmp_dir, ): - ct_file = get_golden_file("no-splitids-java.tdf") - rt_file = os.path.join(tmp_dir, "no-splitids-java.untdf") + ct_file = get_golden_file("big-java-4.3.0-e0f8caf.tdf") + rt_file = os.path.join(tmp_dir, "big-java.untdf") tdfs.decrypt(decrypt_sdk, ct_file, rt_file, fmt="ztdf") file_stats = os.stat(rt_file) - assert file_stats.st_size == 5 * 2**10 + assert file_stats.st_size == 10 * 2**20 expected_bytes = bytes([0] * 1024) with open(rt_file, "rb") as f: while b := f.read(1024): assert b == expected_bytes -def test_decrypt_big( +def test_decrypt_no_splitid( decrypt_sdk: tdfs.sdk_type, tmp_dir, ): - ct_file = get_golden_file("big-java-4.3.0-e0f8caf.tdf") - rt_file = os.path.join(tmp_dir, "big-java.untdf") + ct_file = get_golden_file("no-splitids-java.tdf") + rt_file = os.path.join(tmp_dir, "no-splitids-java.untdf") tdfs.decrypt(decrypt_sdk, ct_file, rt_file, fmt="ztdf") file_stats = os.stat(rt_file) - assert file_stats.st_size == 10 * 2**20 + assert file_stats.st_size == 5 * 2**10 expected_bytes = bytes([0] * 1024) with open(rt_file, "rb") as f: while b := f.read(1024): assert b == expected_bytes + + +def test_decrypt_object_statement_value_json( + decrypt_sdk: tdfs.sdk_type, + tmp_dir, +): + ct_file = get_golden_file("with-json-object-assertions-java.tdf") + rt_file = os.path.join(tmp_dir, "with-json-object-assertions-java.untdf") + tdfs.decrypt(decrypt_sdk, ct_file, rt_file, fmt="ztdf", verify_assertions=False) + with open(rt_file, "rb") as f: + assert f.read().decode("utf-8") == "text"