LCOV - code coverage report
Current view: top level - lib - merchant_api_common_mfa_challenge.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 32 0
Test Date: 2026-09-11 17:45:24 Functions: 0.0 % 2 0

            Line data    Source code
       1              : /*
       2              :   This file is part of TALER
       3              :   Copyright (C) 2025-2026 Taler Systems SA
       4              : 
       5              :   TALER is free software; you can redistribute it and/or modify it under the
       6              :   terms of the GNU Lesser General Public License as published by the Free Software
       7              :   Foundation; either version 2.1, 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 Lesser General Public License for more details.
      12              : 
      13              :   You should have received a copy of the GNU Lesser General Public License along with
      14              :   TALER; see the file COPYING.LGPL.  If not, see
      15              :   <http://www.gnu.org/licenses/>
      16              : */
      17              : /**
      18              :  * @file src/lib/merchant_api_common_mfa_challenge.c
      19              :  * @brief Shared parsing of HTTP 202 MFA challenge responses
      20              :  * @author Christian Grothoff
      21              :  */
      22              : #include "platform.h"
      23              : #include "taler/taler_merchant_service.h"
      24              : #include <gnunet/gnunet_json_lib.h>
      25              : #include "taler/taler_json_lib.h"
      26              : #include "merchant_api_common.h"
      27              : 
      28              : 
      29              : enum GNUNET_GenericReturnValue
      30            0 : TALER_MERCHANT_parse_mfa_challenge_response_ (
      31              :   const json_t *json,
      32              :   struct TALER_MERCHANT_MfaChallengeResponse *cr)
      33              : {
      34              :   const json_t *challenges;
      35              :   struct GNUNET_JSON_Specification spec[] = {
      36            0 :     GNUNET_JSON_spec_bool ("combi_and",
      37              :                            &cr->combi_and),
      38            0 :     GNUNET_JSON_spec_array_const ("challenges",
      39              :                                   &challenges),
      40            0 :     GNUNET_JSON_spec_end ()
      41              :   };
      42              : 
      43            0 :   memset (cr,
      44              :           0,
      45              :           sizeof (*cr));
      46            0 :   if (GNUNET_OK !=
      47            0 :       GNUNET_JSON_parse (json,
      48              :                          spec,
      49              :                          NULL, NULL))
      50              :   {
      51            0 :     GNUNET_break_op (0);
      52            0 :     return GNUNET_SYSERR;
      53              :   }
      54            0 :   cr->challenges_length = (unsigned int) json_array_size (challenges);
      55            0 :   if (0 == cr->challenges_length)
      56              :   {
      57            0 :     GNUNET_break_op (0);
      58            0 :     return GNUNET_SYSERR;
      59              :   }
      60            0 :   cr->challenges = GNUNET_new_array (
      61              :     cr->challenges_length,
      62              :     struct TALER_MERCHANT_MfaChallengeEntry);
      63            0 :   for (unsigned int i = 0; i < cr->challenges_length; i++)
      64              :   {
      65            0 :     const json_t *jentry = json_array_get (challenges,
      66              :                                            i);
      67            0 :     struct TALER_MERCHANT_MfaChallengeEntry *entry = &cr->challenges[i];
      68              :     struct GNUNET_JSON_Specification espec[] = {
      69            0 :       GNUNET_JSON_spec_string ("tan_info",
      70              :                                &entry->tan_info),
      71            0 :       GNUNET_JSON_spec_string ("tan_channel",
      72              :                                &entry->tan_channel),
      73            0 :       TALER_JSON_spec_slug ("challenge_id",
      74              :                             &entry->challenge_id),
      75            0 :       GNUNET_JSON_spec_end ()
      76              :     };
      77              : 
      78            0 :     if (GNUNET_OK !=
      79            0 :         GNUNET_JSON_parse (jentry,
      80              :                            espec,
      81              :                            NULL, NULL))
      82              :     {
      83            0 :       GNUNET_break_op (0);
      84            0 :       GNUNET_free (cr->challenges);
      85            0 :       cr->challenges_length = 0;
      86            0 :       return GNUNET_SYSERR;
      87              :     }
      88              :   }
      89            0 :   return GNUNET_OK;
      90              : }
      91              : 
      92              : 
      93              : void
      94            0 : TALER_MERCHANT_mfa_challenge_response_free (
      95              :   struct TALER_MERCHANT_MfaChallengeResponse *cr)
      96              : {
      97            0 :   GNUNET_free (cr->challenges);
      98            0 :   cr->challenges_length = 0;
      99            0 : }
     100              : 
     101              : 
     102              : /* end of merchant_api_common_mfa_challenge.c */
        

Generated by: LCOV version 2.0-1