test_donau_api.c (5292B)
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_exchange_api.c 21 * @brief testcase to test exchange's HTTP API interface 22 * @author Sree Harsha Totakura <sreeharsha@totakura.in> 23 * @author Christian Grothoff 24 * @author Marcello Stanisci 25 * @author Lukas Matyja 26 */ 27 #include <donau_config.h> 28 #include <taler/taler_util.h> 29 #include <taler/taler_json_lib.h> 30 #include <gnunet/gnunet_util_lib.h> 31 #include <gnunet/gnunet_testing_lib.h> 32 #include <microhttpd.h> 33 #include <taler/taler_testing_lib.h> 34 #include "donau_testing_lib.h" 35 36 /** 37 * Configuration file we use. One (big) configuration is used 38 * for the various components for this test. 39 */ 40 static char *config_file; 41 42 /** 43 * Our credentials. 44 */ 45 static struct TALER_TESTING_Credentials cred; 46 47 /** 48 * Issue receipts tests behave differently when using CS. 49 */ 50 static bool uses_cs; 51 52 /** 53 * Main function that will tell the interpreter what commands to 54 * run. 55 * 56 * @param cls closure 57 * @param is interpreter we use to run commands 58 */ 59 static void 60 run (void *cls, 61 struct TALER_TESTING_Interpreter *is) 62 { 63 const static struct DONAU_BearerToken bearer = { 64 .token = "secret-token:secret" 65 }; 66 struct TALER_TESTING_Command commands[] = { 67 TALER_TESTING_cmd_system_start ("start-donau", 68 config_file, 69 "-D", 70 "NULL"), 71 TALER_TESTING_cmd_get_donau ("get-donau", 72 cred.cfg, 73 true), 74 TALER_TESTING_cmd_charity_post ("post-charity", 75 "example", 76 "example.com", 77 "EUR:10", // max_per_year 78 &bearer, 79 MHD_HTTP_CREATED), 80 TALER_TESTING_cmd_charity_get ("get-charity-by-id", 81 "post-charity", // cmd trait reference 82 MHD_HTTP_OK), 83 TALER_TESTING_cmd_charity_patch ("patch-charity", 84 "post-charity", 85 "example-updated", 86 "example.org", 87 "EUR:15", 88 &bearer, 89 MHD_HTTP_OK), 90 TALER_TESTING_cmd_charity_get ("get-charity-after-patch", 91 "patch-charity", 92 MHD_HTTP_OK), 93 TALER_TESTING_cmd_charities_get ("get-charities", 94 &bearer, 95 MHD_HTTP_OK), 96 // FIXME: CSR signatures 97 TALER_TESTING_cmd_issue_receipts ("issue-receipts", 98 "patch-charity", 99 uses_cs, 100 2025, 101 "7560001010000", // tax id 102 "1234", // salt for tax id hash 103 "EUR:5", /* Amount to be issued*/ 104 MHD_HTTP_OK), 105 TALER_TESTING_cmd_submit_receipts ("submit-receipts", 106 "issue-receipts", // cmd trait reference 107 2025, 108 MHD_HTTP_CREATED), 109 TALER_TESTING_cmd_donation_statement_get ("donation-statement", 110 2025, 111 MHD_HTTP_OK), 112 TALER_TESTING_cmd_charity_delete ("delete-charity", 113 "patch-charity", // cmd trait reference 114 &bearer, 115 MHD_HTTP_NO_CONTENT), 116 /* End the suite. */ 117 TALER_TESTING_cmd_end () 118 }; 119 120 (void) cls; 121 TALER_TESTING_run (is, 122 commands); 123 } 124 125 126 int 127 main (int argc, 128 char *const *argv) 129 { 130 (void) argc; 131 { 132 char *cipher; 133 134 cipher = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); 135 GNUNET_assert (NULL != cipher); 136 uses_cs = (0 == strcmp (cipher, 137 "cs")); 138 GNUNET_asprintf (&config_file, 139 "test_donau_api-%s.conf", 140 cipher); 141 GNUNET_free (cipher); 142 } 143 return DONAU_TESTING_main (argv, 144 "INFO", 145 config_file, 146 &cred, 147 &run, 148 NULL); 149 } 150 151 152 /* end of test_donau_api.c */