commit be698dbe4b36dbb1667b4f8ae245decb3909b4c2
parent 3d46e80874d28071c2c550442431bade3ef83e12
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
Date: Mon, 6 May 2024 10:23:53 +0200
[testing] submit test
Diffstat:
7 files changed, 84 insertions(+), 43 deletions(-)
diff --git a/src/donau/donau-httpd_batch-issue.c b/src/donau/donau-httpd_batch-issue.c
@@ -182,7 +182,7 @@ DH_handler_issue_receipts_post (struct DH_RequestContext *rc,
else
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "empty array of budi key pairs!\n");
+ "Empty array of budi key pairs!\n");
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_GENERIC_PARAMETER_MALFORMED,
@@ -202,12 +202,13 @@ DH_handler_issue_receipts_post (struct DH_RequestContext *rc,
{
case GNUNET_DB_STATUS_HARD_ERROR:
case GNUNET_DB_STATUS_SOFT_ERROR:
- GNUNET_break (0);
+ GNUNET_break_op (0);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_FETCH_FAILED,
NULL);
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+ GNUNET_break_op (0);
return TALER_MHD_reply_with_error (
rc->connection,
MHD_HTTP_NOT_FOUND,
@@ -304,11 +305,13 @@ start:
struct DH_DonationUnitKey *dk;
if (NULL == (dk = DH_keys_donation_unit_by_hash (
- &bkps[i].h_donation_unit_pub)))
+ &bkps[i].h_donation_unit_pub))) {
+ GNUNET_break_op (0);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_DONAU_GENERIC_KEYS_MISSING,
NULL);
+ }
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"public key value: %lu.%u\n",
dk->value.value, dk->value.fraction);
@@ -330,11 +333,13 @@ start:
batch_sign_ec = DH_keys_donation_unit_batch_sign (num_bkps,
bkps_sign_data,
du_sigs);
- if (TALER_EC_NONE != batch_sign_ec)
+ if (TALER_EC_NONE != batch_sign_ec) {
+ GNUNET_break_op (0);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
batch_sign_ec, // TODO:other EC
NULL);
+ }
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"made blind signatures!\n");
/* save new receipts to date and save receipts Request (blinded signatures,
@@ -363,11 +368,13 @@ start:
second_time = true;
goto start;
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
- if (! smaller_than_max_per_year)
+ if (! smaller_than_max_per_year) {
+ GNUNET_break_op (0);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_DONAU_EXCEEDING_DONATION_LIMIT,
NULL);
+ }
break;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
diff --git a/src/include/donau_testing_lib.h b/src/include/donau_testing_lib.h
@@ -191,7 +191,9 @@ TALER_TESTING_get_donau_url (
op (charity_id, const unsigned long long) \
op (donau_url, const char) \
op (donau_keys, struct DONAU_Keys) \
- op (salted_tax_id_hash, struct DONAU_HashDonorTaxId)
+ op (salted_tax_id_hash, const struct DONAU_HashDonorTaxId) \
+ op (donation_receipts, const struct DONAU_DonationReceipt*) \
+ op (number_receipts, const size_t)
/**
diff --git a/src/lib/donau_api_batch_issue_receipts.c b/src/lib/donau_api_batch_issue_receipts.c
@@ -221,6 +221,7 @@ handle_batch_issue_finished (void *cls,
birh->job = NULL;
switch (response_code)
{
+ case MHD_HTTP_OK:
case MHD_HTTP_CREATED:
if (GNUNET_OK !=
handle_batch_issue_ok (j,
diff --git a/src/testing/test_donau_api.c b/src/testing/test_donau_api.c
@@ -96,12 +96,12 @@ run (void *cls,
"post-charity",
2024,
"7560001010000", // tax id
- "1234", //salt for tax id hash
+ "1234", // salt for tax id hash
MHD_HTTP_CREATED),
-// TALER_TESTING_cmd_submit_receipts ("submit-receipts",
-// "issue-receipts", // cmd trait reference
-// 2024,
-// MHD_HTTP_OK),
+ TALER_TESTING_cmd_submit_receipts ("submit-receipts",
+ "issue-receipts", // cmd trait reference
+ 2024,
+ MHD_HTTP_OK),
TALER_TESTING_cmd_charity_delete ("delete-charity",
"post-charity", // cmd trait reference
&bearer,
diff --git a/src/testing/testing_api_cmd_issue_receipts.c b/src/testing/testing_api_cmd_issue_receipts.c
@@ -96,7 +96,7 @@ struct StatusState
/**
* Blinding secrets
*/
- union GNUNET_CRYPTO_BlindingSecretP *blinded_secrets;
+ union GNUNET_CRYPTO_BlindingSecretP *blinding_secrets;
/**
* Blinding values. Cs-nonces, cipher.
@@ -139,16 +139,18 @@ issue_receipts_status_cb (void *cls,
TALER_TESTING_interpreter_fail (ss->is);
return;
}
- struct DONAU_BlindedDonationUnitSignature *blinded_sigs = biresp->details.ok.blinded_sigs;
- for (size_t i = 0; i < ss->num_bkp; i++) {
- GNUNET_assert ( GNUNET_OK ==
- DONAU_donation_unit_sig_unblind(
- &ss->receipts[i].donation_unit_sig,
- &blinded_sigs[i],
- &ss->blinded_secrets[i],
- &ss->h_udis[i],
- ss->alg_values[i],
- &ss->keys->donation_unit_keys[0].key));
+ struct DONAU_BlindedDonationUnitSignature *blinded_sigs =
+ biresp->details.ok.blinded_sigs;
+ for (size_t i = 0; i < ss->num_bkp; i++)
+ {
+ GNUNET_assert (GNUNET_OK ==
+ DONAU_donation_unit_sig_unblind (
+ &ss->receipts[i].donation_unit_sig,
+ &blinded_sigs[i],
+ &ss->blinding_secrets[i],
+ &ss->h_udis[i],
+ ss->alg_values[i],
+ &ss->keys->donation_unit_keys[0].key));
}
TALER_TESTING_interpreter_next (ss->is);
}
@@ -213,8 +215,9 @@ status_run (void *cls,
// TODO: Free
ss->bkps =
- GNUNET_new_array (ss->num_bkp, struct DONAU_BlindedUniqueDonorIdentifierKeyPair);
- ss->blinded_secrets =
+ GNUNET_new_array (ss->num_bkp, struct
+ DONAU_BlindedUniqueDonorIdentifierKeyPair);
+ ss->blinding_secrets =
GNUNET_new_array (ss->num_bkp, union GNUNET_CRYPTO_BlindingSecretP);
ss->receipts =
GNUNET_new_array (ss->num_bkp, struct DONAU_DonationReceipt);
@@ -238,14 +241,14 @@ status_run (void *cls,
sizeof (ps));
DONAU_budi_secret_create (&ps,
alg_values,
- &ss->blinded_secrets[cnt]);
+ &ss->blinding_secrets[cnt]);
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
udi_nonce,
sizeof (*udi_nonce));
GNUNET_assert (GNUNET_OK ==
DONAU_donation_unit_blind (
&ss->keys->donation_unit_keys[0].key,
- &ss->blinded_secrets[cnt],
+ &ss->blinding_secrets[cnt],
NULL, /* no cs-nonce needed for rsa */
udi_nonce,
ss->h_donor_tax_id,
@@ -324,7 +327,11 @@ issue_receipts_traits (void *cls,
{
struct StatusState *ss = cls;
struct TALER_TESTING_Trait traits[] = {
- TALER_TESTING_make_trait_salted_tax_id_hash (ss->h_donor_tax_id),
+ TALER_TESTING_make_trait_salted_tax_id_hash (
+ (const struct DONAU_HashDonorTaxId *) ss->h_donor_tax_id),
+ TALER_TESTING_make_trait_donation_receipts (
+ (const struct DONAU_DonationReceipt **) &ss->receipts),
+ TALER_TESTING_make_trait_number_receipts ((const size_t *) &ss->num_bkp),
TALER_TESTING_trait_end ()
};
diff --git a/src/testing/testing_api_cmd_submit_receipts.c b/src/testing/testing_api_cmd_submit_receipts.c
@@ -49,6 +49,11 @@ struct StatusState
struct TALER_TESTING_Interpreter *is;
/**
+ * Issue receipts reference.
+ */
+ const char *issue_receipt_reference;
+
+ /**
* corresponding year
*/
unsigned long long year;
@@ -61,7 +66,7 @@ struct StatusState
/**
* array of donation receipts
*/
- struct DONAU_DonationReceipt *receipts;
+ const struct DONAU_DonationReceipt *receipts;
/**
* donau keys
@@ -143,18 +148,32 @@ status_run (void *cls,
ss->keys = keys;
}
- // TODO: Get receipts from issue receipts test
-
- ss->receipts
- = GNUNET_new_array (ss->num_receipts,
- struct DONAU_DonationReceipt);
- for (size_t cnt = 0; cnt < ss->num_receipts; cnt++)
+ /* Get donau keys from trait */
{
- DONAU_donation_unit_pub_hash (&ss->keys->donation_unit_keys[0].key,
- &ss->receipts[cnt].h_donation_unit_pub);
+ const struct TALER_TESTING_Command *receipts_cmd;
+ const struct DONAU_DonationReceipt **receipts;
+ const struct DONAU_HashDonorTaxId *h_donor_tax_id;
+ const size_t *num_receipts;
+
+ receipts_cmd = TALER_TESTING_interpreter_lookup_command (is,
+ ss->issue_receipt_reference);
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_donation_receipts (receipts_cmd, &receipts) ||
+ GNUNET_OK !=
+ TALER_TESTING_get_trait_salted_tax_id_hash (receipts_cmd, &h_donor_tax_id) ||
+ GNUNET_OK !=
+ TALER_TESTING_get_trait_number_receipts (receipts_cmd, &num_receipts) )
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (is);
+ return;
+ }
+ ss->num_receipts = *num_receipts;
+ ss->receipts = *receipts;
+ ss->h_donor_tax_id = h_donor_tax_id;
}
- // const struct DONAU_DonationReceipt *receipts = ss->receipts;
+
ss->bsrh = DONAU_donor_receipts_to_statement (
TALER_TESTING_interpreter_get_context (is),
TALER_TESTING_get_donau_url (is),
@@ -205,7 +224,8 @@ TALER_TESTING_cmd_submit_receipts (const char *label,
ss->year = year;
ss->expected_response_code = expected_response_code;
- // ss->h_donor_tax_id = &h_donor_tax_id;
+ ss->issue_receipt_reference = issue_receipt_reference;
+
{
struct TALER_TESTING_Command cmd = {
.cls = ss,
diff --git a/src/util/donau_crypto.c b/src/util/donau_crypto.c
@@ -173,13 +173,14 @@ DONAU_donation_receipt_verify (
sizeof (*h_udi));
}
+
enum GNUNET_GenericReturnValue
DONAU_donation_unit_blind (
const struct DONAU_DonationUnitPublicKey *du_pub,
const union GNUNET_CRYPTO_BlindingSecretP *budi_secret,
const union GNUNET_CRYPTO_BlindSessionNonce *cs_nonce,
- const struct DONAU_UniqueDonorIdentifierNonce *udi_nonce,//message
- const struct DONAU_HashDonorTaxId *h_tax_id, //message
+ const struct DONAU_UniqueDonorIdentifierNonce *udi_nonce,// message
+ const struct DONAU_HashDonorTaxId *h_tax_id, // message
const struct DONAU_BatchIssueValues *alg_values,
struct DONAU_UniqueDonorIdentifierHashP *udi_hash,
struct DONAU_BlindedUniqueDonorIdentifier *budi)
@@ -189,12 +190,13 @@ DONAU_donation_unit_blind (
GNUNET_CRYPTO_hash_context_read (hash_context,
udi_nonce,
- sizeof(struct DONAU_UniqueDonorIdentifierNonce)),
+ sizeof(struct
+ DONAU_UniqueDonorIdentifierNonce)),
GNUNET_CRYPTO_hash_context_read (hash_context,
- h_tax_id,
+ h_tax_id,
sizeof(struct DONAU_HashDonorTaxId));
GNUNET_CRYPTO_hash_context_finish (hash_context,
- &udi_hash->hash);
+ &udi_hash->hash);
budi->blinded_message
= GNUNET_CRYPTO_message_blind_to_sign (du_pub->bsign_pub_key,
@@ -208,6 +210,7 @@ DONAU_donation_unit_blind (
return GNUNET_OK;
}
+
enum GNUNET_GenericReturnValue
DONAU_donation_unit_sig_unblind (
struct DONAU_DonationUnitSignature *du_sig,
@@ -232,6 +235,7 @@ DONAU_donation_unit_sig_unblind (
return GNUNET_OK;
}
+
void
DONAU_budi_secret_create (
const struct DONAU_BudiMasterSecretP *ps,