[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: get test_anastasis_api to pass
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: get test_anastasis_api to pass |
Date: |
Sun, 14 Feb 2021 14:28:44 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new ddd8b10 get test_anastasis_api to pass
ddd8b10 is described below
commit ddd8b1057cff55bde6ec1704dc423f3e6749ebe7
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Feb 14 14:28:42 2021 +0100
get test_anastasis_api to pass
---
.../anastasis_authorization_plugin_file.c | 19 +++++++-----
.../anastasis_authorization_plugin_sms.c | 3 ++
src/backend/anastasis-httpd_truth.c | 4 +++
src/stasis/plugin_anastasis_postgres.c | 10 +++----
src/testing/test_anastasis_api.c | 24 ++++++++++++---
src/testing/testing_api_cmd_keyshare_lookup.c | 35 +++++++++++-----------
src/testing/testing_api_cmd_truth_store.c | 12 +++++++-
7 files changed, 72 insertions(+), 35 deletions(-)
diff --git a/src/authorization/anastasis_authorization_plugin_file.c
b/src/authorization/anastasis_authorization_plugin_file.c
index 8c8790b..a9fe607 100644
--- a/src/authorization/anastasis_authorization_plugin_file.c
+++ b/src/authorization/anastasis_authorization_plugin_file.c
@@ -29,9 +29,9 @@
struct ANASTASIS_AUTHORIZATION_State
{
/**
- * Public key of the challenge which is authorised
+ * UUID of the challenge which is authorised
*/
- const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_public_key;
+ struct ANASTASIS_CRYPTO_TruthUUIDP truth_uuid;
/**
* Code which is sent to the user (here saved into a file)
@@ -105,7 +105,7 @@ file_validate (void *cls,
* @param cls closure
* @param trigger function to call when we made progress
* @param trigger_cls closure for @a trigger
- * @param truth_public_key Identifier of the challenge, to be (if possible)
included in the
+ * @param truth_uuid Identifier of the challenge, to be (if possible) included
in the
* interaction with the user
* @param code secret code that the user has to provide back to satisfy the
challenge in
* the main anastasis protocol
@@ -116,7 +116,7 @@ static struct ANASTASIS_AUTHORIZATION_State *
file_start (void *cls,
GNUNET_SCHEDULER_TaskCallback trigger,
void *trigger_cls,
- const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_public_key,
+ const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid,
uint64_t code,
const void *data,
size_t data_length)
@@ -125,10 +125,10 @@ file_start (void *cls,
as = GNUNET_new (struct ANASTASIS_AUTHORIZATION_State);
as->cls = cls;
- as->truth_public_key = truth_public_key;
+ as->truth_uuid = *truth_uuid;
as->code = code;
- as->filename = GNUNET_STRINGS_data_to_string_alloc (data,
- data_length);
+ as->filename = GNUNET_strndup (data,
+ data_length);
return as;
}
@@ -195,7 +195,7 @@ file_process (struct ANASTASIS_AUTHORIZATION_State *as,
char *response;
MHD_RESULT mres;
- /* FIXME: internationalization, etc. */
+ /* FIXME: internationalization, mention UUID, etc. */
response_size = GNUNET_asprintf (&response,
"Challenge written to file");
resp = MHD_create_response_from_buffer (response_size,
@@ -239,6 +239,9 @@ libanastasis_plugin_authorization_file_init (void *cls)
struct ANASTASIS_AuthorizationPlugin *plugin;
plugin = GNUNET_new (struct ANASTASIS_AuthorizationPlugin);
+ plugin->code_validity_period = GNUNET_TIME_UNIT_MINUTES;
+ plugin->code_rotation_period = GNUNET_TIME_UNIT_MINUTES;
+ plugin->code_retransmission_frequency = GNUNET_TIME_UNIT_MINUTES;
plugin->validate = &file_validate;
plugin->start = &file_start;
plugin->process = &file_process;
diff --git a/src/authorization/anastasis_authorization_plugin_sms.c
b/src/authorization/anastasis_authorization_plugin_sms.c
index 939c55a..a2075fd 100644
--- a/src/authorization/anastasis_authorization_plugin_sms.c
+++ b/src/authorization/anastasis_authorization_plugin_sms.c
@@ -449,6 +449,9 @@ libanastasis_plugin_authorization_sms_init (void *cls)
}
}
plugin = GNUNET_new (struct ANASTASIS_AuthorizationPlugin);
+ plugin->code_validity_period = GNUNET_TIME_UNIT_DAYS;
+ plugin->code_rotation_period = GNUNET_TIME_UNIT_HOURS;
+ plugin->code_retransmission_frequency = GNUNET_TIME_UNIT_MINUTES;
plugin->cls = ctx;
plugin->validate = &sms_validate;
plugin->start = &sms_start;
diff --git a/src/backend/anastasis-httpd_truth.c
b/src/backend/anastasis-httpd_truth.c
index d241c3c..c7decb0 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -943,6 +943,8 @@ AH_handler_truth_get (
switch (cs)
{
case ANASTASIS_DB_CODE_STATUS_CHALLENGE_CODE_MISMATCH:
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Provided response does not match our stored challenge\n");
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN,
TALER_EC_ANASTASIS_TRUTH_CHALLENGE_FAILED,
@@ -955,6 +957,8 @@ AH_handler_truth_get (
TALER_EC_GENERIC_DB_FETCH_FAILED,
"verify_challenge_code");
case ANASTASIS_DB_CODE_STATUS_NO_RESULTS:
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "No challenge known\n");
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_GONE,
TALER_EC_ANASTASIS_TRUTH_CHALLENGE_UNKNOWN,
diff --git a/src/stasis/plugin_anastasis_postgres.c
b/src/stasis/plugin_anastasis_postgres.c
index 622b9cb..7653cf1 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -1346,7 +1346,7 @@ struct CheckValidityContext
/**
* Truth we are processing.
*/
- const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_pub;
+ const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid;
/**
* Database context.
@@ -1416,7 +1416,7 @@ check_valid_code (void *cls,
{
/* count failures to prevent brute-force attacks */
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (cvc->truth_pub),
+ GNUNET_PQ_query_param_auto_from_type (cvc->truth_uuid),
GNUNET_PQ_query_param_uint64 (&server_code),
GNUNET_PQ_query_param_end
};
@@ -1449,18 +1449,18 @@ check_valid_code (void *cls,
enum ANASTASIS_DB_CodeStatus
postgres_verify_challenge_code (
void *cls,
- const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_pub,
+ const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid,
const struct GNUNET_HashCode *hashed_code)
{
struct PostgresClosure *pg = cls;
struct CheckValidityContext cvc = {
- .truth_pub = truth_pub,
+ .truth_uuid = truth_uuid,
.hashed_code = hashed_code,
.pg = pg
};
struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (truth_pub),
+ GNUNET_PQ_query_param_auto_from_type (truth_uuid),
TALER_PQ_query_param_absolute_time (&now),
GNUNET_PQ_query_param_end
};
diff --git a/src/testing/test_anastasis_api.c b/src/testing/test_anastasis_api.c
index d0d1cb5..d8e074c 100644
--- a/src/testing/test_anastasis_api.c
+++ b/src/testing/test_anastasis_api.c
@@ -36,7 +36,6 @@
*/
#define EXCHANGE_URL "http://localhost:8081/"
-
/**
* Account number of the exchange at the bank.
*/
@@ -97,6 +96,10 @@ static struct GNUNET_OS_Process *merchantd;
*/
static struct GNUNET_OS_Process *anastasisd;
+/**
+ * Name of the file for exchanging the secret.
+ */
+static char *file_secret;
/**
* Execute the taler-exchange-wirewatch command with our configuration
@@ -218,8 +221,8 @@ run (void *cls,
NULL,
"file",
"text/plain",
- strlen ("file-secret"),
- "file-secret",
+ strlen (file_secret),
+ file_secret,
ANASTASIS_TESTING_TSO_NONE,
MHD_HTTP_NO_CONTENT),
ANASTASIS_TESTING_cmd_keyshare_lookup (
@@ -331,6 +334,20 @@ main (int argc,
"exchange-account-exchange",
&bc))
return 77;
+ {
+ char dir[] = "/tmp/test-anastasis-file-XXXXXX";
+
+ if (NULL == mkdtemp (dir))
+ {
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
+ "mkdtemp",
+ dir);
+ return 77;
+ }
+ GNUNET_asprintf (&file_secret,
+ "%s/.secret",
+ dir);
+ }
payer_payto = ("payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME);
exchange_payto = ("payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME);
merchant_payto = ("payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME);
@@ -353,7 +370,6 @@ main (int argc,
return 1;
case GNUNET_NO:
return 77;
-
case GNUNET_OK:
if (NULL == (merchantd =
TALER_TESTING_run_merchant (CONFIG_FILE,
diff --git a/src/testing/testing_api_cmd_keyshare_lookup.c
b/src/testing/testing_api_cmd_keyshare_lookup.c
index 48ca623..ad8527f 100644
--- a/src/testing/testing_api_cmd_keyshare_lookup.c
+++ b/src/testing/testing_api_cmd_keyshare_lookup.c
@@ -99,14 +99,15 @@ struct KeyShareLookupState
char *instructions;
/**
- * Mode for the lookup(0 = question, 1 = code based)
+ * Name of the file where the service will write the challenge, if method is
"file".
+ * Otherwise NULL.
*/
- int lookup_mode;
+ char *filename;
/**
- * True if the authentication method is 'file'.
+ * Mode for the lookup(0 = question, 1 = code based)
*/
- bool is_file;
+ int lookup_mode;
};
@@ -153,18 +154,18 @@ keyshare_lookup_cb (void *cls,
break;
case ANASTASIS_KSD_INVALID_ANSWER:
- if (ksls->is_file)
+ if (ksls->filename)
{
FILE *file;
char code[22];
- file = fopen (dd->details.open_challenge.instructions,
+ file = fopen (ksls->filename,
"r");
if (NULL == file)
{
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
"open",
- dd->details.open_challenge.instructions);
+ ksls->filename);
TALER_TESTING_interpreter_fail (ksls->is);
return;
}
@@ -174,13 +175,16 @@ keyshare_lookup_cb (void *cls,
{
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
"fscanf",
- dd->details.open_challenge.instructions);
+ ksls->filename);
GNUNET_break (0 == fclose (file));
TALER_TESTING_interpreter_fail (ksls->is);
return;
}
GNUNET_break (0 == fclose (file));
ksls->code = GNUNET_strdup (code);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Read code `%s'\n",
+ code);
}
else
{
@@ -233,19 +237,19 @@ keyshare_lookup_run (void *cls,
return;
}
{
- const char *method;
+ const char *fn;
if (GNUNET_OK !=
TALER_TESTING_get_trait_string (upload_cmd,
0,
- &method))
+ &fn))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (ksls->is);
return;
}
- ksls->is_file = (0 == strcasecmp (method,
- "file"));
+ if (NULL != fn)
+ ksls->filename = GNUNET_strdup (fn);
}
if (GNUNET_OK !=
ANASTASIS_TESTING_get_trait_truth_uuid (upload_cmd,
@@ -300,15 +304,12 @@ keyshare_lookup_run (void *cls,
TALER_TESTING_interpreter_fail (ksls->is);
return;
}
- if (NULL == ksls->answer)
+ if (NULL == answer)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (ksls->is);
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Answer from trait: %s\n",
- answer);
}
else
{
@@ -350,7 +351,7 @@ keyshare_lookup_run (void *cls,
truth_uuid,
truth_key,
payment_secret,
- (NULL != ksls->answer)
+ (NULL != answer)
? &h_answer
: NULL,
&keyshare_lookup_cb,
diff --git a/src/testing/testing_api_cmd_truth_store.c
b/src/testing/testing_api_cmd_truth_store.c
index 6eb3a09..bc3297a 100644
--- a/src/testing/testing_api_cmd_truth_store.c
+++ b/src/testing/testing_api_cmd_truth_store.c
@@ -85,6 +85,11 @@ struct TruthStoreState
*/
void *truth_data;
+ /**
+ * Name of the file where the service will write the challenge, or NULL.
+ */
+ char *filename;
+
/**
* Expected status code.
*/
@@ -334,6 +339,7 @@ truth_store_cleanup (void *cls,
}
GNUNET_free (tss->truth_data);
GNUNET_free (tss->pay_uri);
+ GNUNET_free (tss->filename);
GNUNET_free (tss);
}
@@ -366,7 +372,7 @@ truth_store_traits (void *cls,
TALER_TESTING_make_trait_url (TALER_TESTING_UT_TALER_URL,
tss->pay_uri),
TALER_TESTING_make_trait_string (0,
- tss->method),
+ tss->filename),
TALER_TESTING_trait_end ()
};
@@ -403,6 +409,10 @@ ANASTASIS_TESTING_cmd_truth_store (const char *label,
tss->truth_data = GNUNET_memdup (truth_data,
truth_data_size);
tss->truth_data_size = truth_data_size;
+ if (0 == strcasecmp (method,
+ "file"))
+ tss->filename = GNUNET_strndup (truth_data,
+ truth_data_size);
{
struct TALER_TESTING_Command cmd = {
.cls = tss,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: get test_anastasis_api to pass,
gnunet <=