challenger

OAuth 2.0-based authentication service that validates user can receive messages at a certain address
Log | Files | Refs | Submodules | README | LICENSE

commit 233a935497745df0c311c671557389a728164dd9
parent 862bee5625ee13bb829e5641dee9710ee2221f50
Author: Christian Grothoff <christian@grothoff.org>
Date:   Wed, 15 Nov 2023 23:18:43 +0100

-fix test

Diffstat:
Msrc/challenger/cat.sh | 2+-
Msrc/challenger/challenger-httpd_info.c | 7+++----
Msrc/challenger/challenger-httpd_solve.c | 9+++++++++
Msrc/challenger/test-challenger.sh | 12+++++++-----
Msrc/challengerdb/pg_info_get_token.c | 6+++---
Msrc/challengerdb/pg_info_get_token.h | 2+-
Msrc/include/challenger_database_plugin.h | 2+-
7 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/src/challenger/cat.sh b/src/challenger/cat.sh @@ -1,4 +1,4 @@ #!/bin/bash # This file is in the public domain. -cat - > "$1" +cat - > "$(echo $1 | jq -r ".filename")" exit 0 diff --git a/src/challenger/challenger-httpd_info.c b/src/challenger/challenger-httpd_info.c @@ -80,7 +80,7 @@ CH_handler_info (struct CH_HandlerContext *hc, /* Check token is valid */ { uint64_t id; - char *address; + json_t *address; enum GNUNET_DB_QueryStatus qs; struct GNUNET_TIME_Timestamp address_expiration; MHD_RESULT mret; @@ -115,13 +115,12 @@ CH_handler_info (struct CH_HandlerContext *hc, MHD_HTTP_OK, GNUNET_JSON_pack_uint64 ("id", id), - GNUNET_JSON_pack_string ("address", - address), + GNUNET_JSON_pack_object_steal ("address", + address), GNUNET_JSON_pack_string ("address_type", CH_address_type), GNUNET_JSON_pack_timestamp ("expires", address_expiration)); - GNUNET_free (address); return mret; } } diff --git a/src/challenger/challenger-httpd_solve.c b/src/challenger/challenger-httpd_solve.c @@ -175,6 +175,15 @@ CH_handler_solve (struct CH_HandlerContext *hc, return MHD_YES; return MHD_NO; } + if (NULL == bc->pin) + { + GNUNET_break_op (0); + return TALER_TEMPLATING_reply_error (hc->connection, + "invalid-request", + MHD_HTTP_BAD_REQUEST, + TALER_EC_GENERIC_PARAMETER_MISSING, + "pin"); + } { unsigned int pin; char dummy; diff --git a/src/challenger/test-challenger.sh b/src/challenger/test-challenger.sh @@ -61,7 +61,7 @@ echo " OK" CLIENT_ID=1 echo -n "Start challenger-httpd ..." -challenger-httpd -L INFO -c "${CONF}" &> httpd.log & +valgrind challenger-httpd -L INFO -c "${CONF}" &> httpd.log & # Wait for challenger to be available for n in $(seq 1 50) @@ -117,7 +117,7 @@ echo "OK" echo -n "Initiating address submission..." STATUS=$(curl "${BURL}/challenge/${NONCE}" \ -X POST \ - --data-urlencode "address=${FILENAME}" \ + --data-urlencode "filename=${FILENAME}" \ -w "%{http_code}" -s -o $LAST_RESPONSE) if [ "$STATUS" != "200" ] @@ -169,7 +169,7 @@ if [ "$STATUS" != "200" ] then exit_fail "Expected 200 OK. Got: $STATUS" $(cat $LAST_RESPONSE) fi -TOKEN_TYPE=$(cat $LAST_RESPONSE | jq -r .token_type) +TOKEN_TYPE="$(cat $LAST_RESPONSE | jq -r .token_type)" if [ "$TOKEN_TYPE" != "Bearer" ] then exit_fail "Expected Bearer token. Got: $TOKEN_TYPE" @@ -187,8 +187,10 @@ then exit_fail "Expected 200 OK. Got: $STATUS" $(cat $LAST_RESPONSE) fi -TADDRESS=$(cat $LAST_RESPONSE | jq -r .address) -TADDRESS_TYPE=$(cat $LAST_RESPONSE | jq -r .address_type) +cat $LAST_RESPONSE | jq + +TADDRESS=$(cat "$LAST_RESPONSE" | jq -r .address.filename) +TADDRESS_TYPE=$(cat "$LAST_RESPONSE" | jq -r .address_type) if [ "$TADDRESS" != "$FILENAME" ] then diff --git a/src/challengerdb/pg_info_get_token.c b/src/challengerdb/pg_info_get_token.c @@ -31,7 +31,7 @@ CH_PG_info_get_token ( void *cls, const struct CHALLENGER_AccessTokenP *token, uint64_t *rowid, - char **address, + json_t **address, struct GNUNET_TIME_Timestamp *address_expiration) { struct PostgresClosure *pg = cls; @@ -46,8 +46,8 @@ CH_PG_info_get_token ( struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("rowid", rowid), - GNUNET_PQ_result_spec_string ("address", - address), + TALER_PQ_result_spec_json ("address", + address), GNUNET_PQ_result_spec_absolute_time ("address_expiration_time", &at), GNUNET_PQ_result_spec_end diff --git a/src/challengerdb/pg_info_get_token.h b/src/challengerdb/pg_info_get_token.h @@ -41,7 +41,7 @@ CH_PG_info_get_token ( void *cls, const struct CHALLENGER_AccessTokenP *grant, uint64_t *rowid, - char **address, + json_t **address, struct GNUNET_TIME_Timestamp *address_expiration); diff --git a/src/include/challenger_database_plugin.h b/src/include/challenger_database_plugin.h @@ -356,7 +356,7 @@ struct CHALLENGER_DatabasePlugin (*info_get_token)(void *cls, const struct CHALLENGER_AccessTokenP *grant, uint64_t *rowid, - char **address, + json_t **address, struct GNUNET_TIME_Timestamp *address_expiration);