LCOV - code coverage report
Current view: top level - backend - taler-merchant-httpd_delete-private-donau-DONAU_SERIAL.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 47.4 % 19 9
Test Date: 2026-09-04 23:42:01 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :   This file is part of TALER
       3              :   (C) 2024 Taler Systems SA
       4              : 
       5              :   TALER is free software; you can redistribute it and/or modify it under the
       6              :   terms of the GNU Affero General Public License as published by the Free Software
       7              :   Foundation; either version 3, or (at your option) any later version.
       8              : 
       9              :   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
      10              :   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
      11              :   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
      12              : 
      13              :   You should have received a copy of the GNU General Public License along with
      14              :   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
      15              : */
      16              : /**
      17              :  * @file src/backend/taler-merchant-httpd_delete-private-donau-DONAU_SERIAL.c
      18              :  * @brief implement DELETE /private/donau/$donau_serial_id
      19              :  * @author Bohdan Potuzhnyi
      20              :  * @author Vlada Svirsh
      21              :  */
      22              : 
      23              : #include "platform.h"
      24              : #include "taler-merchant-httpd_delete-private-donau-DONAU_SERIAL.h"
      25              : #include <taler/taler_json_lib.h>
      26              : #include <taler/taler_error_codes.h>
      27              : #include <taler/taler_dbevents.h>
      28              : #include "merchant-database/delete_donau_instance.h"
      29              : 
      30              : /**
      31              :  * Handle a DELETE "/donau/$donau_serial_id/" request.
      32              :  *
      33              :  * @param rh context of the handler
      34              :  * @param connection the MHD connection to handle
      35              :  * @param[in,out] hc context with further information about the request
      36              :  * @return MHD result code
      37              :  */
      38              : enum MHD_Result
      39            2 : TMH_private_delete_donau_instance_ID (
      40              :   const struct TMH_RequestHandler *rh,
      41              :   struct MHD_Connection *connection,
      42              :   struct TMH_HandlerContext *hc)
      43              : {
      44            2 :   struct TMH_MerchantInstance *mi = hc->instance;
      45              :   enum GNUNET_DB_QueryStatus qs;
      46              :   unsigned long long donau_serial_id;
      47              :   char dummy;
      48              : 
      49            2 :   GNUNET_assert (NULL != mi);
      50            2 :   if (1 != sscanf (hc->infix,
      51              :                    "%llu%c",
      52              :                    &donau_serial_id,
      53              :                    &dummy))
      54              :   {
      55            0 :     return TALER_MHD_reply_with_error (connection,
      56              :                                        MHD_HTTP_BAD_REQUEST,
      57              :                                        TALER_EC_GENERIC_PARAMETER_MALFORMED,
      58            0 :                                        hc->infix);
      59              :   }
      60              : 
      61            2 :   qs = TALER_MERCHANTDB_delete_donau_instance (TMH_db,
      62            2 :                                                hc->instance->settings.id,
      63              :                                                (uint64_t) donau_serial_id);
      64            2 :   switch (qs)
      65              :   {
      66            0 :   case GNUNET_DB_STATUS_HARD_ERROR:
      67            0 :     return TALER_MHD_reply_with_error (connection,
      68              :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      69              :                                        TALER_EC_GENERIC_DB_STORE_FAILED,
      70              :                                        "delete_donau_instance");
      71            0 :   case GNUNET_DB_STATUS_SOFT_ERROR:
      72            0 :     GNUNET_break (0);
      73            0 :     return TALER_MHD_reply_with_error (connection,
      74              :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      75              :                                        TALER_EC_GENERIC_DB_SOFT_FAILURE,
      76              :                                        "delete_donau_instance (soft)");
      77            0 :   case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
      78            0 :     return TALER_MHD_reply_with_error (connection,
      79              :                                        MHD_HTTP_NOT_FOUND,
      80              :                                        TALER_EC_MERCHANT_GENERIC_DONAU_UNKNOWN,
      81              :                                        NULL);
      82            2 :   case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
      83            2 :     return TALER_MHD_reply_static (connection,
      84              :                                    MHD_HTTP_NO_CONTENT,
      85              :                                    NULL,
      86              :                                    NULL,
      87              :                                    0);
      88              :   }
      89            0 :   GNUNET_assert (0);
      90              :   return MHD_NO;
      91              : }
        

Generated by: LCOV version 2.0-1