test_donau_api.c (6050B)
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-transient", 75 "example", 76 "https://example.com/", 77 "EUR:10", // max_per_year 78 &bearer, 79 MHD_HTTP_CREATED), 80 TALER_TESTING_cmd_charity_delete ("delete-charity-transient", 81 "post-charity-transient", // cmd trait reference 82 &bearer, 83 MHD_HTTP_NO_CONTENT), 84 TALER_TESTING_cmd_charity_post ("post-charity", 85 "example", 86 "https://example.com/", 87 "EUR:10", // max_per_year 88 &bearer, 89 MHD_HTTP_CREATED), 90 TALER_TESTING_cmd_charity_get ("get-charity-by-id", 91 "post-charity", // cmd trait reference 92 MHD_HTTP_OK), 93 TALER_TESTING_cmd_charity_patch ("patch-charity", 94 "post-charity", 95 "example-updated", 96 "https://example.org/", 97 "EUR:15", 98 &bearer, 99 MHD_HTTP_OK), 100 TALER_TESTING_cmd_charity_get ("get-charity-after-patch", 101 "patch-charity", 102 MHD_HTTP_OK), 103 TALER_TESTING_cmd_charities_get ("get-charities", 104 &bearer, 105 MHD_HTTP_OK), 106 // FIXME: CSR signatures 107 TALER_TESTING_cmd_issue_receipts ("issue-receipts", 108 "patch-charity", 109 uses_cs, 110 GNUNET_TIME_get_current_year (), 111 "7560001010000", // tax id 112 "1234", // salt for tax id hash 113 "EUR:5", /* Amount to be issued*/ 114 MHD_HTTP_OK), 115 TALER_TESTING_cmd_submit_receipts ("submit-receipts", 116 "issue-receipts", // cmd trait reference 117 GNUNET_TIME_get_current_year (), 118 MHD_HTTP_CREATED), 119 TALER_TESTING_cmd_donation_statement_get ("donation-statement", 120 GNUNET_TIME_get_current_year (), 121 MHD_HTTP_OK), 122 /* cannot delete anymore: this would delete data we need to keep */ 123 TALER_TESTING_cmd_charity_delete ("delete-charity", 124 "patch-charity", // cmd trait reference 125 &bearer, 126 MHD_HTTP_CONFLICT), 127 /* End the suite. */ 128 TALER_TESTING_cmd_end () 129 }; 130 131 (void) cls; 132 TALER_TESTING_run (is, 133 commands); 134 } 135 136 137 int 138 main (int argc, 139 char *const *argv) 140 { 141 (void) argc; 142 { 143 char *cipher; 144 145 cipher = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); 146 GNUNET_assert (NULL != cipher); 147 uses_cs = (0 == strcmp (cipher, 148 "cs")); 149 GNUNET_asprintf (&config_file, 150 "test_donau_api-%s.conf", 151 cipher); 152 GNUNET_free (cipher); 153 } 154 return DONAU_TESTING_main (argv, 155 "INFO", 156 config_file, 157 &cred, 158 &run, 159 NULL); 160 } 161 162 163 /* end of test_donau_api.c */