Skip to content

Commit

Permalink
fix tests for new error codes
Browse files Browse the repository at this point in the history
improve partial line parsing in many tests
  • Loading branch information
jaromil committed Oct 11, 2023
1 parent e530f73 commit a8398de
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions test/testgen_sign_verify_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Then print the string 'Signature is valid'
and print the 'message'
EOF
run \$ZENROOM_EXECUTABLE -z -a sign_pubkey.json wrong_message.zen
assert_line '[W] The %%ALGOSIGN%% signature by Alice is not authentic'
assert_line --partial 'The %%ALGOSIGN%% signature by Alice is not authentic'
}
@test "Fail verification on a different public key" {
Expand All @@ -132,7 +132,7 @@ Then print the string 'Signature is valid'
and print the 'message'
EOF
run \$ZENROOM_EXECUTABLE -z -a wrong_pubkey.json wrong_pubkey.zen
assert_line '[W] The %%ALGOSIGN%% signature by Alice is not authentic'
assert_line --partial 'The %%ALGOSIGN%% signature by Alice is not authentic'
}
@test "Alice signs a big file" {
Expand Down
4 changes: 2 additions & 2 deletions test/zencode/bbs_sha.bats
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ When I verify the 'myStringArray' has a bbs signature in 'bbs signature' by 'Ali
Then print the string 'Signature is valid'
EOF
run $ZENROOM_EXECUTABLE -z -a '3messages_sha.json' -k sign_pubkey_sha.json wrong_message_sha.zen
assert_line '[W] The bbs signature by Alice is not authentic'
assert_line --partial 'The bbs signature by Alice is not authentic'
}

@test "Fail verification on a different public key" {
Expand All @@ -210,7 +210,7 @@ When I verify the 'myStringArray' has a bbs signature in 'bbs signature' by 'Ali
Then print the string 'Signature is valid'
EOF
run $ZENROOM_EXECUTABLE -z -a multi_msg_data_sha.json -k sign_pubkey_sha.json verify_from_wrong_pk_sha.zen
assert_line '[W] The bbs signature by Alice is not authentic'
assert_line --partial 'The bbs signature by Alice is not authentic'
}

@test "DOCS: Generate keys for Alice" {
Expand Down
4 changes: 2 additions & 2 deletions test/zencode/bbs_shake.bats
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ When I verify the 'myStringArray' has a bbs signature in 'bbs signature' by 'Ali
Then print the string 'Signature is valid'
EOF
run $ZENROOM_EXECUTABLE -z -a '3messages_shake.json' -k sign_pubkey_shake.json wrong_message_shake.zen
assert_line '[W] The bbs signature by Alice is not authentic'
assert_line --partial 'The bbs signature by Alice is not authentic'
}

@test "Fail verification on a different public key" {
Expand All @@ -210,5 +210,5 @@ When I verify the 'myStringArray' has a bbs signature in 'bbs signature' by 'Ali
Then print the string 'Signature is valid'
EOF
run $ZENROOM_EXECUTABLE -z -a multi_msg_data_shake.json -k sign_pubkey_shake.json verify_from_wrong_pk_shake.zen
assert_line '[W] The bbs signature by Alice is not authentic'
assert_line --partial 'The bbs signature by Alice is not authentic'
}
6 changes: 3 additions & 3 deletions test/zencode/ethereum.bats
Original file line number Diff line number Diff line change
Expand Up @@ -758,8 +758,8 @@ When I verify the ethereum address string 'string address' is valid
Then print the string 'This fails'
EOF
run $ZENROOM_EXECUTABLE -z -a checksum_fail.json checksum_fail.zen
assert_line '[W] "Invalid encoding for ethereum address. Expected encoding: 0x1e30e53E87869aaD8dC5A1A9dAc31a8dD3559460"'
assert_line '[W] [!] The address has a wrong encoding'
assert_line --partial 'Invalid encoding for ethereum address. Expected encoding: 0x1e30e53E87869aaD8dC5A1A9dAc31a8dD3559460'
assert_line --partial 'The address has a wrong encoding'
}

@test "Call generic smart contract" {
Expand Down Expand Up @@ -976,7 +976,7 @@ EOF
Then print the 'result_array'
EOF
run $ZENROOM_EXECUTABLE -z -a fail_array_verification.data fail_array_verification.zen
assert_line '[W] The ethereum signature by 0xe1C2F1ACb2758c4D88EDb84e0306A0a96682E62a is not authentic'
assert_line --partial 'The ethereum signature by 0xe1C2F1ACb2758c4D88EDb84e0306A0a96682E62a is not authentic'
}

