LCOV - code coverage report
Current view: top level - backend - taler-merchant-httpd_patch-private-accounts-H_WIRE.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 43 0
Test Date: 2026-09-04 23:42:01 Functions: 0.0 % 1 0

            Line data    Source code
       1              : /*
       2              :   This file is part of TALER
       3              :   (C) 2023, 2025, 2026 Taler Systems SA
       4              : 
       5              :   TALER is free software; you can redistribute it and/or modify
       6              :   it under the terms of the GNU Affero General Public License as
       7              :   published by the Free Software Foundation; either version 3,
       8              :   or (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,
      17              :   see <http://www.gnu.org/licenses/>
      18              : */
      19              : 
      20              : /**
      21              :  * @file src/backend/taler-merchant-httpd_patch-private-accounts-H_WIRE.c
      22              :  * @brief implementing PATCH /accounts/$ID request handling
      23              :  * @author Christian Grothoff
      24              :  */
      25              : #include "platform.h"
      26              : #include "taler-merchant-httpd_patch-private-accounts-H_WIRE.h"
      27              : #include "taler-merchant-httpd_helper.h"
      28              : #include <taler/taler_json_lib.h>
      29              : #include "taler-merchant-httpd_mfa.h"
      30              : #include "merchant-database/update_account.h"
      31              : 
      32              : 
      33              : /**
      34              :  * PATCH configuration of an existing instance, given its configuration.
      35              :  *
      36              :  * @param rh context of the handler
      37              :  * @param connection the MHD connection to handle
      38              :  * @param[in,out] hc context with further information about the request
      39              :  * @return MHD result code
      40              :  */
      41              : enum MHD_Result
      42            0 : TMH_private_patch_accounts_ID (const struct TMH_RequestHandler *rh,
      43              :                                struct MHD_Connection *connection,
      44              :                                struct TMH_HandlerContext *hc)
      45              : {
      46            0 :   struct TMH_MerchantInstance *mi = hc->instance;
      47            0 :   const char *h_wire_s = hc->infix;
      48              :   enum GNUNET_DB_QueryStatus qs;
      49            0 :   const json_t *cfc = NULL;
      50            0 :   const char *extra_wire_subject_metadata = NULL;
      51            0 :   const char *cfu = NULL;
      52              :   struct TALER_MerchantWireHashP h_wire;
      53              :   struct GNUNET_JSON_Specification spec[] = {
      54            0 :     GNUNET_JSON_spec_mark_optional (
      55              :       TALER_JSON_spec_web_url ("credit_facade_url",
      56              :                                &cfu),
      57              :       NULL),
      58            0 :     GNUNET_JSON_spec_mark_optional (
      59              :       GNUNET_JSON_spec_string ("extra_wire_subject_metadata",
      60              :                                &extra_wire_subject_metadata),
      61              :       NULL),
      62            0 :     GNUNET_JSON_spec_mark_optional (
      63              :       GNUNET_JSON_spec_object_const ("credit_facade_credentials",
      64              :                                      &cfc),
      65              :       NULL),
      66            0 :     GNUNET_JSON_spec_end ()
      67              :   };
      68              : 
      69            0 :   GNUNET_assert (NULL != mi);
      70            0 :   GNUNET_assert (NULL != h_wire_s);
      71            0 :   if (GNUNET_OK !=
      72            0 :       GNUNET_STRINGS_string_to_data (h_wire_s,
      73              :                                      strlen (h_wire_s),
      74              :                                      &h_wire,
      75              :                                      sizeof (h_wire)))
      76              :   {
      77            0 :     GNUNET_break_op (0);
      78            0 :     return TALER_MHD_reply_with_error (connection,
      79              :                                        MHD_HTTP_BAD_REQUEST,
      80              :                                        TALER_EC_MERCHANT_GENERIC_H_WIRE_MALFORMED,
      81              :                                        h_wire_s);
      82              :   }
      83              :   {
      84              :     enum GNUNET_GenericReturnValue res;
      85              : 
      86            0 :     res = TALER_MHD_parse_json_data (connection,
      87            0 :                                      hc->request_body,
      88              :                                      spec);
      89            0 :     if (GNUNET_OK != res)
      90              :       return (GNUNET_NO == res)
      91              :              ? MHD_YES
      92            0 :              : MHD_NO;
      93              :   }
      94            0 :   if (! TALER_is_valid_subject_metadata_string (
      95              :         extra_wire_subject_metadata))
      96              :   {
      97            0 :     GNUNET_break_op (0);
      98            0 :     return TALER_MHD_reply_with_error (
      99              :       connection,
     100              :       MHD_HTTP_BAD_REQUEST,
     101              :       TALER_EC_GENERIC_PARAMETER_MALFORMED,
     102              :       "extra_wire_subject_metadata");
     103              :   }
     104              : 
     105            0 :   qs = TALER_MERCHANTDB_update_account (TMH_db,
     106            0 :                                         mi->settings.id,
     107              :                                         &h_wire,
     108              :                                         extra_wire_subject_metadata,
     109              :                                         cfu,
     110              :                                         cfc);
     111              :   {
     112            0 :     enum MHD_Result ret = MHD_NO;
     113              : 
     114            0 :     switch (qs)
     115              :     {
     116            0 :     case GNUNET_DB_STATUS_HARD_ERROR:
     117            0 :       GNUNET_break (0);
     118            0 :       ret = TALER_MHD_reply_with_error (
     119              :         connection,
     120              :         MHD_HTTP_INTERNAL_SERVER_ERROR,
     121              :         TALER_EC_GENERIC_DB_STORE_FAILED,
     122              :         "update_account");
     123            0 :       break;
     124            0 :     case GNUNET_DB_STATUS_SOFT_ERROR:
     125            0 :       GNUNET_break (0);
     126            0 :       ret = TALER_MHD_reply_with_error (
     127              :         connection,
     128              :         MHD_HTTP_INTERNAL_SERVER_ERROR,
     129              :         TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
     130              :         "unexpected serialization problem");
     131            0 :       break;
     132            0 :     case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
     133            0 :       ret = TALER_MHD_reply_with_error (
     134              :         connection,
     135              :         MHD_HTTP_NOT_FOUND,
     136              :         TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN,
     137              :         h_wire_s);
     138            0 :       break;
     139            0 :     case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
     140            0 :       ret = TALER_MHD_reply_static (connection,
     141              :                                     MHD_HTTP_NO_CONTENT,
     142              :                                     NULL,
     143              :                                     NULL,
     144              :                                     0);
     145            0 :       break;
     146              :     }
     147            0 :     GNUNET_JSON_parse_free (spec);
     148            0 :     return ret;
     149              :   }
     150              : }
     151              : 
     152              : 
     153              : /* end of taler-merchant-httpd_patch-private-accounts-H_WIRE.c */
        

Generated by: LCOV version 2.0-1