donau

Donation authority for GNU Taler (experimental)
Log | Files | Refs | Submodules | README | LICENSE

commit ec58ff7406578940de826747dd3b14414b7b2825
parent 3fbd9fa650a74eeb0b438f7e2af77b788d00a880
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
Date:   Tue, 12 Mar 2024 09:18:17 +0100

[testing] load and use BASE_URL from config file

Diffstat:
Msrc/include/donau_testing_lib.h | 4+---
Msrc/testing/test_donau_api.c | 15+++------------
Msrc/testing/testing_api_cmd_charities_get.c | 2+-
Msrc/testing/testing_api_cmd_charity_delete.c | 2+-
Msrc/testing/testing_api_cmd_charity_get.c | 2+-
Msrc/testing/testing_api_cmd_charity_post.c | 2+-
Msrc/testing/testing_api_cmd_get_donau.c | 88+++++++++++++++++++++++++++++++++----------------------------------------------
Msrc/testing/testing_api_loop.c | 29++++++++++++++++++++---------
8 files changed, 65 insertions(+), 79 deletions(-)

diff --git a/src/include/donau_testing_lib.h b/src/include/donau_testing_lib.h @@ -47,9 +47,7 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_get_donau ( const char *label, const struct GNUNET_CONFIGURATION_Handle *cfg, - // const char *last_keys_ref, - bool wait_for_keys, - bool load_private_key); + bool wait_for_keys); /** * Create a GET "charity" command. diff --git a/src/testing/test_donau_api.c b/src/testing/test_donau_api.c @@ -67,24 +67,15 @@ run (void *cls, const struct DONAU_BearerToken bearer = { .token = NULL }; -// struct DONAU_CharityRequest charity_req = { -// .charity_pub = {{"EBETNXT9ZF606FRF3WD5N6G2XVD5QHDP2PTQD4GSX4VEN2YYG2C0"}}, -// .name = "example", -// .charity_url = "example.com", -// .max_per_year = {"EUR:10"}, -// .receipts_to_date = {"EUR:0"}, -// .current_year = 2024 -// }; { struct TALER_TESTING_Command commands[] = { TALER_TESTING_cmd_system_start ("start-donau", config_file, "-D", NULL), -// TALER_TESTING_cmd_get_donau ("get-donau", -// cred.cfg, -// true, -// true), + TALER_TESTING_cmd_get_donau ("get-donau", + cred.cfg, + true), TALER_TESTING_cmd_charity_post ("post-charity", "example", "example.com", diff --git a/src/testing/testing_api_cmd_charities_get.c b/src/testing/testing_api_cmd_charities_get.c @@ -105,7 +105,7 @@ status_run (void *cls, ss->cgh = DONAU_charities_get ( TALER_TESTING_interpreter_get_context (is), - "http://localhost:8080/", //TODO: TALER_TESTING_get_donau_url (is), + TALER_TESTING_get_donau_url (is), ss->bearer, &charities_status_cb, ss); diff --git a/src/testing/testing_api_cmd_charity_delete.c b/src/testing/testing_api_cmd_charity_delete.c @@ -135,7 +135,7 @@ status_run (void *cls, ss->cgh = DONAU_charity_delete ( TALER_TESTING_interpreter_get_context (is), - "http://localhost:8080/", //TODO: TALER_TESTING_get_donau_url (is), + TALER_TESTING_get_donau_url (is), ss->charity_id, ss->bearer, &charity_status_cb, diff --git a/src/testing/testing_api_cmd_charity_get.c b/src/testing/testing_api_cmd_charity_get.c @@ -134,7 +134,7 @@ status_run (void *cls, ss->cgh = DONAU_charity_get ( TALER_TESTING_interpreter_get_context (is), - "http://localhost:8080/", //TODO: TALER_TESTING_get_donau_url (is), + TALER_TESTING_get_donau_url (is), ss->charity_id, ss->bearer, &charity_status_cb, diff --git a/src/testing/testing_api_cmd_charity_post.c b/src/testing/testing_api_cmd_charity_post.c @@ -122,7 +122,7 @@ status_run (void *cls, ss->cph = DONAU_charity_post ( TALER_TESTING_interpreter_get_context (is), - "http://localhost:8080/", // TODO: TALER_TESTING_get_donau_url (is), + TALER_TESTING_get_donau_url (is), &ss->charity_req, ss->bearer, &charity_status_cb, diff --git a/src/testing/testing_api_cmd_get_donau.c b/src/testing/testing_api_cmd_get_donau.c @@ -75,34 +75,37 @@ cert_cb (void *cls, struct DONAU_Keys *keys) { struct GetDonauState *ges = cls; - const struct DONAU_HttpResponse *hr = &kr->hr; + //const struct DONAU_HttpResponse *hr = &kr->hr; struct TALER_TESTING_Interpreter *is = ges->is; ges->donau = NULL; ges->keys = keys; - switch (hr->http_status) - { - case MHD_HTTP_OK: - if (ges->wait_for_keys) - { - ges->wait_for_keys = false; - TALER_TESTING_interpreter_next (is); - return; - } - return; - default: - GNUNET_break (0); - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "/keys responded with HTTP status %u\n", - hr->http_status); - if (ges->wait_for_keys) - { - ges->wait_for_keys = false; - TALER_TESTING_interpreter_fail (is); - return; - } - return; - } +// switch (hr->http_status) +// { +// case MHD_HTTP_OK: +// if (ges->wait_for_keys) +// { +// ges->wait_for_keys = false; +// TALER_TESTING_interpreter_next (is); +// return; +// } +// return; +// default: +// GNUNET_break (0); +// GNUNET_log (GNUNET_ERROR_TYPE_WARNING, +// "/keys responded with HTTP status %u\n", +// hr->http_status); +// if (ges->wait_for_keys) +// { +// ges->wait_for_keys = false; +// TALER_TESTING_interpreter_fail (is); +// return; +// } +// return; +// } + + TALER_TESTING_interpreter_next (is); // to delete... only temporary + return; } @@ -186,33 +189,17 @@ get_donau_traits (void *cls, unsigned int index) { struct GetDonauState *ges = cls; - // unsigned int off = (NULL == ges->master_priv_file) ? 1 : 0; - unsigned int off = 1; - if (NULL != ges->keys) - { - struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_donau_url (ges->donau_url), - TALER_TESTING_trait_end () - }; + struct TALER_TESTING_Trait traits[] = { + TALER_TESTING_make_trait_donau_url (ges->donau_url), + TALER_TESTING_trait_end () + }; - return TALER_TESTING_get_trait (&traits[off], - ret, - trait, - index); - } - else - { - struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_donau_url (ges->donau_url), - TALER_TESTING_trait_end () - }; + return TALER_TESTING_get_trait (traits, + ret, + trait, + index); - return TALER_TESTING_get_trait (&traits[off], - ret, - trait, - index); - } } @@ -226,7 +213,7 @@ static char * get_donau_base_url ( const struct GNUNET_CONFIGURATION_Handle *cfg) { - char *donau_url; // = "http://localhost:8080/"; + char *donau_url;// = "http://localhost:8080/"; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, @@ -247,8 +234,7 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_get_donau ( const char *label, const struct GNUNET_CONFIGURATION_Handle *cfg, - bool wait_for_keys, - bool load_private_key) + bool wait_for_keys) { struct GetDonauState *ges; diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c @@ -45,15 +45,26 @@ DONAU_TESTING_main (char *const *argv, GNUNET_log_setup (argv[0], loglevel, NULL); - //if (GNUNET_OK != - // TALER_TESTING_get_credentials (cfg_file, - // exchange_account_section, - // bs, - // cred)) - //{ - // GNUNET_break (0); - // return 77; - //} + cred->cfg = GNUNET_CONFIGURATION_create (); + if (GNUNET_OK != + GNUNET_CONFIGURATION_load (cred->cfg, + cfg_file)) + { + GNUNET_break (0); + GNUNET_CONFIGURATION_destroy (cred->cfg); + return GNUNET_SYSERR; + } + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (cred->cfg, + "donau", + "BASE_URL", + &cred->exchange_url)) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "donau", + "BASE_URL"); + return GNUNET_SYSERR; + } // if (GNUNET_OK != // TALER_TESTING_cleanup_files_cfg (NULL, // cred->cfg))