LCOV - code coverage report
Current view: top level - bank-lib - bank_api_common.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 66.7 % 24 16
Test Date: 2026-01-12 22:36:41 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :   This file is part of TALER
       3              :   Copyright (C) 2015-2020 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
      15              :   <http://www.gnu.org/licenses/>
      16              : */
      17              : /**
      18              :  * @file bank-lib/bank_api_common.c
      19              :  * @brief Common functions for the bank API
      20              :  * @author Christian Grothoff
      21              :  */
      22              : #include "taler/platform.h"
      23              : #include "bank_api_common.h"
      24              : 
      25              : 
      26              : enum GNUNET_GenericReturnValue
      27          309 : TALER_BANK_setup_auth_ (CURL *easy,
      28              :                         const struct TALER_BANK_AuthenticationData *auth)
      29              : {
      30              :   enum GNUNET_GenericReturnValue ret;
      31              : 
      32          309 :   ret = GNUNET_OK;
      33          309 :   switch (auth->method)
      34              :   {
      35           43 :   case TALER_BANK_AUTH_NONE:
      36           43 :     return GNUNET_OK;
      37          266 :   case TALER_BANK_AUTH_BASIC:
      38              :     {
      39              :       char *up;
      40              : 
      41          266 :       GNUNET_asprintf (&up,
      42              :                        "%s:%s",
      43          266 :                        auth->details.basic.username,
      44          266 :                        auth->details.basic.password);
      45          266 :       if ( (CURLE_OK !=
      46          266 :             curl_easy_setopt (easy,
      47              :                               CURLOPT_HTTPAUTH,
      48          266 :                               CURLAUTH_BASIC)) ||
      49              :            (CURLE_OK !=
      50          266 :             curl_easy_setopt (easy,
      51              :                               CURLOPT_USERPWD,
      52              :                               up)) )
      53            0 :         ret = GNUNET_SYSERR;
      54          266 :       GNUNET_free (up);
      55          266 :       break;
      56              :     }
      57            0 :   case TALER_BANK_AUTH_BEARER:
      58              :     {
      59            0 :       if ( (CURLE_OK !=
      60            0 :             curl_easy_setopt (easy,
      61              :                               CURLOPT_HTTPAUTH,
      62            0 :                               CURLAUTH_BEARER)) ||
      63              :            (CURLE_OK !=
      64            0 :             curl_easy_setopt (easy,
      65              :                               CURLOPT_XOAUTH2_BEARER,
      66              :                               auth->details.bearer.token)) )
      67            0 :         ret = GNUNET_SYSERR;
      68            0 :       break;
      69              :     }
      70              :   }
      71          266 :   return ret;
      72              : }
      73              : 
      74              : 
      75              : /* end of bank_api_common.c */
        

Generated by: LCOV version 2.0-1