summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_auditor_add.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_auditor_add.c')
-rw-r--r--src/testing/testing_api_cmd_auditor_add.c86
1 files changed, 58 insertions, 28 deletions
diff --git a/src/testing/testing_api_cmd_auditor_add.c b/src/testing/testing_api_cmd_auditor_add.c
index e40e13194..ac9c2c8fb 100644
--- a/src/testing/testing_api_cmd_auditor_add.c
+++ b/src/testing/testing_api_cmd_auditor_add.c
@@ -18,7 +18,7 @@
*/
/**
* @file testing/testing_api_cmd_auditor_add.c
- * @brief command for testing /auditor_add.
+ * @brief command for testing auditor_add
* @author Christian Grothoff
*/
#include "platform.h"
@@ -62,27 +62,22 @@ struct AuditorAddState
* if the response code is acceptable.
*
* @param cls closure.
- * @param hr HTTP response details
+ * @param aer response details
*/
static void
-auditor_add_cb (void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr)
+auditor_add_cb (
+ void *cls,
+ const struct TALER_EXCHANGE_ManagementAuditorEnableResponse *aer)
{
struct AuditorAddState *ds = cls;
+ const struct TALER_EXCHANGE_HttpResponse *hr = &aer->hr;
ds->dh = NULL;
if (ds->expected_response_code != hr->http_status)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u to command %s in %s:%u\n",
- hr->http_status,
- ds->is->commands[ds->is->ip].label,
- __FILE__,
- __LINE__);
- json_dumpf (hr->reply,
- stderr,
- 0);
- TALER_TESTING_interpreter_fail (ds->is);
+ TALER_TESTING_unexpected_status (ds->is,
+ hr->http_status,
+ ds->expected_response_code);
return;
}
TALER_TESTING_interpreter_next (ds->is);
@@ -102,13 +97,45 @@ auditor_add_run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
struct AuditorAddState *ds = cls;
- struct GNUNET_TIME_Absolute now;
+ struct GNUNET_TIME_Timestamp now;
struct TALER_MasterSignatureP master_sig;
+ const struct TALER_AuditorPublicKeyP *auditor_pub;
+ const struct TALER_TESTING_Command *auditor_cmd;
+ const struct TALER_TESTING_Command *exchange_cmd;
+ const char *exchange_url;
+ const char *auditor_url;
(void) cmd;
- now = GNUNET_TIME_absolute_get ();
- (void) GNUNET_TIME_round_abs (&now);
+ now = GNUNET_TIME_timestamp_get ();
ds->is = is;
+
+ auditor_cmd = TALER_TESTING_interpreter_get_command (is,
+ "auditor");
+ if (NULL == auditor_cmd)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (is);
+ return;
+ }
+ GNUNET_assert (GNUNET_OK ==
+ TALER_TESTING_get_trait_auditor_pub (auditor_cmd,
+ &auditor_pub));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_TESTING_get_trait_auditor_url (auditor_cmd,
+ &auditor_url));
+ exchange_cmd = TALER_TESTING_interpreter_get_command (is,
+ "exchange");
+ if (NULL == exchange_cmd)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (is);
+ return;
+ }
+ GNUNET_assert (GNUNET_OK ==
+ TALER_TESTING_get_trait_exchange_url (exchange_cmd,
+ &exchange_url));
+
+
if (ds->bad_sig)
{
memset (&master_sig,
@@ -117,17 +144,22 @@ auditor_add_run (void *cls,
}
else
{
- TALER_exchange_offline_auditor_add_sign (&is->auditor_pub,
- is->auditor_url,
+ const struct TALER_MasterPrivateKeyP *master_priv;
+
+ GNUNET_assert (GNUNET_OK ==
+ TALER_TESTING_get_trait_master_priv (exchange_cmd,
+ &master_priv));
+ TALER_exchange_offline_auditor_add_sign (auditor_pub,
+ auditor_url,
now,
- &is->master_priv,
+ master_priv,
&master_sig);
}
ds->dh = TALER_EXCHANGE_management_enable_auditor (
- is->ctx,
- is->exchange_url,
- &is->auditor_pub,
- is->auditor_url,
+ TALER_TESTING_interpreter_get_context (is),
+ exchange_url,
+ auditor_pub,
+ auditor_url,
"test-case auditor", /* human-readable auditor name */
now,
&master_sig,
@@ -157,10 +189,8 @@ auditor_add_cleanup (void *cls,
if (NULL != ds->dh)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Command %u (%s) did not complete\n",
- ds->is->ip,
- cmd->label);
+ TALER_TESTING_command_incomplete (ds->is,
+ cmd->label);
TALER_EXCHANGE_management_enable_auditor_cancel (ds->dh);
ds->dh = NULL;
}