[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: fix truths initialization
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: fix truths initialization |
Date: |
Mon, 23 Nov 2020 15:45:21 +0100 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new c5945b0 fix truths initialization
c5945b0 is described below
commit c5945b007eb1ea670e5a655495e4bb0f6ab24a7d
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Mon Nov 23 15:45:17 2020 +0100
fix truths initialization
---
src/cli/Makefile.am | 3 +-
.../test_anastasis_reducer_done_authentication.sh | 4 +-
...> test_anastasis_reducer_done_policy_review.sh} | 18 ++---
src/lib/anastasis_api_backup_redux.c | 93 ++++++++++++----------
4 files changed, 64 insertions(+), 54 deletions(-)
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
index d1769aa..fa3f1e2 100644
--- a/src/cli/Makefile.am
+++ b/src/cli/Makefile.am
@@ -15,7 +15,8 @@ check_SCRIPTS = \
test_anastasis_reducer_select_country.sh \
test_anastasis_reducer_enter_user_attributes.sh \
test_anastasis_reducer_add_authentication.sh \
- test_anastasis_reducer_done_authentication.sh
+ test_anastasis_reducer_done_authentication.sh \
+ test_anastasis_reducer_done_policy_review.sh
AM_TESTS_ENVIRONMENT=export
ANASTASIS_PREFIX=$${ANASTASIS_PREFIX:-@libdir@};export
PATH=$${ANASTASIS_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset
XDG_CONFIG_HOME;
diff --git a/src/cli/test_anastasis_reducer_done_authentication.sh
b/src/cli/test_anastasis_reducer_done_authentication.sh
index eb4e6ec..a0a693b 100755
--- a/src/cli/test_anastasis_reducer_done_authentication.sh
+++ b/src/cli/test_anastasis_reducer_done_authentication.sh
@@ -56,9 +56,9 @@ then
fi
ARRAY_LENGTH=`jq -r -e '.policies | length' < $VFILE`
-if test $ARRAY_LENGTH >= 3
+if test $ARRAY_LENGTH -lt 3
then
- exit_fail "Expected policy array to be >= 3, got $ARRAY_LENGTH"
+ exit_fail "Expected policy array length to be >= 3, got $ARRAY_LENGTH"
fi
exit 0
diff --git a/src/cli/test_anastasis_reducer_done_authentication.sh
b/src/cli/test_anastasis_reducer_done_policy_review.sh
similarity index 64%
copy from src/cli/test_anastasis_reducer_done_authentication.sh
copy to src/cli/test_anastasis_reducer_done_policy_review.sh
index eb4e6ec..ed9ceae 100755
--- a/src/cli/test_anastasis_reducer_done_authentication.sh
+++ b/src/cli/test_anastasis_reducer_done_policy_review.sh
@@ -26,9 +26,9 @@ function cleanup()
}
# Install cleanup handler (except for kill -9)
-UFILE=test_reducer_stateAESTATE_FINAL
+UFILE=test_reducer_statePRSTATE
# Tempfile used und deleted by other test
-VFILE=test_reducer_statePRSTATE
+VFILE=test_reducer_stateSESTATE
trap cleanup EXIT
@@ -41,24 +41,24 @@ echo " FOUND"
echo " "
echo "Beginning with actual reducer test"
-# Test done authentication in a backup state
+# Test done policy review in a backup state
echo " "
-echo "Test done authentication (next) in a backup state"
+echo "Test done policy review (next) in a backup state"
touch $VFILE
./anastasis-reducer -a \
'{}' \
next $UFILE $VFILE
STATE=`jq -r -e .backup_state < $VFILE`
-if test "$STATE" != "POLICIES_REVIEWING"
+if test "$STATE" != "SECRET_EDITING"
then
- exit_fail "Expected new state to be AUTHENTICATIONS_EDITING, got $STATE"
+ exit_fail "Expected new state to be SECRET_EDITING, got $STATE"
fi
-ARRAY_LENGTH=`jq -r -e '.policies | length' < $VFILE`
-if test $ARRAY_LENGTH >= 3
+ARRAY_LENGTH=`jq -r -e '.truths | length' < $VFILE`
+if test $ARRAY_LENGTH -lt 3
then
- exit_fail "Expected policy array to be >= 3, got $ARRAY_LENGTH"
+ exit_fail "Expected truths array length to be >= 3, got $ARRAY_LENGTH"
fi
exit 0
diff --git a/src/lib/anastasis_api_backup_redux.c
b/src/lib/anastasis_api_backup_redux.c
index 831f8e1..ad9022c 100644
--- a/src/lib/anastasis_api_backup_redux.c
+++ b/src/lib/anastasis_api_backup_redux.c
@@ -841,37 +841,6 @@ del_policy (json_t *state,
}
-/**
- * DispatchHandler/Callback function which is called for a
- * "done_policy_review" action.
- * Returns an #ANASTASIS_ReduxAction if operation is async.
- *
- * @param state state to operate on
- * @param arguments arguments to use for operation on state
- * @param ctx CURL context
- * @param cb callback (#DispatchHandler) to call during/after operation
- * @param cb_cls callback closure
- * @return NULL
- */
-static struct ANASTASIS_ReduxAction *
-done_policy_review (json_t *state,
- const json_t *arguments,
- struct GNUNET_CURL_Context *ctx,
- ANASTASIS_ActionCallback cb,
- void *cb_cls)
-{
- GNUNET_assert (NULL != state);
- set_state (state,
- ANASTASIS_backup_state_to_string (
- ANASTASIS_BACKUP_STATE_SECRET_EDITING));
-
- cb (cb_cls,
- ANASTASIS_EC_NONE,
- state);
- return NULL;
-}
-
-
/**
* Initialize data for #ANASTASIS_truth_upload.
*
@@ -902,12 +871,12 @@ initialize_truths (json_t *state)
json_array_foreach (policy_json_array, policy_index, policy)
{
size_t index;
- json_t *method;
+ json_t *policy_method;
json_t *policy_methods = json_object_get (policy,
"methods");
GNUNET_assert (json_is_array (policy_methods));
- json_array_foreach (policy_methods, index, method)
+ json_array_foreach (policy_methods, index, policy_method)
{
const char *instructions;
const char *mime_type;
@@ -918,7 +887,7 @@ initialize_truths (json_t *state)
json_t *check_truth;
json_t *supported_provider;
size_t auth_method_index = json_integer_value (
- json_object_get (method,
+ json_object_get (policy_method,
"authentication_method"));
json_t *auth_method = json_array_get (authentication_methods,
auth_method_index);
@@ -927,8 +896,9 @@ initialize_truths (json_t *state)
"method"));
json_t *truth_data = json_object_get (auth_method,
"data");
- const char *backend_id = json_string_value (json_object_get (method,
-
"provider"));
+ const char *backend_id = json_string_value (json_object_get (
+ policy_method,
+ "provider"));
json_t *supported_providers = json_object_get (provider_methods,
method);
@@ -939,12 +909,15 @@ initialize_truths (json_t *state)
json_t *provider_data =
json_object_get (supported_provider,
backend_id);
+
if (NULL != provider_data)
{
- backend_url = json_object_get (provider_data,
- "provider_url");
- backend_salt = json_string_value (json_object_get (provider_data,
- "provider_salt"));
+ backend_url = json_string_value (
+ json_object_get (provider_data,
+ "provider_url"));
+ backend_salt = json_string_value (
+ json_object_get (provider_data,
+ "provider_salt"));
break;
}
}
@@ -980,7 +953,6 @@ initialize_truths (json_t *state)
GNUNET_break (0);
return NULL;
}
-
json_t *truth = json_pack ("{s:I, s:s, s:s, s:s, s:o, s:s, s:s, s:s}",
"auth_method_index",
(json_int_t) auth_method_index,
@@ -996,7 +968,9 @@ initialize_truths (json_t *state)
instructions,
"mime_type",
mime_type,
- "backend_salt");
+ "backend_salt",
+ backend_salt);
+
// check if truths allready contains this truth
bool existing = false;
json_array_foreach (truths, check_index, check_truth)
@@ -1015,6 +989,41 @@ initialize_truths (json_t *state)
}
+/**
+ * DispatchHandler/Callback function which is called for a
+ * "done_policy_review" action.
+ * Returns an #ANASTASIS_ReduxAction if operation is async.
+ *
+ * @param state state to operate on
+ * @param arguments arguments to use for operation on state
+ * @param ctx CURL context
+ * @param cb callback (#DispatchHandler) to call during/after operation
+ * @param cb_cls callback closure
+ * @return NULL
+ */
+static struct ANASTASIS_ReduxAction *
+done_policy_review (json_t *state,
+ const json_t *arguments,
+ struct GNUNET_CURL_Context *ctx,
+ ANASTASIS_ActionCallback cb,
+ void *cb_cls)
+{
+ GNUNET_assert (NULL != state);
+ set_state (state,
+ ANASTASIS_backup_state_to_string (
+ ANASTASIS_BACKUP_STATE_SECRET_EDITING));
+
+ GNUNET_assert (0 ==
+ json_object_set (state,
+ "truths",
+ initialize_truths (state)));
+ cb (cb_cls,
+ ANASTASIS_EC_NONE,
+ state);
+ return NULL;
+}
+
+
/**
* Upload information
* caller MUST free 't' using ANASTASIS_truth_free()
--
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: fix truths initialization,
gnunet <=