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

            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/client_check.c
      18              :  * @brief Implementation of the client_check 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 "client_check.h"
      26              : #include "pg_helper.h"
      27              : 
      28              : 
      29              : enum GNUNET_DB_QueryStatus
      30            6 : CHALLENGERDB_client_check (struct CHALLENGERDB_PostgresContext *ctx,
      31              :                     uint64_t client_id,
      32              :                     const char *client_secret,
      33              :                     uint32_t counter_increment,
      34              :                     char **client_redirect_uri)
      35              : {
      36            6 :   struct GNUNET_PQ_QueryParam params[] = {
      37            6 :     GNUNET_PQ_query_param_uint64 (&client_id),
      38            6 :     GNUNET_PQ_query_param_string (client_secret),
      39            6 :     GNUNET_PQ_query_param_uint32 (&counter_increment),
      40              :     GNUNET_PQ_query_param_end
      41              :   };
      42            6 :   struct GNUNET_PQ_ResultSpec rs[] = {
      43            6 :     GNUNET_PQ_result_spec_allow_null (
      44              :       GNUNET_PQ_result_spec_string ("uri",
      45              :                                     client_redirect_uri),
      46              :       NULL),
      47              :     GNUNET_PQ_result_spec_end
      48              :   };
      49              : 
      50            6 :   *client_redirect_uri = NULL;
      51            6 :   PREPARE (ctx,
      52              :            "client_check",
      53              :            "UPDATE clients SET"
      54              :            " validation_counter=validation_counter+CAST($3::INT4 AS INT8)"
      55              :            " WHERE client_serial_id=$1"
      56              :            "   AND client_secret=$2"
      57              :            " RETURNING uri;");
      58            6 :   return GNUNET_PQ_eval_prepared_singleton_select (ctx->conn,
      59              :                                                    "client_check",
      60              :                                                    params,
      61              :                                                    rs);
      62              : }
      63              : 
      64              : 
      65              : enum GNUNET_DB_QueryStatus
      66            3 : CHALLENGERDB_client_check2 (struct CHALLENGERDB_PostgresContext *ctx,
      67              :                      const char *client_uri,
      68              :                      const char *client_secret,
      69              :                      uint64_t *client_id)
      70              : {
      71            3 :   struct GNUNET_PQ_QueryParam params[] = {
      72            3 :     GNUNET_PQ_query_param_string (client_uri),
      73            3 :     GNUNET_PQ_query_param_string (client_secret),
      74              :     GNUNET_PQ_query_param_end
      75              :   };
      76            3 :   struct GNUNET_PQ_ResultSpec rs[] = {
      77            3 :     GNUNET_PQ_result_spec_uint64 ("client_serial_id",
      78              :                                   client_id),
      79              :     GNUNET_PQ_result_spec_end
      80              :   };
      81              : 
      82            3 :   PREPARE (ctx,
      83              :            "client_check2",
      84              :            "SELECT client_serial_id"
      85              :            " FROM clients"
      86              :            " WHERE uri=$1"
      87              :            "   AND client_secret=$2;");
      88            3 :   return GNUNET_PQ_eval_prepared_singleton_select (ctx->conn,
      89              :                                                    "client_check2",
      90              :                                                    params,
      91              :                                                    rs);
      92              : }
        

Generated by: LCOV version 2.0-1