LCOV - code coverage report
Current view: top level - backenddb - get_instance_auth.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 13 13
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              :    Copyright (C) 2022 Taler Systems SA
       4              : 
       5              :    TALER 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              :    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/backenddb/get_instance_auth.c
      18              :  * @brief Implementation of the get_instance_auth function for Postgres
      19              :  * @author Iván Ávalos
      20              :  */
      21              : #include "platform.h"
      22              : #include <taler/taler_pq_lib.h>
      23              : #include "merchant-database/get_instance_auth.h"
      24              : #include "helper.h"
      25              : 
      26              : 
      27              : enum GNUNET_DB_QueryStatus
      28           15 : TALER_MERCHANTDB_get_instance_auth (
      29              :   struct TALER_MERCHANTDB_PostgresContext *pg,
      30              :   const char *instance_id,
      31              :   struct TALER_MERCHANTDB_InstanceAuthSettings *ias)
      32              : {
      33           15 :   struct GNUNET_PQ_QueryParam params[] = {
      34           15 :     GNUNET_PQ_query_param_string (instance_id),
      35              :     GNUNET_PQ_query_param_end
      36              :   };
      37              :   bool no_hash;
      38              :   bool no_salt;
      39           15 :   struct GNUNET_PQ_ResultSpec rs[] = {
      40           15 :     GNUNET_PQ_result_spec_allow_null (
      41           15 :       GNUNET_PQ_result_spec_auto_from_type ("auth_hash",
      42              :                                             &ias->auth_hash),
      43              :       &no_hash),
      44           15 :     GNUNET_PQ_result_spec_allow_null (
      45           15 :       GNUNET_PQ_result_spec_auto_from_type ("auth_salt",
      46              :                                             &ias->auth_salt),
      47              :       &no_salt),
      48              :     GNUNET_PQ_result_spec_end
      49              :   };
      50              :   enum GNUNET_DB_QueryStatus qs;
      51              : 
      52           15 :   PREPARE (pg,
      53              :            "get_instance_auth",
      54              :            "SELECT"
      55              :            " auth_hash"
      56              :            ",auth_salt"
      57              :            " FROM merchant.merchant_instances"
      58              :            " WHERE merchant_id=$1");
      59           15 :   memset (&ias->auth_hash,
      60              :           0,
      61              :           sizeof (ias->auth_hash));
      62           15 :   memset (&ias->auth_salt,
      63              :           0,
      64              :           sizeof (ias->auth_salt));
      65           15 :   qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
      66              :                                                  "get_instance_auth",
      67              :                                                  params,
      68              :                                                  rs);
      69              :   /* 'auth_hash' and 'auth_salt' are nullable; the all-zero value we
      70              :      left them at is how the rest of the code spells "no password
      71              :      configured" (see TMH_check_auth()). */
      72           15 :   return qs;
      73              : }
        

Generated by: LCOV version 2.0-1