LCOV - code coverage report
Current view: top level - testing - testing_api_trait_merchant_key.c (source / functions) Hit Total Coverage
Test: GNU Taler exchange coverage report Lines: 5 10 50.0 %
Date: 2021-08-30 06:43:37 Functions: 2 4 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   Copyright (C) 2018 Taler Systems SA
       4             : 
       5             :   TALER is free software; you can redistribute it and/or modify it
       6             :   under the terms of the GNU General Public License as published
       7             :   by the Free Software Foundation; either version 3, or (at your
       8             :   option) any later version.
       9             : 
      10             :   TALER is distributed in the hope that it will be useful, but
      11             :   WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13             :   General Public License for more details.
      14             : 
      15             :   You should have received a copy of the GNU General Public
      16             :   License along with TALER; see the file COPYING.  If not, see
      17             :   <http://www.gnu.org/licenses/>
      18             : */
      19             : /**
      20             :  * @file testing/testing_api_trait_merchant_key.c
      21             :  * @brief traits to offer peer's (private) keys
      22             :  * @author Marcello Stanisci
      23             :  */
      24             : #include "platform.h"
      25             : #include "taler_json_lib.h"
      26             : #include <gnunet/gnunet_curl_lib.h>
      27             : #include "taler_signatures.h"
      28             : #include "taler_testing_lib.h"
      29             : 
      30             : #define TALER_TESTING_TRAIT_MERCHANT_PRIV "merchant-priv"
      31             : #define TALER_TESTING_TRAIT_MERCHANT_PUB "merchant-pub-pub"
      32             : 
      33             : /**
      34             :  * Obtain a private key from a "peer".  Used e.g. to obtain
      35             :  * a merchant's priv to sign a /track request.
      36             :  *
      37             :  * @param cmd command that is offering the key.
      38             :  * @param index (typically zero) which key to return if there
      39             :  *        are multiple on offer.
      40             :  * @param[out] priv set to the key coming from @a cmd.
      41             :  * @return #GNUNET_OK on success.
      42             :  */
      43             : int
      44          16 : TALER_TESTING_get_trait_merchant_priv
      45             :   (const struct TALER_TESTING_Command *cmd,
      46             :   unsigned int index,
      47             :   const struct TALER_MerchantPrivateKeyP **priv)
      48             : {
      49          16 :   return cmd->traits (cmd->cls,
      50             :                       (const void **) priv,
      51             :                       TALER_TESTING_TRAIT_MERCHANT_PRIV,
      52             :                       index);
      53             : }
      54             : 
      55             : 
      56             : /**
      57             :  * Offer private key, typically done when CMD_1 needs it to
      58             :  * sign a request.
      59             :  *
      60             :  * @param index (typically zero) which key to return if there are
      61             :  *        multiple on offer.
      62             :  * @param priv which object should be offered.
      63             :  * @return the trait.
      64             :  */
      65             : struct TALER_TESTING_Trait
      66         160 : TALER_TESTING_make_trait_merchant_priv (unsigned int index,
      67             :                                         const struct
      68             :                                         TALER_MerchantPrivateKeyP *priv)
      69             : {
      70         160 :   struct TALER_TESTING_Trait ret = {
      71             :     .index = index,
      72             :     .trait_name = TALER_TESTING_TRAIT_MERCHANT_PRIV,
      73             :     .ptr = (const void *) priv
      74             :   };
      75             : 
      76         160 :   return ret;
      77             : }
      78             : 
      79             : 
      80             : /**
      81             :  * Obtain a public key from a "peer".  Used e.g. to obtain
      82             :  * a merchant's public key to use backend's API.
      83             :  *
      84             :  * @param cmd command offering the key.
      85             :  * @param index (typically zero) which key to return if there
      86             :  *        are multiple on offer.
      87             :  * @param[out] pub set to the key coming from @a cmd.
      88             :  * @return #GNUNET_OK on success.
      89             :  */
      90             : int
      91           0 : TALER_TESTING_get_trait_merchant_pub
      92             :   (const struct TALER_TESTING_Command *cmd,
      93             :   unsigned int index,
      94             :   const struct TALER_MerchantPublicKeyP **pub)
      95             : {
      96           0 :   return cmd->traits (cmd->cls,
      97             :                       (const void **) pub,
      98             :                       TALER_TESTING_TRAIT_MERCHANT_PUB,
      99             :                       index);
     100             : }
     101             : 
     102             : 
     103             : /**
     104             :  * Offer public key.
     105             :  *
     106             :  * @param index (typically zero) which key to return if there
     107             :  *        are multiple on offer.  NOTE: if one key is offered, it
     108             :  *        is mandatory to set this as zero.
     109             :  * @param pub which object should be returned.
     110             :  * @return the trait.
     111             :  */
     112             : struct TALER_TESTING_Trait
     113           0 : TALER_TESTING_make_trait_merchant_pub (unsigned int index,
     114             :                                        const struct
     115             :                                        TALER_MerchantPublicKeyP *pub)
     116             : {
     117           0 :   struct TALER_TESTING_Trait ret = {
     118             :     .index = index,
     119             :     .trait_name = TALER_TESTING_TRAIT_MERCHANT_PUB,
     120             :     .ptr = (const void *) pub
     121             :   };
     122             : 
     123           0 :   return ret;
     124             : }
     125             : 
     126             : 
     127             : /* end of testing_api_trait_merchant_key.c */

Generated by: LCOV version 1.14