test_kyc_api.c (25337B)
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_get_aml_officer ( 594 "get-read-only-aml-officer", 595 "create-aml-officer-1", 596 MHD_HTTP_OK, 597 "Peter Falk", 598 true), 599 TALER_TESTING_cmd_check_aml_decisions ( 600 "check-decisions-none-normal", 601 "create-aml-officer-1", 602 NULL, 603 MHD_HTTP_OK), 604 /* Trigger something upon which an AML officer could act */ 605 TALER_TESTING_cmd_wallet_kyc_get ( 606 "wallet-trigger-kyc-for-aml", 607 NULL, 608 "EUR:1000", 609 MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS), 610 TALER_TESTING_cmd_get_active_legitimization_measures ( 611 "check-decisions-wallet-pending", 612 "create-aml-officer-1", 613 "wallet-trigger-kyc-for-aml", 614 MHD_HTTP_OK, 615 "{\"measures\": [{\"check_name\": \"oauth-test-id\", \"prog_name\": \"oauth-output-check\", \"context\": {}}], \"is_and_combinator\": true, \"verboten\": false}"), 616 /* Test that we are not allowed to take AML decisions as our 617 AML staff account is on read-only */ 618 TALER_TESTING_cmd_take_aml_decision ( 619 "aml-decide-while-disabled", 620 "create-aml-officer-1", 621 "wallet-trigger-kyc-for-aml", 622 true /* keep investigating */, 623 GNUNET_TIME_UNIT_HOURS /* expiration */, 624 NULL /* successor measure: default */, 625 "{\"rules\":[" 626 "{\"timeframe\":{\"d_us\":3600000000}," 627 " \"threshold\":\"EUR:10000\"," 628 " \"operation_type\":\"BALANCE\"," 629 " \"verboten\":true" 630 "}" 631 "]}" /* new rules */, 632 "{}" /* properties */, 633 "party time", 634 MHD_HTTP_CONFLICT), 635 /* Check that no decision was taken, but that we are allowed 636 to read this information */ 637 TALER_TESTING_cmd_check_aml_decisions ( 638 "check-aml-decision-empty", 639 "create-aml-officer-1", 640 "aml-decide-while-disabled", 641 MHD_HTTP_NO_CONTENT), 642 TALER_TESTING_cmd_sleep ( 643 "sleep-1b", 644 1), 645 TALER_TESTING_cmd_set_officer ( 646 "create-aml-officer-1-enable", 647 "create-aml-officer-1", 648 "Peter Falk", 649 true, 650 false), 651 TALER_TESTING_cmd_get_aml_officer ( 652 "get-read-write-aml-officer", 653 "create-aml-officer-1", 654 MHD_HTTP_OK, 655 "Peter Falk", 656 false), 657 TALER_TESTING_cmd_take_aml_decision ( 658 "aml-decide", 659 "create-aml-officer-1", 660 "wallet-trigger-kyc-for-aml", 661 true /* keep investigating */, 662 GNUNET_TIME_UNIT_HOURS /* expiration */, 663 NULL /* successor measure: default */, 664 "{\"rules\":[" 665 "{\"timeframe\":{\"d_us\":3600000000}," 666 " \"threshold\":\"EUR:10000\"," 667 " \"operation_type\":\"BALANCE\"," 668 " \"verboten\":true" 669 "}" 670 "]}" /* new rules */, 671 "{}" /* properties */, 672 "party time", 673 MHD_HTTP_NO_CONTENT), 674 TALER_TESTING_cmd_check_aml_decisions ( 675 "check-decisions-one-normal", 676 "create-aml-officer-1", 677 "aml-decide", 678 MHD_HTTP_OK), 679 TALER_TESTING_cmd_wallet_kyc_get ( 680 "wallet-trigger-kyc-for-aml-allowed", 681 "wallet-trigger-kyc-for-aml", 682 "EUR:1000", 683 MHD_HTTP_OK), 684 TALER_TESTING_cmd_wallet_kyc_get ( 685 "wallet-trigger-kyc-for-aml-denied-high", 686 "wallet-trigger-kyc-for-aml", 687 "EUR:20000", 688 MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS), 689 TALER_TESTING_cmd_sleep ( 690 "sleep-1d", 691 1), 692 TALER_TESTING_cmd_set_officer ( 693 "create-aml-officer-1-disable", 694 "create-aml-officer-1", 695 "Peter Falk", 696 false, 697 true), 698 TALER_TESTING_cmd_get_aml_officer ( 699 "get-disabled-aml-officer", 700 "create-aml-officer-1", 701 MHD_HTTP_FORBIDDEN, 702 NULL, 703 true), 704 /* Test that we are NOT allowed to read AML decisions now that 705 our AML staff account is disabled */ 706 TALER_TESTING_cmd_check_aml_decisions ( 707 "check-aml-decision-disabled", 708 "create-aml-officer-1", 709 "aml-decide", 710 MHD_HTTP_FORBIDDEN), 711 TALER_TESTING_cmd_end () 712 }; 713 714 struct TALER_TESTING_Command aml_form[] = { 715 TALER_TESTING_cmd_set_officer ( 716 "create-aml-form-officer-1", 717 NULL, 718 "Peter Falk", 719 true, 720 false), 721 /* Trigger something upon which an AML officer could act */ 722 TALER_TESTING_cmd_wallet_kyc_get ( 723 "wallet-trigger-kyc-for-form-aml", 724 NULL, 725 "EUR:1000", 726 MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS), 727 TALER_TESTING_cmd_wallet_kyc_get ( 728 "wallet-trigger-kyc-for-form-aml-disallowed", 729 "wallet-trigger-kyc-for-form-aml", 730 "EUR:500", 731 MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS), 732 /* AML officer switches from Oauth2 to form */ 733 TALER_TESTING_cmd_take_aml_decision ( 734 "aml-decide-form", 735 "create-aml-form-officer-1", 736 "wallet-trigger-kyc-for-form-aml", 737 false /* just awaiting KYC, no investigation */, 738 GNUNET_TIME_UNIT_HOURS /* expiration */, 739 NULL /* successor measure: default */, 740 "{\"rules\":" 741 " [" 742 " {" 743 " \"timeframe\":{\"d_us\":3600000000}" 744 " ,\"threshold\":\"EUR:0\"" 745 " ,\"operation_type\":\"BALANCE\"" 746 " ,\"display_priority\":65536" 747 " ,\"measures\":[\"form-measure\"]" 748 " ,\"verboten\":false" 749 " }" 750 " ]" /* end new rules */ 751 ",\"new_measures\":\"form-measure\"" 752 ",\"custom_measures\":" 753 " {" 754 " \"form-measure\":" 755 " {" 756 " \"check_name\":\"test-form\"" 757 " ,\"prog_name\":\"test-form-check\"" 758 " }" 759 " }" /* end custom measures */ 760 "}", 761 "{}" /* properties */, 762 "form time", 763 MHD_HTTP_NO_CONTENT), 764 /* Wallet learns about form submission */ 765 TALER_TESTING_cmd_check_kyc_get ( 766 "check-kyc-form", 767 "wallet-trigger-kyc-for-form-aml", 768 "wallet-trigger-kyc-for-form-aml", 769 TALER_EXCHANGE_KLPT_KYC_AUTH_TRANSFER, 770 MHD_HTTP_ACCEPTED), 771 TALER_TESTING_cmd_get_kyc_info ( 772 "get-kyc-info-form", 773 "check-kyc-form", 774 MHD_HTTP_OK), 775 TALER_TESTING_cmd_post_kyc_form ( 776 "wallet-post-kyc-wrong-form", 777 "get-kyc-info-form", 778 0, /* requirement index */ 779 "application/json", 780 "{\"FORM_ID\":\"wrong\",\"FULL_NAME\":\"Bob\",\"DATE_OF_BIRTH\":\"1990-00-00\"}", 781 MHD_HTTP_CONFLICT), 782 TALER_TESTING_cmd_post_kyc_form ( 783 "wallet-post-kyc-form", 784 "get-kyc-info-form", 785 0, /* requirement index */ 786 "application/json", 787 "{\"FORM_ID\":\"full_name_and_birthdate\",\"FULL_NAME\":\"Bob\",\"DATE_OF_BIRTH\":\"1990-00-00\"}", 788 MHD_HTTP_NO_CONTENT), 789 /* now this should be allowed */ 790 TALER_TESTING_cmd_wallet_kyc_get ( 791 "wallet-trigger-kyc-for-form-aml-allowed", 792 "wallet-trigger-kyc-for-form-aml", 793 "EUR:500", 794 MHD_HTTP_OK), 795 TALER_TESTING_cmd_end () 796 }; 797 798 799 struct TALER_TESTING_Command commands[] = { 800 TALER_TESTING_cmd_run_fakebank ( 801 "run-fakebank", 802 cred.cfg, 803 "exchange-account-2"), 804 TALER_TESTING_cmd_system_start ( 805 "start-taler", 806 CONFIG_FILE, 807 "-e", 808 NULL), 809 TALER_TESTING_cmd_get_exchange ( 810 "get-exchange", 811 cred.cfg, 812 NULL, 813 true, 814 true), 815 TALER_TESTING_cmd_batch ( 816 "withdraw", 817 withdraw), 818 TALER_TESTING_cmd_batch ( 819 "spend", 820 spend), 821 TALER_TESTING_cmd_batch ( 822 "track", 823 track), 824 TALER_TESTING_cmd_batch ( 825 "withdraw-kyc", 826 withdraw_kyc), 827 TALER_TESTING_cmd_batch ( 828 "wallet-kyc", 829 wallet_kyc), 830 TALER_TESTING_cmd_batch ( 831 "p2p_withdraw", 832 p2p_withdraw), 833 TALER_TESTING_cmd_batch ( 834 "push", 835 push), 836 TALER_TESTING_cmd_batch ( 837 "pull", 838 pull), 839 TALER_TESTING_cmd_batch ("aml", 840 aml), 841 TALER_TESTING_cmd_batch ("aml-form", 842 aml_form), 843 TALER_TESTING_cmd_end () 844 }; 845 846 (void) cls; 847 TALER_TESTING_run (is, 848 commands); 849 } 850 851 852 int 853 main (int argc, 854 char *const *argv) 855 { 856 (void) argc; 857 return TALER_TESTING_main ( 858 argv, 859 "INFO", 860 CONFIG_FILE, 861 "exchange-account-2", 862 TALER_TESTING_BS_FAKEBANK, 863 &cred, 864 &run, 865 NULL); 866 } 867 868 869 /* end of test_kyc_api.c */