aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-07-25 22:03:53 +0200
committerChristian Grothoff <christian@grothoff.org>2024-07-29 12:18:48 +0200
commit007ce3bcb9f0406a6b833bff2ae9463bc390bc33 (patch)
tree0e75bfdd046da53753f1929721f4e64d56c3e479
parentd825ef10974b1a9087874f289985f988e2e1b440 (diff)
fix age restriction FTBFS
-rw-r--r--src/testing/test_exchange_api_age_restriction.c339
1 files changed, 194 insertions, 145 deletions
diff --git a/src/testing/test_exchange_api_age_restriction.c b/src/testing/test_exchange_api_age_restriction.c
index 5ba24a00c..d82b00191 100644
--- a/src/testing/test_exchange_api_age_restriction.c
+++ b/src/testing/test_exchange_api_age_restriction.c
@@ -61,7 +61,8 @@ static bool uses_cs;
* @param label label to use for the command.
*/
#define CMD_EXEC_WIREWATCH(label) \
- TALER_TESTING_cmd_exec_wirewatch2 (label, config_file, "exchange-account-2")
+ TALER_TESTING_cmd_exec_wirewatch2 (label, config_file, \
+ "exchange-account-2")
/**
* Execute the taler-exchange-aggregator, closer and transfer commands with
@@ -70,9 +71,9 @@ static bool uses_cs;
* @param label label to use for the command.
*/
#define CMD_EXEC_AGGREGATOR(label) \
- TALER_TESTING_cmd_sleep ("sleep-before-aggregator", 2), \
- TALER_TESTING_cmd_exec_aggregator (label "-aggregator", config_file), \
- TALER_TESTING_cmd_exec_transfer (label "-transfer", config_file)
+ TALER_TESTING_cmd_sleep ("sleep-before-aggregator", 2), \
+ TALER_TESTING_cmd_exec_aggregator (label "-aggregator", config_file), \
+ TALER_TESTING_cmd_exec_transfer (label "-transfer", config_file)
/**
@@ -83,9 +84,9 @@ static bool uses_cs;
* @param amount amount to transfer, i.e. "EUR:1"
*/
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
- TALER_TESTING_cmd_admin_add_incoming (label, amount, \
- &cred.ba, \
- cred.user42_payto)
+ TALER_TESTING_cmd_admin_add_incoming (label, amount, \
+ &cred.ba, \
+ cred.user42_payto)
/**
* Main function that will tell the interpreter what commands to
@@ -113,13 +114,15 @@ run (void *cls,
/**
* Move money to the exchange's bank account.
*/
- CMD_TRANSFER_TO_EXCHANGE ("create-reserve-age",
- "EUR:6.01"),
- TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-age",
- "EUR:6.01",
- cred.user42_payto,
- cred.exchange_payto,
- "create-reserve-age"),
+ CMD_TRANSFER_TO_EXCHANGE (
+ "create-reserve-age",
+ "EUR:6.01"),
+ TALER_TESTING_cmd_check_bank_admin_transfer (
+ "check-create-reserve-age",
+ "EUR:6.01",
+ cred.user42_payto,
+ cred.exchange_payto,
+ "create-reserve-age"),
/**
* Make a reserve exist, according to the previous
* transfer.
@@ -128,11 +131,12 @@ run (void *cls,
/**
* Withdraw EUR:5.
*/
- TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-age-1",
- "create-reserve-age",
- "EUR:5",
- 13,
- MHD_HTTP_OK),
+ TALER_TESTING_cmd_withdraw_amount (
+ "withdraw-coin-age-1",
+ "create-reserve-age",
+ "EUR:5",
+ 13,
+ MHD_HTTP_OK),
TALER_TESTING_cmd_end ()
};
@@ -141,25 +145,28 @@ run (void *cls,
/**
* Spend the coin.
*/
- TALER_TESTING_cmd_deposit ("deposit-simple-age",
- "withdraw-coin-age-1",
- 0,
- cred.user42_payto,
- "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
- GNUNET_TIME_UNIT_ZERO,
- "EUR:4.99",
- MHD_HTTP_OK),
- TALER_TESTING_cmd_deposit_replay ("deposit-simple-replay-age",
- "deposit-simple-age",
- MHD_HTTP_OK),
+ TALER_TESTING_cmd_deposit (
+ "deposit-simple-age",
+ "withdraw-coin-age-1",
+ 0,
+ cred.user42_payto,
+ "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
+ GNUNET_TIME_UNIT_ZERO,
+ "EUR:4.99",
+ MHD_HTTP_OK),
+ TALER_TESTING_cmd_deposit_replay (
+ "deposit-simple-replay-age",
+ "deposit-simple-age",
+ MHD_HTTP_OK),
TALER_TESTING_cmd_end ()
};
struct TALER_TESTING_Command refresh_age[] = {
/* Fill reserve with EUR:5, 1ct is for fees. */
- CMD_TRANSFER_TO_EXCHANGE ("refresh-create-reserve-age-1",
- "EUR:6.01"),
+ CMD_TRANSFER_TO_EXCHANGE (
+ "refresh-create-reserve-age-1",
+ "EUR:6.01"),
TALER_TESTING_cmd_check_bank_admin_transfer (
"ck-refresh-create-reserve-age-1",
"EUR:6.01",
@@ -173,83 +180,93 @@ run (void *cls,
/**
* Withdraw EUR:7 with age restriction for age 13.
*/
- TALER_TESTING_cmd_withdraw_amount ("refresh-withdraw-coin-age-1",
- "refresh-create-reserve-age-1",
- "EUR:5",
- 13,
- MHD_HTTP_OK),
+ TALER_TESTING_cmd_withdraw_amount (
+ "refresh-withdraw-coin-age-1",
+ "refresh-create-reserve-age-1",
+ "EUR:5",
+ 13,
+ MHD_HTTP_OK),
/* Try to partially spend (deposit) 1 EUR of the 5 EUR coin
* (in full) (merchant would receive EUR:0.99 due to 1 ct
* deposit fee)
*/
- TALER_TESTING_cmd_deposit ("refresh-deposit-partial-age",
- "refresh-withdraw-coin-age-1",
- 0,
- cred.user42_payto,
- "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}",
- GNUNET_TIME_UNIT_ZERO,
- "EUR:1",
- MHD_HTTP_OK),
+ TALER_TESTING_cmd_deposit (
+ "refresh-deposit-partial-age",
+ "refresh-withdraw-coin-age-1",
+ 0,
+ cred.user42_payto,
+ "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}",
+ GNUNET_TIME_UNIT_ZERO,
+ "EUR:1",
+ MHD_HTTP_OK),
/**
* Melt the rest of the coin's value
* (EUR:4.00 = 3x EUR:1.03 + 7x EUR:0.13) */
- TALER_TESTING_cmd_melt_double ("refresh-melt-age-1",
- "refresh-withdraw-coin-age-1",
- MHD_HTTP_OK,
- NULL),
+ TALER_TESTING_cmd_melt_double (
+ "refresh-melt-age-1",
+ "refresh-withdraw-coin-age-1",
+ MHD_HTTP_OK,
+ NULL),
/**
* Complete (successful) melt operation, and
* withdraw the coins
*/
- TALER_TESTING_cmd_refresh_reveal ("refresh-reveal-age-1",
- "refresh-melt-age-1",
- MHD_HTTP_OK),
+ TALER_TESTING_cmd_refresh_reveal (
+ "refresh-reveal-age-1",
+ "refresh-melt-age-1",
+ MHD_HTTP_OK),
/**
* Do it again to check idempotency
*/
- TALER_TESTING_cmd_refresh_reveal ("refresh-reveal-age-1-idempotency",
- "refresh-melt-age-1",
- MHD_HTTP_OK),
+ TALER_TESTING_cmd_refresh_reveal (
+ "refresh-reveal-age-1-idempotency",
+ "refresh-melt-age-1",
+ MHD_HTTP_OK),
/**
* Test that /refresh/link works
*/
- TALER_TESTING_cmd_refresh_link ("refresh-link-age-1",
- "refresh-reveal-age-1",
- MHD_HTTP_OK),
+ TALER_TESTING_cmd_refresh_link (
+ "refresh-link-age-1",
+ "refresh-reveal-age-1",
+ MHD_HTTP_OK),
/**
* Try to spend a refreshed EUR:1 coin
*/
- TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-age-1a",
- "refresh-reveal-age-1-idempotency",
- 0,
- cred.user42_payto,
- "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
- GNUNET_TIME_UNIT_ZERO,
- "EUR:1",
- MHD_HTTP_OK),
+ TALER_TESTING_cmd_deposit (
+ "refresh-deposit-refreshed-age-1a",
+ "refresh-reveal-age-1-idempotency",
+ 0,
+ cred.user42_payto,
+ "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
+ GNUNET_TIME_UNIT_ZERO,
+ "EUR:1",
+ MHD_HTTP_OK),
/**
* Try to spend a refreshed EUR:0.1 coin
*/
- TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-age-1b",
- "refresh-reveal-age-1",
- 3,
- cred.user43_payto,
- "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
- GNUNET_TIME_UNIT_ZERO,
- "EUR:0.1",
- MHD_HTTP_OK),
+ TALER_TESTING_cmd_deposit (
+ "refresh-deposit-refreshed-age-1b",
+ "refresh-reveal-age-1",
+ 3,
+ cred.user43_payto,
+ "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
+ GNUNET_TIME_UNIT_ZERO,
+ "EUR:0.1",
+ MHD_HTTP_OK),
/* Test running a failing melt operation (same operation
* again must fail) */
- TALER_TESTING_cmd_melt ("refresh-melt-failing-age",
- "refresh-withdraw-coin-age-1",
- MHD_HTTP_CONFLICT,
- NULL),
+ TALER_TESTING_cmd_melt (
+ "refresh-melt-failing-age",
+ "refresh-withdraw-coin-age-1",
+ MHD_HTTP_CONFLICT,
+ NULL),
/* Test running a failing melt operation (on a coin that
was itself revealed and subsequently deposited) */
- TALER_TESTING_cmd_melt ("refresh-melt-failing-age-2",
- "refresh-reveal-age-1",
- MHD_HTTP_CONFLICT,
- NULL),
+ TALER_TESTING_cmd_melt (
+ "refresh-melt-failing-age-2",
+ "refresh-reveal-age-1",
+ MHD_HTTP_CONFLICT,
+ NULL),
TALER_TESTING_cmd_end ()
};
@@ -257,8 +274,9 @@ run (void *cls,
* Test with age-withdraw, after kyc process has set a birthdate
*/
struct TALER_TESTING_Command age_withdraw[] = {
- CMD_TRANSFER_TO_EXCHANGE ("create-reserve-kyc-1",
- "EUR:30.02"),
+ CMD_TRANSFER_TO_EXCHANGE (
+ "create-reserve-kyc-1",
+ "EUR:30.02"),
TALER_TESTING_cmd_check_bank_admin_transfer (
"check-create-reserve-kyc-1",
"EUR:30.02",
@@ -266,61 +284,90 @@ run (void *cls,
cred.exchange_payto,
"create-reserve-kyc-1"),
CMD_EXEC_WIREWATCH ("wirewatch-age-withdraw-1"),
- TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1-lacking-kyc",
- "create-reserve-kyc-1",
- "EUR:10",
- 0, /* age restriction off */
- MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS),
- TALER_TESTING_cmd_check_kyc_get ("check-kyc-withdraw",
- "withdraw-coin-1-lacking-kyc",
- MHD_HTTP_ACCEPTED),
- TALER_TESTING_cmd_proof_kyc_oauth2 ("proof-kyc",
- "withdraw-coin-1-lacking-kyc",
- "kyc-provider-test-oauth2",
- "pass",
- MHD_HTTP_SEE_OTHER),
- TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1-with-kyc",
- "create-reserve-kyc-1",
- "EUR:10",
- 0, /* age restriction off */
- MHD_HTTP_CONFLICT),
- TALER_TESTING_cmd_age_withdraw ("age-withdraw-coin-1-too-low",
- "create-reserve-kyc-1",
- 18, /* Too high */
- MHD_HTTP_CONFLICT,
- "EUR:10",
- NULL),
- TALER_TESTING_cmd_age_withdraw ("age-withdraw-coins-1",
- "create-reserve-kyc-1",
- 8,
- MHD_HTTP_OK,
- "EUR:10",
- "EUR:10",
- "EUR:5",
- NULL),
- TALER_TESTING_cmd_age_withdraw_reveal ("age-withdraw-coins-reveal-1",
- "age-withdraw-coins-1",
- MHD_HTTP_OK),
+ TALER_TESTING_cmd_withdraw_amount (
+ "withdraw-coin-1-lacking-kyc",
+ "create-reserve-kyc-1",
+ "EUR:10",
+ 0, /* age restriction off */
+ MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS),
+ TALER_TESTING_cmd_admin_add_kycauth (
+ "setup-account-key",
+ "EUR:0.01",
+ &cred.ba,
+ cred.user42_payto,
+ NULL /* create new key */),
+ CMD_EXEC_WIREWATCH (
+ "import-kyc-account"),
+ TALER_TESTING_cmd_check_kyc_get (
+ "check-kyc-withdraw",
+ "withdraw-coin-1-lacking-kyc",
+ "setup-account-key",
+ MHD_HTTP_ACCEPTED),
+ TALER_TESTING_cmd_get_kyc_info (
+ "get-kyc-info",
+ "check-kyc-withdraw",
+ MHD_HTTP_OK),
+ TALER_TESTING_cmd_post_kyc_start (
+ "start-kyc-process",
+ "get-kyc-info",
+ 0,
+ MHD_HTTP_OK),
+ TALER_TESTING_cmd_proof_kyc_oauth2 (
+ "proof-kyc",
+ "withdraw-coin-1-lacking-kyc",
+ "kyc-provider-test-oauth2",
+ "pass",
+ MHD_HTTP_SEE_OTHER),
+ TALER_TESTING_cmd_withdraw_amount (
+ "withdraw-coin-1-with-kyc",
+ "create-reserve-kyc-1",
+ "EUR:10",
+ 0, /* age restriction off */
+ MHD_HTTP_CONFLICT),
+ TALER_TESTING_cmd_age_withdraw (
+ "age-withdraw-coin-1-too-low",
+ "create-reserve-kyc-1",
+ 18, /* Too high */
+ MHD_HTTP_CONFLICT,
+ "EUR:10",
+ NULL),
+ TALER_TESTING_cmd_age_withdraw (
+ "age-withdraw-coins-1",
+ "create-reserve-kyc-1",
+ 8,
+ MHD_HTTP_OK,
+ "EUR:10",
+ "EUR:10",
+ "EUR:5",
+ NULL),
+ TALER_TESTING_cmd_age_withdraw_reveal (
+ "age-withdraw-coins-reveal-1",
+ "age-withdraw-coins-1",
+ MHD_HTTP_OK),
TALER_TESTING_cmd_end (),
};
{
struct TALER_TESTING_Command commands[] = {
- TALER_TESTING_cmd_run_fakebank ("run-fakebank",
- cred.cfg,
- "exchange-account-2"),
- TALER_TESTING_cmd_system_start ("start-taler",
- config_file,
- "-e",
- NULL),
- TALER_TESTING_cmd_get_exchange ("get-exchange",
- cred.cfg,
- NULL,
- true,
- true),
- TALER_TESTING_cmd_oauth_with_birthdate ("oauth-service-with-birthdate",
- "2015-00-00", /* enough for a while */
- 6666),
+ TALER_TESTING_cmd_run_fakebank (
+ "run-fakebank",
+ cred.cfg,
+ "exchange-account-2"),
+ TALER_TESTING_cmd_system_start (
+ "start-taler",
+ config_file,
+ "-e",
+ NULL),
+ TALER_TESTING_cmd_get_exchange (
+ "get-exchange",
+ cred.cfg,
+ NULL,
+ true,
+ true),
+ TALER_TESTING_cmd_oauth_with_birthdate (
+ "oauth-service-with-birthdate",
+ "2015-00-00", /* enough for a while */
+ 6666),
TALER_TESTING_cmd_batch ("withdraw-age",
withdraw_age),
TALER_TESTING_cmd_batch ("spend-age",
@@ -351,19 +398,21 @@ main (int argc,
GNUNET_assert (NULL != cipher);
uses_cs = (0 == strcmp (cipher,
"cs"));
- GNUNET_asprintf (&config_file,
- "test_exchange_api_age_restriction-%s.conf",
- cipher);
+ GNUNET_asprintf (
+ &config_file,
+ "test_exchange_api_age_restriction-%s.conf",
+ cipher);
GNUNET_free (cipher);
}
- return TALER_TESTING_main (argv,
- "INFO",
- config_file,
- "exchange-account-2",
- TALER_TESTING_BS_FAKEBANK,
- &cred,
- &run,
- NULL);
+ return TALER_TESTING_main (
+ argv,
+ "INFO",
+ config_file,
+ "exchange-account-2",
+ TALER_TESTING_BS_FAKEBANK,
+ &cred,
+ &run,
+ NULL);
}