exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

test_exchange_management_api.c (7535B)


      1 /*
      2   This file is part of TALER
      3   Copyright (C) 2020-2023 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_management_api.c
     21  * @brief testcase to test exchange's HTTP /management/ API
     22  * @author Christian Grothoff
     23  */
     24 #include "taler/taler_util.h"
     25 #include <gnunet/gnunet_util_lib.h>
     26 #include <gnunet/gnunet_testing_lib.h>
     27 #include <microhttpd.h>
     28 #include "taler/taler_testing_lib.h"
     29 
     30 /**
     31  * Configuration file we use.  One (big) configuration is used
     32  * for the various components for this test.
     33  */
     34 static char *config_file;
     35 
     36 /**
     37  * Our credentials.
     38  */
     39 static struct TALER_TESTING_Credentials cred;
     40 
     41 
     42 /**
     43  * Main function that will tell the interpreter what commands to run.
     44  *
     45  * @param cls closure
     46  * @param is interpreter we use to run commands
     47  */
     48 static void
     49 run (void *cls,
     50      struct TALER_TESTING_Interpreter *is)
     51 {
     52   struct TALER_TESTING_Command commands[] = {
     53     TALER_TESTING_cmd_system_start ("start-taler",
     54                                     config_file,
     55                                     "-u", "exchange-account-2",
     56                                     "-ae",
     57                                     NULL),
     58     TALER_TESTING_cmd_get_exchange ("get-exchange",
     59                                     cred.cfg,
     60                                     NULL,
     61                                     true,
     62                                     true),
     63     TALER_TESTING_cmd_get_auditor ("get-auditor",
     64                                    cred.cfg,
     65                                    true),
     66     TALER_TESTING_cmd_auditor_del ("del-auditor-FROM-SETUP",
     67                                    MHD_HTTP_NO_CONTENT,
     68                                    false),
     69     TALER_TESTING_cmd_auditor_add ("add-auditor-BAD-SIG",
     70                                    MHD_HTTP_FORBIDDEN,
     71                                    true),
     72     TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
     73                                    MHD_HTTP_NO_CONTENT,
     74                                    false),
     75     TALER_TESTING_cmd_auditor_add ("add-auditor-OK-idempotent",
     76                                    MHD_HTTP_NO_CONTENT,
     77                                    false),
     78     TALER_TESTING_cmd_auditor_del ("del-auditor-BAD-SIG",
     79                                    MHD_HTTP_FORBIDDEN,
     80                                    true),
     81     TALER_TESTING_cmd_auditor_del ("del-auditor-OK",
     82                                    MHD_HTTP_NO_CONTENT,
     83                                    false),
     84     TALER_TESTING_cmd_auditor_del ("del-auditor-IDEMPOTENT",
     85                                    MHD_HTTP_NO_CONTENT,
     86                                    false),
     87     TALER_TESTING_cmd_set_wire_fee ("set-fee",
     88                                     "foo-method",
     89                                     "EUR:1",
     90                                     "EUR:5",
     91                                     MHD_HTTP_NO_CONTENT,
     92                                     false),
     93     TALER_TESTING_cmd_set_wire_fee ("set-fee-conflicting",
     94                                     "foo-method",
     95                                     "EUR:1",
     96                                     "EUR:1",
     97                                     MHD_HTTP_CONFLICT,
     98                                     false),
     99     TALER_TESTING_cmd_set_wire_fee ("set-fee-bad-signature",
    100                                     "bar-method",
    101                                     "EUR:1",
    102                                     "EUR:1",
    103                                     MHD_HTTP_FORBIDDEN,
    104                                     true),
    105     TALER_TESTING_cmd_set_wire_fee ("set-fee-other-method",
    106                                     "bar-method",
    107                                     "EUR:1",
    108                                     "EUR:1",
    109                                     MHD_HTTP_NO_CONTENT,
    110                                     false),
    111     TALER_TESTING_cmd_set_wire_fee ("set-fee-idempotent",
    112                                     "bar-method",
    113                                     "EUR:1",
    114                                     "EUR:1",
    115                                     MHD_HTTP_NO_CONTENT,
    116                                     false),
    117     TALER_TESTING_cmd_wire_add ("add-wire-account",
    118                                 cred.user42_payto,
    119                                 MHD_HTTP_NO_CONTENT,
    120                                 false),
    121     TALER_TESTING_cmd_wire_add ("add-wire-account-idempotent",
    122                                 cred.user42_payto,
    123                                 MHD_HTTP_NO_CONTENT,
    124                                 false),
    125     TALER_TESTING_cmd_wire_add ("add-wire-account-another",
    126                                 cred.user43_payto,
    127                                 MHD_HTTP_NO_CONTENT,
    128                                 false),
    129     TALER_TESTING_cmd_wire_add ("add-wire-account-bad-signature",
    130                                 cred.user44_payto,
    131                                 MHD_HTTP_FORBIDDEN,
    132                                 true),
    133     TALER_TESTING_cmd_wire_del ("del-wire-account-not-found",
    134                                 cred.user44_payto,
    135                                 MHD_HTTP_NOT_FOUND,
    136                                 false),
    137     TALER_TESTING_cmd_wire_del ("del-wire-account-bad-signature",
    138                                 cred.user43_payto,
    139                                 MHD_HTTP_FORBIDDEN,
    140                                 true),
    141     TALER_TESTING_cmd_wire_del ("del-wire-account-ok",
    142                                 cred.user43_payto,
    143                                 MHD_HTTP_NO_CONTENT,
    144                                 false),
    145     TALER_TESTING_cmd_exec_offline_sign_keys ("download-future-keys",
    146                                               config_file),
    147     TALER_TESTING_cmd_get_exchange ("get-exchange-1",
    148                                     cred.cfg,
    149                                     "get-exchange",
    150                                     true,
    151                                     true),
    152     TALER_TESTING_cmd_get_exchange ("get-exchange-2",
    153                                     cred.cfg,
    154                                     NULL,
    155                                     true,
    156                                     true),
    157     TALER_TESTING_cmd_end ()
    158   };
    159 
    160   (void) cls;
    161   TALER_TESTING_run (is,
    162                      commands);
    163 }
    164 
    165 
    166 int
    167 main (int argc,
    168       char *const *argv)
    169 {
    170   (void) argc;
    171   {
    172     char *cipher;
    173 
    174     cipher = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]);
    175     GNUNET_assert (NULL != cipher);
    176     GNUNET_asprintf (&config_file,
    177                      "test_exchange_api-%s.conf",
    178                      cipher);
    179     GNUNET_free (cipher);
    180   }
    181   return TALER_TESTING_main (argv,
    182                              "INFO",
    183                              config_file,
    184                              "exchange-account-2",
    185                              TALER_TESTING_BS_FAKEBANK,
    186                              &cred,
    187                              &run,
    188                              NULL);
    189 }
    190 
    191 
    192 /* end of test_exchange_management_api.c */