LCOV - code coverage report
Current view: top level - bank-lib - bank_api_common.c (source / functions) Hit Total Coverage
Test: GNU Taler exchange coverage report Lines: 14 15 93.3 %
Date: 2022-08-25 06:15:09 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          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 "platform.h"
      23             : #include "bank_api_common.h"
      24             : 
      25             : 
      26             : enum GNUNET_GenericReturnValue
      27          22 : TALER_BANK_setup_auth_ (CURL *easy,
      28             :                         const struct TALER_BANK_AuthenticationData *auth)
      29             : {
      30             :   enum GNUNET_GenericReturnValue ret;
      31             : 
      32          22 :   ret = GNUNET_OK;
      33          22 :   switch (auth->method)
      34             :   {
      35          14 :   case TALER_BANK_AUTH_NONE:
      36          14 :     return GNUNET_OK;
      37           8 :   case TALER_BANK_AUTH_BASIC:
      38             :     {
      39             :       char *up;
      40             : 
      41           8 :       GNUNET_asprintf (&up,
      42             :                        "%s:%s",
      43             :                        auth->details.basic.username,
      44             :                        auth->details.basic.password);
      45           8 :       if ( (CURLE_OK !=
      46           8 :             curl_easy_setopt (easy,
      47             :                               CURLOPT_HTTPAUTH,
      48           8 :                               CURLAUTH_BASIC)) ||
      49             :            (CURLE_OK !=
      50           8 :             curl_easy_setopt (easy,
      51             :                               CURLOPT_USERPWD,
      52             :                               up)) )
      53           0 :         ret = GNUNET_SYSERR;
      54           8 :       GNUNET_free (up);
      55           8 :       break;
      56             :     }
      57             :   }
      58           8 :   return ret;
      59             : }
      60             : 
      61             : 
      62             : /* end of bank_api_common.c */

Generated by: LCOV version 1.14