@test "create the verification result of array of signature" {
Expand Down
4 changes: 2 additions & 2 deletions test/zencode/generic_bbs.bats
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Then print the string 'Signature is valid'
and print the 'message'
EOF
run $ZENROOM_EXECUTABLE -z -a sign_pubkey.json wrong_message.zen
assert_line '[W] The bbs signature by Alice is not authentic'
assert_line --partial 'The bbs signature by Alice is not authentic'
}

@test "Fail verification on a different public key" {
Expand All @@ -126,7 +126,7 @@ Then print the string 'Signature is valid'
and print the 'message'
EOF
run $ZENROOM_EXECUTABLE -z -a wrong_pubkey.json wrong_pubkey.zen
assert_line '[W] The bbs signature by Alice is not authentic'
assert_line --partial 'The bbs signature by Alice is not authentic'
}

@test "Alice signs a big file" {
Expand Down
4 changes: 2 additions & 2 deletions test/zencode/generic_dilithium.bats
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Then print the string 'Signature is valid'
and print the 'message'
EOF
run $ZENROOM_EXECUTABLE -z -a sign_pubkey.json wrong_message.zen
assert_line '[W] The dilithium signature by Alice is not authentic'
assert_line --partial 'The dilithium signature by Alice is not authentic'
}

@test "Fail verification on a different public key" {
Expand All @@ -126,7 +126,7 @@ Then print the string 'Signature is valid'
and print the 'message'
EOF
run $ZENROOM_EXECUTABLE -z -a wrong_pubkey.json wrong_pubkey.zen
assert_line '[W] The dilithium signature by Alice is not authentic'
assert_line --partial 'The dilithium signature by Alice is not authentic'
}

@test "Alice signs a big file" {
Expand Down
4 changes: 2 additions & 2 deletions test/zencode/generic_ecdh.bats
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Then print the string 'Signature is valid'
and print the 'message'
EOF
run $ZENROOM_EXECUTABLE -z -a sign_pubkey.json wrong_message.zen
assert_line '[W] The ecdh signature by Alice is not authentic'
assert_line --partial 'The ecdh signature by Alice is not authentic'
}

@test "Fail verification on a different public key" {
Expand All @@ -126,7 +126,7 @@ Then print the string 'Signature is valid'
and print the 'message'
EOF
run $ZENROOM_EXECUTABLE -z -a wrong_pubkey.json wrong_pubkey.zen
assert_line '[W] The ecdh signature by Alice is not authentic'
assert_line --partial 'The ecdh signature by Alice is not authentic'
}

@test "Alice signs a big file" {
Expand Down
4 changes: 2 additions & 2 deletions test/zencode/generic_eddsa.bats
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Then print the string 'Signature is valid'
and print the 'message'
EOF
run $ZENROOM_EXECUTABLE -z -a sign_pubkey.json wrong_message.zen
assert_line '[W] The eddsa signature by Alice is not authentic'
assert_line --partial 'The eddsa signature by Alice is not authentic'
}

@test "Fail verification on a different public key" {
Expand All @@ -126,7 +126,7 @@ Then print the string 'Signature is valid'
and print the 'message'
EOF
run $ZENROOM_EXECUTABLE -z -a wrong_pubkey.json wrong_pubkey.zen
assert_line '[W] The eddsa signature by Alice is not authentic'
assert_line --partial 'The eddsa signature by Alice is not authentic'
}

@test "Alice signs a big file" {
Expand Down
4 changes: 2 additions & 2 deletions test/zencode/generic_schnorr.bats
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Then print the string 'Signature is valid'
and print the 'message'
EOF
run $ZENROOM_EXECUTABLE -z -a sign_pubkey.json wrong_message.zen
assert_line '[W] The schnorr signature by Alice is not authentic'
assert_line --partial 'The schnorr signature by Alice is not authentic'
}

@test "Fail verification on a different public key" {
Expand All @@ -126,7 +126,7 @@ Then print the string 'Signature is valid'
and print the 'message'
EOF
run $ZENROOM_EXECUTABLE -z -a wrong_pubkey.json wrong_pubkey.zen
assert_line '[W] The schnorr signature by Alice is not authentic'
assert_line --partial 'The schnorr signature by Alice is not authentic'
}

