test_kyc_api.c (24572B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2014-2024 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as 7 published by the Free Software Foundation; either version 3, or 8 (at your option) any later version. 9 10 TALER is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public 16 License along with TALER; see the file COPYING. If not, see 17 <http://www.gnu.org/licenses/> 18 */ 19 /** 20 * @file testing/test_kyc_api.c 21 * @brief testcase to test the KYC processes 22 * @author Christian Grothoff 23 */ 24 #include "taler/taler_util.h" 25 #include "taler/taler_attributes.h" 26 #include "taler/taler_json_lib.h" 27 #include <gnunet/gnunet_util_lib.h> 28 #include <microhttpd.h> 29 #include "taler/taler_bank_service.h" 30 #include "taler/taler_testing_lib.h" 31 32 33 /** 34 * Configuration file we use. One (big) configuration is used 35 * for the various components for this test. 36 */ 37 #define CONFIG_FILE "test_kyc_api.conf" 38 39 /** 40 * Our credentials. 41 */ 42 struct TALER_TESTING_Credentials cred; 43 44 45 /** 46 * Execute the taler-exchange-wirewatch command with 47 * our configuration file. 48 * 49 * @param label label to use for the command. 50 */ 51 #define CMD_EXEC_WIREWATCH(label) \ 52 TALER_TESTING_cmd_exec_wirewatch2 ( \ 53 label, \ 54 CONFIG_FILE, \ 55 "exchange-account-2") 56 57 /** 58 * Execute the taler-exchange-aggregator, closer and transfer commands with 59 * our configuration file. 60 * 61 * @param label label to use for the command. 62 */ 63 #define CMD_EXEC_AGGREGATOR(label) \ 64 TALER_TESTING_cmd_sleep ( \ 65 label "-sleep", 1), \ 66 TALER_TESTING_cmd_exec_aggregator_with_kyc ( \ 67 label, CONFIG_FILE), \ 68 TALER_TESTING_cmd_exec_transfer ( \ 69 label, CONFIG_FILE) 70 71 /** 72 * Run wire transfer of funds from some user's account to the 73 * exchange. 74 * 75 * @param label label to use for the command. 76 * @param amount amount to transfer, i.e. "EUR:1" 77 */ 78 #define CMD_TRANSFER_TO_EXCHANGE(label,amount) \ 79 TALER_TESTING_cmd_admin_add_incoming ( \ 80 label, \ 81 amount, \ 82 &cred.ba, \ 83 cred.user42_payto) 84 85 /** 86 * Main function that will tell the interpreter what commands to 87 * run. 88 * 89 * @param cls closure 90 */ 91 static void 92 run (void *cls, 93 struct TALER_TESTING_Interpreter *is) 94 { 95 struct TALER_TESTING_Command withdraw[] = { 96 CMD_TRANSFER_TO_EXCHANGE ( 97 "create-reserve-1", 98 "EUR:15.02"), 99 TALER_TESTING_cmd_check_bank_admin_transfer ( 100 "check-create-reserve-1", 101 "EUR:15.02", 102 cred.user42_payto, 103 cred.exchange_payto, 104 "create-reserve-1"), 105 CMD_EXEC_WIREWATCH ("wirewatch-1"), 106 TALER_TESTING_cmd_withdraw_amount ( 107 "withdraw-coin-1-no-kyc", 108 "create-reserve-1", 109 "EUR:10", 110 0, /* age restriction off */ 111 MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS), 112 TALER_TESTING_cmd_withdraw_amount ( 113 "withdraw-coin-1", 114 "create-reserve-1", 115 "EUR:5", 116 0, /* age restriction off */ 117 MHD_HTTP_OK), 118 TALER_TESTING_cmd_end () 119 }; 120 121 /** 122 * Test withdraw with KYC. 123 */ 124 struct TALER_TESTING_Command withdraw_kyc[] = { 125 CMD_TRANSFER_TO_EXCHANGE ( 126 "create-reserve-kyc", 127 "EUR:15.02"), 128 TALER_TESTING_cmd_check_bank_admin_transfer ( 129 "check-create-reserve-kyc", 130 "EUR:15.02", 131 cred.user42_payto, 132 cred.exchange_payto, 133 "create-reserve-kyc"), 134 CMD_EXEC_WIREWATCH ("wirewatch-kyc"), 135 TALER_TESTING_cmd_withdraw_amount ( 136 "withdraw-coin-1-lacking-kyc", 137 "create-reserve-kyc", 138 "EUR:10", 139 0, /* age restriction off */ 140 MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS), 141 TALER_TESTING_cmd_admin_add_kycauth ( 142 "setup-account-key-withdraw", 143 "EUR:0.01", 144 &cred.ba, 145 cred.user42_payto, 146 NULL /* create new key */), 147 CMD_EXEC_WIREWATCH ( 148 "import-kyc-account-withdraw"), 149 TALER_TESTING_cmd_check_kyc_get ( 150 "check-kyc-withdraw", 151 "withdraw-coin-1-lacking-kyc", 152 "setup-account-key-withdraw", 153 TALER_EXCHANGE_KLPT_KYC_AUTH_TRANSFER, 154 MHD_HTTP_ACCEPTED), 155 TALER_TESTING_cmd_get_kyc_info ( 156 "get-kyc-info-withdraw", 157 "check-kyc-withdraw", 158 MHD_HTTP_OK), 159 TALER_TESTING_cmd_post_kyc_start ( 160 "start-kyc-process-withdraw", 161 "get-kyc-info-withdraw", 162 0, 163 MHD_HTTP_OK), 164 TALER_TESTING_cmd_proof_kyc_oauth2 ( 165 "proof-kyc-withdraw-oauth2", 166 "withdraw-coin-1-lacking-kyc", 167 "test-oauth2", 168 "pass", 169 MHD_HTTP_SEE_OTHER), 170 TALER_TESTING_cmd_withdraw_with_age_proof ( 171 "age-withdraw-coin-1-with-kyc", 172 "create-reserve-kyc", 173 1, 174 MHD_HTTP_CREATED, 175 "EUR:5", 176 NULL), 177 TALER_TESTING_cmd_withdraw_reveal_age_proof ( 178 "reveal-age-withdraw-coin-1-with-kyc", 179 "age-withdraw-coin-1-with-kyc", 180 MHD_HTTP_OK), 181 /* Attestations above are bound to the originating *bank* account, 182 not to the reserve (!). Hence, they are NOT found here! */ 183 TALER_TESTING_cmd_reserve_get_attestable ( 184 "reserve-get-attestable", 185 "create-reserve-kyc", 186 MHD_HTTP_NOT_FOUND, 187 NULL), 188 TALER_TESTING_cmd_end () 189 }; 190 struct TALER_TESTING_Command spend[] = { 191 TALER_TESTING_cmd_set_var ( 192 "account-priv", 193 TALER_TESTING_cmd_deposit ( 194 "deposit-simple-fail-kyc", 195 "withdraw-coin-1", 196 0, 197 cred.user43_payto, 198 "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", 199 GNUNET_TIME_UNIT_ZERO, 200 "EUR:5", 201 MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS)), 202 TALER_TESTING_cmd_admin_add_kycauth ( 203 "kyc-auth-transfer", 204 "EUR:0.01", 205 &cred.ba, 206 cred.user42_payto, 207 "deposit-simple-fail-kyc"), 208 TALER_TESTING_cmd_admin_add_kycauth ( 209 "kyc-auth-transfer", 210 "EUR:0.01", 211 &cred.ba, 212 cred.user43_payto, 213 "deposit-simple-fail-kyc"), 214 CMD_EXEC_WIREWATCH ( 215 "import-kyc-account"), 216 TALER_TESTING_cmd_deposit ( 217 "deposit-simple", 218 "withdraw-coin-1", 219 0, 220 cred.user43_payto, 221 "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", 222 GNUNET_TIME_UNIT_ZERO, 223 "EUR:5", 224 MHD_HTTP_OK), 225 TALER_TESTING_cmd_deposits_get ( 226 "track-deposit", 227 "deposit-simple", 228 0, 229 MHD_HTTP_ACCEPTED, 230 NULL), 231 TALER_TESTING_cmd_end () 232 }; 233 234 235 struct TALER_TESTING_Command track[] = { 236 CMD_EXEC_AGGREGATOR ("run-aggregator-before-kyc"), 237 TALER_TESTING_cmd_check_bank_empty ( 238 "check_bank_empty-no-kyc"), 239 TALER_TESTING_cmd_deposits_get ( 240 "track-deposit-kyc-ready", 241 "deposit-simple", 242 0, 243 MHD_HTTP_ACCEPTED, 244 NULL), 245 TALER_TESTING_cmd_admin_add_kycauth ( 246 "setup-account-key-deposit", 247 "EUR:0.01", 248 &cred.ba, 249 cred.user43_payto, 250 NULL /* create new key */), 251 CMD_EXEC_WIREWATCH ( 252 "import-kyc-account-deposit"), 253 TALER_TESTING_cmd_check_kyc_get ( 254 "check-kyc-deposit", 255 "track-deposit-kyc-ready", 256 "setup-account-key-deposit", 257 TALER_EXCHANGE_KLPT_KYC_AUTH_TRANSFER, 258 MHD_HTTP_ACCEPTED), 259 TALER_TESTING_cmd_get_kyc_info ( 260 "get-kyc-info-deposit", 261 "check-kyc-deposit", 262 MHD_HTTP_OK), 263 TALER_TESTING_cmd_post_kyc_start ( 264 "start-kyc-process-deposit", 265 "get-kyc-info-deposit", 266 0, 267 MHD_HTTP_OK), 268 TALER_TESTING_cmd_proof_kyc_oauth2 ( 269 "proof-kyc-no-service", 270 "track-deposit-kyc-ready", 271 "test-oauth2", 272 "bad", 273 MHD_HTTP_BAD_GATEWAY), 274 TALER_TESTING_cmd_oauth_with_birthdate ( 275 "start-oauth-service", 276 "2005-00-00", 277 6666), 278 TALER_TESTING_cmd_proof_kyc_oauth2 ( 279 "proof-kyc-fail", 280 "track-deposit-kyc-ready", 281 "test-oauth2", 282 "bad", 283 MHD_HTTP_FORBIDDEN), 284 TALER_TESTING_cmd_check_kyc_get ( 285 "check-kyc-deposit-again", 286 "track-deposit-kyc-ready", 287 "setup-account-key-deposit", 288 TALER_EXCHANGE_KLPT_KYC_AUTH_TRANSFER, 289 MHD_HTTP_ACCEPTED), 290 TALER_TESTING_cmd_get_kyc_info ( 291 "get-kyc-info-deposit-again", 292 "check-kyc-deposit-again", 293 MHD_HTTP_OK), 294 TALER_TESTING_cmd_post_kyc_start ( 295 "start-kyc-process-deposit-again", 296 "get-kyc-info-deposit-again", 297 0, 298 MHD_HTTP_OK), 299 TALER_TESTING_cmd_proof_kyc_oauth2 ( 300 "proof-kyc-pass", 301 "track-deposit-kyc-ready", 302 "test-oauth2", 303 "pass", 304 MHD_HTTP_SEE_OTHER), 305 CMD_EXEC_AGGREGATOR ( 306 "run-aggregator-after-kyc"), 307 TALER_TESTING_cmd_check_bank_transfer ( 308 "check_bank_transfer-499c", 309 cred.exchange_url, 310 "EUR:4.98", 311 cred.exchange_payto, 312 cred.user43_payto), 313 TALER_TESTING_cmd_check_bank_empty ( 314 "check_bank_empty"), 315 TALER_TESTING_cmd_end () 316 }; 317 318 struct TALER_TESTING_Command wallet_kyc[] = { 319 TALER_TESTING_cmd_wallet_kyc_get ( 320 "wallet-kyc-fail", 321 NULL, 322 "EUR:1000000", 323 MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS), 324 TALER_TESTING_cmd_check_kyc_get ( 325 "check-kyc-wallet", 326 "wallet-kyc-fail", 327 "wallet-kyc-fail", 328 TALER_EXCHANGE_KLPT_KYC_AUTH_TRANSFER, 329 MHD_HTTP_ACCEPTED), 330 TALER_TESTING_cmd_get_kyc_info ( 331 "get-kyc-info-kyc-wallet", 332 "check-kyc-wallet", 333 MHD_HTTP_OK), 334 TALER_TESTING_cmd_post_kyc_start ( 335 "start-kyc-wallet", 336 "get-kyc-info-kyc-wallet", 337 0, 338 MHD_HTTP_OK), 339 TALER_TESTING_cmd_proof_kyc_oauth2 ( 340 "proof-wallet-kyc", 341 "wallet-kyc-fail", 342 "test-oauth2", 343 "pass", 344 MHD_HTTP_SEE_OTHER), 345 TALER_TESTING_cmd_check_kyc_get ( 346 "wallet-kyc-check", 347 "wallet-kyc-fail", 348 "wallet-kyc-fail", 349 TALER_EXCHANGE_KLPT_KYC_AUTH_TRANSFER, 350 MHD_HTTP_OK), 351 TALER_TESTING_cmd_reserve_get_attestable ( 352 "wallet-get-attestable", 353 "wallet-kyc-fail", 354 MHD_HTTP_OK, 355 TALER_ATTRIBUTE_FULL_NAME, 356 NULL), 357 TALER_TESTING_cmd_reserve_attest ( 358 "wallet-get-attest", 359 "wallet-kyc-fail", 360 MHD_HTTP_OK, 361 TALER_ATTRIBUTE_FULL_NAME, 362 NULL), 363 TALER_TESTING_cmd_end () 364 }; 365 366 /** 367 * Test withdrawal for P2P 368 */ 369 struct TALER_TESTING_Command p2p_withdraw[] = { 370 /** 371 * Move money to the exchange's bank account. 372 */ 373 CMD_TRANSFER_TO_EXCHANGE ( 374 "p2p_create-reserve-1", 375 "EUR:5.04"), 376 CMD_TRANSFER_TO_EXCHANGE ( 377 "p2p_create-reserve-2", 378 "EUR:5.01"), 379 CMD_TRANSFER_TO_EXCHANGE ( 380 "p2p_create-reserve-3", 381 "EUR:0.03"), 382 TALER_TESTING_cmd_reserve_poll ( 383 "p2p_poll-reserve-1", 384 "p2p_create-reserve-1", 385 "EUR:5.04", 386 GNUNET_TIME_UNIT_MINUTES, 387 MHD_HTTP_OK), 388 TALER_TESTING_cmd_check_bank_admin_transfer ( 389 "p2p_check-create-reserve-1", 390 "EUR:5.04", 391 cred.user42_payto, 392 cred.exchange_payto, 393 "p2p_create-reserve-1"), 394 TALER_TESTING_cmd_check_bank_admin_transfer ( 395 "p2p_check-create-reserve-2", 396 "EUR:5.01", 397 cred.user42_payto, 398 cred.exchange_payto, 399 "p2p_create-reserve-2"), 400 /** 401 * Make a reserve exist, according to the previous 402 * transfer. 403 */ 404 CMD_EXEC_WIREWATCH ("p2p_wirewatch-1"), 405 TALER_TESTING_cmd_reserve_poll_finish ( 406 "p2p_finish-poll-reserve-1", 407 GNUNET_TIME_UNIT_SECONDS, 408 "p2p_poll-reserve-1"), 409 /** 410 * Withdraw EUR:5. 411 */ 412 TALER_TESTING_cmd_withdraw_amount ( 413 "p2p_withdraw-coin-1", 414 "p2p_create-reserve-1", 415 "EUR:5", 416 0, /* age restriction off */ 417 MHD_HTTP_OK), 418 /** 419 * Check the reserve is depleted. 420 */ 421 TALER_TESTING_cmd_status ( 422 "p2p_status-1", 423 "p2p_create-reserve-1", 424 "EUR:0.03", 425 MHD_HTTP_OK), 426 TALER_TESTING_cmd_end () 427 }; 428 struct TALER_TESTING_Command push[] = { 429 TALER_TESTING_cmd_purse_create_with_deposit ( 430 "purse-with-deposit", 431 MHD_HTTP_OK, 432 "{\"amount\":\"EUR:1\",\"summary\":\"ice cream\"}", 433 true, /* upload contract */ 434 GNUNET_TIME_UNIT_MINUTES, /* expiration */ 435 "p2p_withdraw-coin-1", 436 "EUR:1.01", 437 NULL), 438 TALER_TESTING_cmd_coin_history ( 439 "coin-history-purse-with-deposit", 440 "p2p_withdraw-coin-1#0", 441 "EUR:3.99", 442 MHD_HTTP_OK), 443 TALER_TESTING_cmd_purse_poll ( 444 "push-poll-purse-before-merge", 445 MHD_HTTP_OK, 446 "purse-with-deposit", 447 "EUR:1", 448 true, 449 GNUNET_TIME_UNIT_MINUTES), 450 TALER_TESTING_cmd_contract_get ( 451 "push-get-contract", 452 MHD_HTTP_OK, 453 true, /* for merge */ 454 "purse-with-deposit"), 455 TALER_TESTING_cmd_purse_merge ( 456 "purse-merge-into-reserve", 457 MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS, 458 "push-get-contract", 459 "p2p_create-reserve-1"), 460 TALER_TESTING_cmd_check_kyc_get ( 461 "check-kyc-purse-merge", 462 "purse-merge-into-reserve", 463 "p2p_create-reserve-1", 464 TALER_EXCHANGE_KLPT_KYC_AUTH_TRANSFER, 465 MHD_HTTP_ACCEPTED), 466 TALER_TESTING_cmd_get_kyc_info ( 467 "get-kyc-info-purse-merge-into-reserve", 468 "check-kyc-purse-merge", 469 MHD_HTTP_OK), 470 TALER_TESTING_cmd_post_kyc_start ( 471 "start-kyc-process-purse-merge-into-reserve", 472 "get-kyc-info-purse-merge-into-reserve", 473 0, 474 MHD_HTTP_OK), 475 TALER_TESTING_cmd_proof_kyc_oauth2 ( 476 "p2p_proof-kyc", 477 "purse-merge-into-reserve", 478 "test-oauth2", 479 "pass", 480 MHD_HTTP_SEE_OTHER), 481 TALER_TESTING_cmd_purse_merge ( 482 "purse-merge-into-reserve", 483 MHD_HTTP_OK, 484 "push-get-contract", 485 "p2p_create-reserve-1"), 486 TALER_TESTING_cmd_purse_poll_finish ( 487 "push-merge-purse-poll-finish", 488 GNUNET_TIME_relative_multiply ( 489 GNUNET_TIME_UNIT_SECONDS, 490 5), 491 "push-poll-purse-before-merge"), 492 TALER_TESTING_cmd_status ( 493 "push-check-post-merge-reserve-balance-get", 494 "p2p_create-reserve-1", 495 "EUR:1.03", 496 MHD_HTTP_OK), 497 TALER_TESTING_cmd_reserve_history ( 498 "push-check-post-merge-reserve-balance-post", 499 "p2p_create-reserve-1", 500 "EUR:1.03", 501 MHD_HTTP_OK), 502 503 TALER_TESTING_cmd_end () 504 }; 505 struct TALER_TESTING_Command pull[] = { 506 TALER_TESTING_cmd_purse_create_with_reserve ( 507 "purse-create-with-reserve", 508 MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS, 509 "{\"amount\":\"EUR:1\",\"summary\":\"ice cream\"}", 510 true /* upload contract */, 511 true /* pay purse fee */, 512 GNUNET_TIME_UNIT_MINUTES, /* expiration */ 513 "p2p_create-reserve-3"), 514 TALER_TESTING_cmd_check_kyc_get ( 515 "check-kyc-purse-create", 516 "purse-create-with-reserve", 517 "purse-create-with-reserve", 518 TALER_EXCHANGE_KLPT_KYC_AUTH_TRANSFER, 519 MHD_HTTP_ACCEPTED), 520 TALER_TESTING_cmd_get_kyc_info ( 521 "get-kyc-info-purse-create", 522 "check-kyc-purse-create", 523 MHD_HTTP_OK), 524 TALER_TESTING_cmd_post_kyc_start ( 525 "start-kyc-process-purse-create", 526 "get-kyc-info-purse-create", 527 0, 528 MHD_HTTP_OK), 529 TALER_TESTING_cmd_proof_kyc_oauth2 ( 530 "p2p_proof-kyc-pull", 531 "purse-create-with-reserve", 532 "test-oauth2", 533 "pass", 534 MHD_HTTP_SEE_OTHER), 535 TALER_TESTING_cmd_purse_create_with_reserve ( 536 "purse-create-with-reserve", 537 MHD_HTTP_OK, 538 "{\"amount\":\"EUR:1\",\"summary\":\"ice cream\"}", 539 true /* upload contract */, 540 true /* pay purse fee */, 541 GNUNET_TIME_UNIT_MINUTES, /* expiration */ 542 "p2p_create-reserve-3"), 543 TALER_TESTING_cmd_contract_get ( 544 "pull-get-contract", 545 MHD_HTTP_OK, 546 false, /* for deposit */ 547 "purse-create-with-reserve"), 548 TALER_TESTING_cmd_purse_poll ( 549 "pull-poll-purse-before-deposit", 550 MHD_HTTP_OK, 551 "purse-create-with-reserve", 552 "EUR:1", 553 false, 554 GNUNET_TIME_UNIT_MINUTES), 555 TALER_TESTING_cmd_purse_deposit_coins ( 556 "purse-deposit-coins", 557 MHD_HTTP_OK, 558 0 /* min age */, 559 "purse-create-with-reserve", 560 "p2p_withdraw-coin-1", 561 "EUR:1.01", 562 NULL), 563 TALER_TESTING_cmd_coin_history ( 564 "coin-history-purse-pull-deposit", 565 "p2p_withdraw-coin-1#0", 566 "EUR:2.98", 567 MHD_HTTP_OK), 568 TALER_TESTING_cmd_purse_poll_finish ( 569 "pull-deposit-purse-poll-finish", 570 GNUNET_TIME_relative_multiply ( 571 GNUNET_TIME_UNIT_SECONDS, 572 5), 573 "pull-poll-purse-before-deposit"), 574 TALER_TESTING_cmd_status ( 575 "pull-check-post-merge-reserve-balance-get-2", 576 "p2p_create-reserve-3", 577 "EUR:1.03", 578 MHD_HTTP_OK), 579 TALER_TESTING_cmd_reserve_history ( 580 "push-check-post-merge-reserve-balance-post-2", 581 "p2p_create-reserve-3", 582 "EUR:1.03", 583 MHD_HTTP_OK), 584 TALER_TESTING_cmd_end () 585 }; 586 struct TALER_TESTING_Command aml[] = { 587 TALER_TESTING_cmd_set_officer ( 588 "create-aml-officer-1", 589 NULL, 590 "Peter Falk", 591 true, 592 true), 593 TALER_TESTING_cmd_check_aml_decisions ( 594 "check-decisions-none-normal", 595 "create-aml-officer-1", 596 NULL, 597 MHD_HTTP_OK), 598 /* Trigger something upon which an AML officer could act */ 599 TALER_TESTING_cmd_wallet_kyc_get ( 600 "wallet-trigger-kyc-for-aml", 601 NULL, 602 "EUR:1000", 603 MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS), 604 TALER_TESTING_cmd_get_active_legitimization_measures ( 605 "check-decisions-wallet-pending", 606 "create-aml-officer-1", 607 "wallet-trigger-kyc-for-aml", 608 MHD_HTTP_OK, 609 "{\"measures\": [{\"check_name\": \"oauth-test-id\", \"prog_name\": \"oauth-output-check\", \"context\": {}}], \"is_and_combinator\": true, \"verboten\": false}"), 610 /* Test that we are not allowed to take AML decisions as our 611 AML staff account is on read-only */ 612 TALER_TESTING_cmd_take_aml_decision ( 613 "aml-decide-while-disabled", 614 "create-aml-officer-1", 615 "wallet-trigger-kyc-for-aml", 616 true /* keep investigating */, 617 GNUNET_TIME_UNIT_HOURS /* expiration */, 618 NULL /* successor measure: default */, 619 "{\"rules\":[" 620 "{\"timeframe\":{\"d_us\":3600000000}," 621 " \"threshold\":\"EUR:10000\"," 622 " \"operation_type\":\"BALANCE\"," 623 " \"verboten\":true" 624 "}" 625 "]}" /* new rules */, 626 "{}" /* properties */, 627 "party time", 628 MHD_HTTP_CONFLICT), 629 /* Check that no decision was taken, but that we are allowed 630 to read this information */ 631 TALER_TESTING_cmd_check_aml_decisions ( 632 "check-aml-decision-empty", 633 "create-aml-officer-1", 634 "aml-decide-while-disabled", 635 MHD_HTTP_NO_CONTENT), 636 TALER_TESTING_cmd_sleep ( 637 "sleep-1b", 638 1), 639 TALER_TESTING_cmd_set_officer ( 640 "create-aml-officer-1-enable", 641 "create-aml-officer-1", 642 "Peter Falk", 643 true, 644 false), 645 TALER_TESTING_cmd_take_aml_decision ( 646 "aml-decide", 647 "create-aml-officer-1", 648 "wallet-trigger-kyc-for-aml", 649 true /* keep investigating */, 650 GNUNET_TIME_UNIT_HOURS /* expiration */, 651 NULL /* successor measure: default */, 652 "{\"rules\":[" 653 "{\"timeframe\":{\"d_us\":3600000000}," 654 " \"threshold\":\"EUR:10000\"," 655 " \"operation_type\":\"BALANCE\"," 656 " \"verboten\":true" 657 "}" 658 "]}" /* new rules */, 659 "{}" /* properties */, 660 "party time", 661 MHD_HTTP_NO_CONTENT), 662 TALER_TESTING_cmd_check_aml_decisions ( 663 "check-decisions-one-normal", 664 "create-aml-officer-1", 665 "aml-decide", 666 MHD_HTTP_OK), 667 TALER_TESTING_cmd_wallet_kyc_get ( 668 "wallet-trigger-kyc-for-aml-allowed", 669 "wallet-trigger-kyc-for-aml", 670 "EUR:1000", 671 MHD_HTTP_OK), 672 TALER_TESTING_cmd_wallet_kyc_get ( 673 "wallet-trigger-kyc-for-aml-denied-high", 674 "wallet-trigger-kyc-for-aml", 675 "EUR:20000", 676 MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS), 677 TALER_TESTING_cmd_sleep ( 678 "sleep-1d", 679 1), 680 TALER_TESTING_cmd_set_officer ( 681 "create-aml-officer-1-disable", 682 "create-aml-officer-1", 683 "Peter Falk", 684 false, 685 true), 686 /* Test that we are NOT allowed to read AML decisions now that 687 our AML staff account is disabled */ 688 TALER_TESTING_cmd_check_aml_decisions ( 689 "check-aml-decision-disabled", 690 "create-aml-officer-1", 691 "aml-decide", 692 MHD_HTTP_FORBIDDEN), 693 TALER_TESTING_cmd_end () 694 }; 695 696 struct TALER_TESTING_Command aml_form[] = { 697 TALER_TESTING_cmd_set_officer ( 698 "create-aml-form-officer-1", 699 NULL, 700 "Peter Falk", 701 true, 702 false), 703 /* Trigger something upon which an AML officer could act */ 704 TALER_TESTING_cmd_wallet_kyc_get ( 705 "wallet-trigger-kyc-for-form-aml", 706 NULL, 707 "EUR:1000", 708 MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS), 709 TALER_TESTING_cmd_wallet_kyc_get ( 710 "wallet-trigger-kyc-for-form-aml-disallowed", 711 "wallet-trigger-kyc-for-form-aml", 712 "EUR:500", 713 MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS), 714 /* AML officer switches from Oauth2 to form */ 715 TALER_TESTING_cmd_take_aml_decision ( 716 "aml-decide-form", 717 "create-aml-form-officer-1", 718 "wallet-trigger-kyc-for-form-aml", 719 false /* just awaiting KYC, no investigation */, 720 GNUNET_TIME_UNIT_HOURS /* expiration */, 721 NULL /* successor measure: default */, 722 "{\"rules\":" 723 " [" 724 " {" 725 " \"timeframe\":{\"d_us\":3600000000}" 726 " ,\"threshold\":\"EUR:0\"" 727 " ,\"operation_type\":\"BALANCE\"" 728 " ,\"display_priority\":65536" 729 " ,\"measures\":[\"form-measure\"]" 730 " ,\"verboten\":false" 731 " }" 732 " ]" /* end new rules */ 733 ",\"new_measures\":\"form-measure\"" 734 ",\"custom_measures\":" 735 " {" 736 " \"form-measure\":" 737 " {" 738 " \"check_name\":\"test-form\"" 739 " ,\"prog_name\":\"test-form-check\"" 740 " }" 741 " }" /* end custom measures */ 742 "}", 743 "{}" /* properties */, 744 "form time", 745 MHD_HTTP_NO_CONTENT), 746 /* Wallet learns about form submission */ 747 TALER_TESTING_cmd_check_kyc_get ( 748 "check-kyc-form", 749 "wallet-trigger-kyc-for-form-aml", 750 "wallet-trigger-kyc-for-form-aml", 751 TALER_EXCHANGE_KLPT_KYC_AUTH_TRANSFER, 752 MHD_HTTP_ACCEPTED), 753 TALER_TESTING_cmd_get_kyc_info ( 754 "get-kyc-info-form", 755 "check-kyc-form", 756 MHD_HTTP_OK), 757 TALER_TESTING_cmd_post_kyc_form ( 758 "wallet-post-kyc-form", 759 "get-kyc-info-form", 760 0, /* requirement index */ 761 "application/json", 762 "{\"FORM_ID\":\"test\",\"FULL_NAME\":\"Bob\",\"DATE_OF_BIRTH\":\"1990-00-00\"}", 763 MHD_HTTP_NO_CONTENT), 764 /* now this should be allowed */ 765 TALER_TESTING_cmd_wallet_kyc_get ( 766 "wallet-trigger-kyc-for-form-aml-allowed", 767 "wallet-trigger-kyc-for-form-aml", 768 "EUR:500", 769 MHD_HTTP_OK), 770 TALER_TESTING_cmd_end () 771 }; 772 773 774 struct TALER_TESTING_Command commands[] = { 775 TALER_TESTING_cmd_run_fakebank ( 776 "run-fakebank", 777 cred.cfg, 778 "exchange-account-2"), 779 TALER_TESTING_cmd_system_start ( 780 "start-taler", 781 CONFIG_FILE, 782 "-e", 783 NULL), 784 TALER_TESTING_cmd_get_exchange ( 785 "get-exchange", 786 cred.cfg, 787 NULL, 788 true, 789 true), 790 TALER_TESTING_cmd_batch ( 791 "withdraw", 792 withdraw), 793 TALER_TESTING_cmd_batch ( 794 "spend", 795 spend), 796 TALER_TESTING_cmd_batch ( 797 "track", 798 track), 799 TALER_TESTING_cmd_batch ( 800 "withdraw-kyc", 801 withdraw_kyc), 802 TALER_TESTING_cmd_batch ( 803 "wallet-kyc", 804 wallet_kyc), 805 TALER_TESTING_cmd_batch ( 806 "p2p_withdraw", 807 p2p_withdraw), 808 TALER_TESTING_cmd_batch ( 809 "push", 810 push), 811 TALER_TESTING_cmd_batch ( 812 "pull", 813 pull), 814 TALER_TESTING_cmd_batch ("aml", 815 aml), 816 TALER_TESTING_cmd_batch ("aml-form", 817 aml_form), 818 TALER_TESTING_cmd_end () 819 }; 820 821 (void) cls; 822 TALER_TESTING_run (is, 823 commands); 824 } 825 826 827 int 828 main (int argc, 829 char *const *argv) 830 { 831 (void) argc; 832 return TALER_TESTING_main ( 833 argv, 834 "INFO", 835 CONFIG_FILE, 836 "exchange-account-2", 837 TALER_TESTING_BS_FAKEBANK, 838 &cred, 839 &run, 840 NULL); 841 } 842 843 844 /* end of test_kyc_api.c */