LCOV - code coverage report
Current view: top level - challengerdb - validate_solve_pin.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 90.9 % 22 20
Test Date: 2026-06-09 21:00:27 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :    This file is part of Challenger
       3              :    Copyright (C) 2023 Taler Systems SA
       4              : 
       5              :    Challenger is free software; you can redistribute it and/or modify it under the
       6              :    terms of the GNU General Public License as published by the Free Software
       7              :    Foundation; either version 3, or (at your option) any later version.
       8              : 
       9              :    Challenger 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              :    Challenger; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
      15              :  */
      16              : /**
      17              :  * @file src/challengerdb/validate_solve_pin.c
      18              :  * @brief Implementation of the validate_solve_pin function for Postgres
      19              :  * @author Christian Grothoff
      20              :  */
      21              : #include "platform.h"
      22              : #include <taler/taler_error_codes.h>
      23              : #include <taler/taler_dbevents.h>
      24              : #include <taler/taler_pq_lib.h>
      25              : #include "validate_solve_pin.h"
      26              : #include "pg_helper.h"
      27              : 
      28              : 
      29              : enum GNUNET_DB_QueryStatus
      30            3 : CHALLENGERDB_validate_solve_pin (struct CHALLENGERDB_PostgresContext *ctx,
      31              :                           const struct CHALLENGER_ValidationNonceP *nonce,
      32              :                           uint32_t new_pin,
      33              :                           bool *solved,
      34              :                           bool *exhausted,
      35              :                           bool *no_challenge,
      36              :                           char **state,
      37              :                           uint32_t *addr_left,
      38              :                           uint32_t *auth_attempts_left,
      39              :                           uint32_t *pin_transmissions_left,
      40              :                           char **client_redirect_uri)
      41              : {
      42            3 :   struct GNUNET_PQ_QueryParam params[] = {
      43            3 :     GNUNET_PQ_query_param_auto_from_type (nonce),
      44            3 :     GNUNET_PQ_query_param_uint32 (&new_pin),
      45              :     GNUNET_PQ_query_param_end
      46              :   };
      47              :   bool not_found;
      48            3 :   struct GNUNET_PQ_ResultSpec rs[] = {
      49            3 :     GNUNET_PQ_result_spec_bool ("not_found",
      50              :                                 &not_found),
      51            3 :     GNUNET_PQ_result_spec_bool ("solved",
      52              :                                 solved),
      53            3 :     GNUNET_PQ_result_spec_bool ("exhausted",
      54              :                                 exhausted),
      55            3 :     GNUNET_PQ_result_spec_bool ("no_challenge",
      56              :                                 no_challenge),
      57            3 :     GNUNET_PQ_result_spec_uint32 ("address_attempts_left",
      58              :                                   addr_left),
      59            3 :     GNUNET_PQ_result_spec_uint32 ("auth_attempts_left",
      60              :                                   auth_attempts_left),
      61            3 :     GNUNET_PQ_result_spec_uint32 ("pin_transmissions_left",
      62              :                                   pin_transmissions_left),
      63            3 :     GNUNET_PQ_result_spec_allow_null (
      64              :       GNUNET_PQ_result_spec_string ("client_redirect_uri",
      65              :                                     client_redirect_uri),
      66              :       NULL),
      67            3 :     GNUNET_PQ_result_spec_allow_null (
      68              :       GNUNET_PQ_result_spec_string ("state",
      69              :                                     state),
      70              :       NULL),
      71              :     GNUNET_PQ_result_spec_end
      72              :   };
      73              :   enum GNUNET_DB_QueryStatus qs;
      74              : 
      75            3 :   *client_redirect_uri = NULL;
      76            3 :   PREPARE (ctx,
      77              :            "do_validate_solve_pin",
      78              :            "SELECT "
      79              :            " out_not_found AS not_found"
      80              :            ",out_solved AS solved"
      81              :            ",out_exhausted AS exhausted"
      82              :            ",out_no_challenge AS no_challenge"
      83              :            ",out_state AS state"
      84              :            ",out_address_attempts_left AS address_attempts_left"
      85              :            ",out_auth_attempts_left AS auth_attempts_left"
      86              :            ",out_pin_transmissions_left AS pin_transmissions_left"
      87              :            ",out_client_redirect_uri AS client_redirect_uri"
      88              :            " FROM challenger_do_validate_and_solve_pin"
      89              :            " ($1,$2);");
      90            3 :   qs = GNUNET_PQ_eval_prepared_singleton_select (ctx->conn,
      91              :                                                  "do_validate_solve_pin",
      92              :                                                  params,
      93              :                                                  rs);
      94            3 :   if (qs <= 0)
      95            0 :     return qs;
      96            3 :   if (not_found)
      97            0 :     return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
      98            3 :   return qs;
      99              : }
        

Generated by: LCOV version 2.0-1