LCOV - code coverage report
Current view: top level - lib - test_merchant_api_common.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 58 58
Test Date: 2025-10-31 14:20:14 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :   This file is part of TALER
       3              :   (C) 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 <http://www.gnu.org/licenses/>
      15              : */
      16              : 
      17              : /**
      18              :  * @file util/test_merchant_api_common.c
      19              :  * @brief Unit test for test_merchant_api_common.c
      20              :  * @author Florian Dold
      21              :  */
      22              : #include "platform.h"
      23              : #include "taler_merchant_service.h"
      24              : 
      25              : 
      26              : int
      27            1 : main (int argc,
      28              :       const char *const argv[])
      29              : {
      30              :   struct TALER_MERCHANT_PayUriData pd;
      31              :   struct TALER_MERCHANT_RefundUriData rd;
      32              : 
      33              :   (void) argc;
      34              :   (void) argv;
      35            1 :   GNUNET_log_setup ("test_merchant_api_common",
      36              :                     "WARNING",
      37              :                     NULL);
      38              :   /* test pay parser */
      39            1 :   GNUNET_assert (GNUNET_SYSERR ==
      40              :                  TALER_MERCHANT_parse_pay_uri (
      41              :                    "http://pay/localhost/my-order",
      42              :                    &pd));
      43            1 :   GNUNET_assert (GNUNET_SYSERR ==
      44              :                  TALER_MERCHANT_parse_pay_uri (
      45              :                    "taler://pay/localhost/my-order",
      46              :                    &pd));
      47            1 :   GNUNET_assert (GNUNET_SYSERR ==
      48              :                  TALER_MERCHANT_parse_pay_uri (
      49              :                    "taler://refund/localhost/my-order/",
      50              :                    &pd));
      51            1 :   GNUNET_assert (GNUNET_OK ==
      52              :                  TALER_MERCHANT_parse_pay_uri (
      53              :                    "taler://PAY/localhost/my-order/",
      54              :                    &pd));
      55            1 :   GNUNET_assert (0 == strcmp (pd.merchant_host,
      56              :                               "localhost"));
      57            1 :   GNUNET_assert (NULL == pd.merchant_prefix_path);
      58            1 :   GNUNET_assert (0 == strcmp (pd.order_id,
      59              :                               "my-order"));
      60            1 :   GNUNET_assert (NULL == pd.session_id);
      61            1 :   GNUNET_assert (NULL == pd.claim_token);
      62            1 :   GNUNET_assert (NULL == pd.ssid);
      63            1 :   GNUNET_assert (! pd.use_http);
      64            1 :   TALER_MERCHANT_parse_pay_uri_free (&pd);
      65              : 
      66            1 :   GNUNET_assert (GNUNET_OK ==
      67              :                  TALER_MERCHANT_parse_pay_uri (
      68              :                    "taler://pay/localhost/my-order/#myssid",
      69              :                    &pd));
      70            1 :   GNUNET_assert (0 == strcmp (pd.merchant_host,
      71              :                               "localhost"));
      72            1 :   GNUNET_assert (0 == strcmp (pd.order_id,
      73              :                               "my-order"));
      74            1 :   GNUNET_assert (NULL == pd.session_id);
      75            1 :   GNUNET_assert (NULL == pd.claim_token);
      76            1 :   GNUNET_assert (0 == strcmp (pd.ssid,
      77              :                               "myssid"));
      78            1 :   GNUNET_assert (! pd.use_http);
      79            1 :   TALER_MERCHANT_parse_pay_uri_free (&pd);
      80              : 
      81            1 :   GNUNET_assert (GNUNET_OK ==
      82              :                  TALER_MERCHANT_parse_pay_uri (
      83              :                    "taler+http://pay/localhost/instance/foo/my-order/my-session#myssid",
      84              :                    &pd));
      85            1 :   GNUNET_assert (0 == strcmp (pd.merchant_host,
      86              :                               "localhost"));
      87            1 :   GNUNET_assert (0 == strcmp (pd.merchant_prefix_path,
      88              :                               "instance/foo"));
      89            1 :   GNUNET_assert (0 == strcmp (pd.order_id,
      90              :                               "my-order"));
      91            1 :   GNUNET_assert (0 == strcmp (pd.session_id,
      92              :                               "my-session"));
      93            1 :   GNUNET_assert (NULL == pd.claim_token);
      94            1 :   GNUNET_assert (0 == strcmp (pd.ssid,
      95              :                               "myssid"));
      96            1 :   GNUNET_assert (pd.use_http);
      97            1 :   TALER_MERCHANT_parse_pay_uri_free (&pd);
      98              : 
      99            1 :   GNUNET_assert (GNUNET_OK ==
     100              :                  TALER_MERCHANT_parse_pay_uri (
     101              :                    "taler+http://pay/localhost/my-order/my-session?c=3QV8F3W34Y1FX6R8P2JZNMQ2JQ#myssid",
     102              :                    &pd));
     103            1 :   GNUNET_assert (0 == strcmp (pd.merchant_host,
     104              :                               "localhost"));
     105            1 :   GNUNET_assert (NULL == pd.merchant_prefix_path);
     106            1 :   GNUNET_assert (0 == strcmp (pd.order_id,
     107              :                               "my-order"));
     108            1 :   GNUNET_assert (0 == strcmp (pd.session_id,
     109              :                               "my-session"));
     110            1 :   GNUNET_assert (NULL != pd.claim_token);
     111            1 :   GNUNET_assert (0 == strcmp (pd.ssid,
     112              :                               "myssid"));
     113            1 :   GNUNET_assert (pd.use_http);
     114            1 :   TALER_MERCHANT_parse_pay_uri_free (&pd);
     115              : 
     116              : 
     117              :   /* test refund parser */
     118            1 :   GNUNET_assert (GNUNET_SYSERR ==
     119              :                  TALER_MERCHANT_parse_refund_uri (
     120              :                    "http://refund/localhost/my-order/",
     121              :                    &rd));
     122            1 :   GNUNET_assert (GNUNET_SYSERR ==
     123              :                  TALER_MERCHANT_parse_refund_uri (
     124              :                    "taler://refund/localhost/my-order",
     125              :                    &rd));
     126            1 :   GNUNET_assert (GNUNET_SYSERR ==
     127              :                  TALER_MERCHANT_parse_refund_uri (
     128              :                    "taler://pay/localhost/my-order/",
     129              :                    &rd));
     130              : 
     131            1 :   GNUNET_assert (GNUNET_OK ==
     132              :                  TALER_MERCHANT_parse_refund_uri (
     133              :                    "taler://refund/localhost/my-order/#myssid",
     134              :                    &rd));
     135            1 :   GNUNET_assert (0 == strcmp (rd.merchant_host,
     136              :                               "localhost"));
     137            1 :   GNUNET_assert (NULL == pd.merchant_prefix_path);
     138            1 :   GNUNET_assert (0 == strcmp (rd.order_id,
     139              :                               "my-order"));
     140            1 :   GNUNET_assert (0 == strcmp (rd.ssid,
     141              :                               "myssid"));
     142            1 :   GNUNET_assert (! rd.use_http);
     143            1 :   TALER_MERCHANT_parse_refund_uri_free (&rd);
     144              : 
     145            1 :   GNUNET_assert (GNUNET_OK ==
     146              :                  TALER_MERCHANT_parse_refund_uri (
     147              :                    "taler+http://REFUND/localhost/instance/foo/my-order/",
     148              :                    &rd));
     149            1 :   GNUNET_assert (0 == strcmp (rd.merchant_host,
     150              :                               "localhost"));
     151            1 :   GNUNET_assert (0 == strcmp ("instance/foo",
     152              :                               rd.merchant_prefix_path));
     153            1 :   GNUNET_assert (0 == strcmp (rd.order_id,
     154              :                               "my-order"));
     155            1 :   GNUNET_assert (NULL == rd.ssid);
     156            1 :   GNUNET_assert (rd.use_http);
     157            1 :   TALER_MERCHANT_parse_refund_uri_free (&rd);
     158              : 
     159            1 :   return 0;
     160              : }
     161              : 
     162              : 
     163              : /* end of test_merchant_api_common.c */
        

Generated by: LCOV version 2.0-1