@test "Alice signs a big file" {
Expand Down
6 changes: 3 additions & 3 deletions test/zencode/given.bats
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ rule check version 1.0.0
Then print the 'random object'
EOF
run $ZENROOM_EXECUTABLE -z -a fail_nothing.data fail_nothing.zen
assert_line '[W] Undesired data passed as input'
assert_line --partial 'Undesired data passed as input'
}
@test "Given I have a '' named ''" {
echo '{ "anykey": "anyvalue" }' | save_asset 'have_anyvalue.data'
Expand Down Expand Up @@ -447,15 +447,15 @@ Given I have a 'string array' in path 'my_dict.result.not_my_string_array'
Then print the data
EOF
run $ZENROOM_EXECUTABLE -z -a given_in_path.data given_in_path_fail_not_found.zen
assert_line '[W] [!] Key not_my_string_array not found in result'
assert_line --partial 'Key not_my_string_array not found in result'

cat << EOF | save_asset given_in_path_fail_not_a_table.zen
Given I have a 'string array' in path 'my_dict.result.my_hex.not_existing_element'
Then print the data
EOF
run $ZENROOM_EXECUTABLE -z -a given_in_path.data given_in_path_fail_not_a_table.zen
assert_line '[W] [!] Object is not a table: my_hex'
assert_line --partial 'Object is not a table: my_hex'
}

@test "Read hex with 0x prefix" {
Expand Down
12 changes: 6 additions & 6 deletions test/zencode/w3c.bats
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,13 @@ Given I have a 'did document'
Then print the 'did document'
EOF
run $ZENROOM_EXECUTABLE -z -a invalid_scheme.json did_document_parsing.zen
assert_line '[W] Invalid DID document: invalid scheme'
assert_line --partial 'Invalid DID document: invalid scheme'
run $ZENROOM_EXECUTABLE -z -a invalid_method_name.json did_document_parsing.zen
assert_line '[W] Invalid DID document: invalid method-name'
assert_line --partial 'Invalid DID document: invalid method-name'
run $ZENROOM_EXECUTABLE -z -a invalid_method_specific_identifier.json did_document_parsing.zen
assert_line '[W] Invalid DID document: invalid method specific identifier'
assert_line --partial 'Invalid DID document: invalid method specific identifier'
run $ZENROOM_EXECUTABLE -z -a invalid_method_specific_identifier2.json did_document_parsing.zen
assert_line '[W] Invalid DID document: invalid method specific identifier'
assert_line --partial 'Invalid DID document: invalid method specific identifier'
run $ZENROOM_EXECUTABLE -z -a valid_id.json did_document_parsing.zen
assert_success
}
Expand Down Expand Up @@ -507,7 +507,7 @@ When I create the 'schnorr' public key from did document 'didDocument'
Then print the data
EOF
run $ZENROOM_EXECUTABLE -z -a did_document.json pk_from_doc_not_exist.zen
assert_line '[W] schnorr_public_key not found in the did document didDocument'
assert_line --partial 'schnorr_public_key not found in the did document didDocument'
}

@test "verify the did document named 'did_document' is signed by 'signer_did_document'" {
Expand Down Expand Up @@ -699,7 +699,7 @@ When I verify the did document named 'did_document' is signed by 'not_signer_did
Then print the string 'should not be verified'
EOF
run $ZENROOM_EXECUTABLE -z -a did_documents.json verify_wrong_did_doc.zen
assert_line '[W] The signer id in proof is different from the one in not_signer_did_document'
assert_line --partial 'The signer id in proof is different from the one in not_signer_did_document'
}
@test "JWT HS256 creation" {
cat <<EOF > jwt_hs256.data
Expand Down
2 changes: 1 addition & 1 deletion test/zencode/zencode_exec.bats
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ EOF
>&3 echo
awk '/TRACE:/ {print $4}' full.json | sed 's/",//' | base64 -d > $TMP/out
save_output trace.json
assert_output '[" Z Given nothing"," Z When I create the random object of '"'"'256'"'"' bits"," Z and debug"]'
assert_output '["+1 Given nothing","+2 When I create the random object of '"'"'256'"'"' bits","+3 and debug"]'
}

@test "Execute zencode-exec with all stdin inputs including extra" {
Expand Down

0 comments on commit a8398de

Please sign in to comment.