From 398bda22748ab125e81db553ae4fe9cd5712aa28 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 8 Jul 2015 09:48:12 +0200 Subject: mint malformed request testing --- src/mint/test_taler_mint_httpd.data | 39 +++++++++++++++++++++++++++++++++++++ src/mint/test_taler_mint_httpd.sh | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 src/mint/test_taler_mint_httpd.data create mode 100755 src/mint/test_taler_mint_httpd.sh (limited to 'src/mint') diff --git a/src/mint/test_taler_mint_httpd.data b/src/mint/test_taler_mint_httpd.data new file mode 100644 index 000000000..16fbfd83a --- /dev/null +++ b/src/mint/test_taler_mint_httpd.data @@ -0,0 +1,39 @@ +# This file is part of TALER +# Copyright (C) 2015 GNUnet e.V. +# +# TALER is free software; you can redistribute it and/or modify it under the +# terms of the GNU Affero General Public License as published by the Free Software +# Foundation; either version 3, or (at your option) any later version. +# +# TALER is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License along with +# TALER; see the file COPYING. If not, If not, see +# +# +# This is a resource file for test_taler_mint_httpd.sh. +# Lines starting with '#' (must be first character in line) are comments. +# +# Each non-comment line must contain two strings, the first being the +# URL on the HTTP serve which a HTTP POST request should be made out +# two, followed by the JSON data to POST to the server. +# +# Note that neither element may contain any spaces! +# +# +# Bad amount: +/admin/add/incoming {"reserve_pub":"7RZBZ86677QMASD2KAYGEPD246C7B7RC6P101FNTG6ZK8X61A620","amount":"1","execution_date":"\/Date(1435934428788)\/","wire":{"empty":"empty"}} +# +# Bad wire format: +/admin/add/incoming {"reserve_pub":"6VRFYZRVHJ434BV3J018MS6H7Q1V5Q6YECNMEF9G4WKB8QJQCAX0","amount":{"currency":"EUR","value":10,"fraction":3},"execution_date":"\/Date(1436258333286)\/","wire":{"empty":"empty"}} +# +# Malformed JSON (ill-balanced quotes around 'amount') +/admin/add/incoming {"reserve_pub":"BSEFVVNZ4C3724BPVKTJMQMD73HQREA5FWSS1C1BZ36ZFF2WBTK0",amount":{"currency":"EUR","value":5,"fraction":3},"execution_date":"\/Date(1436271156447)\/","wire":{"type":"test","IBAN":0,"name":"Jack","BIC":999,"edate":"\/Date(1436271156447)\/","r":50}} +# +# Bad amount (value not a string) +/admin/add/incoming {"reserve_pub":"BSEFVVNZ4C3724BPVKTJMQMD73HQREA5FWSS1C1BZ36ZFF2WBTK0","amount":{"currency":"EUR","value":"5","fraction":3},"execution_date":"\/Date(1436271156447)\/","wire":{"type":"test","IBAN":0,"name":"Jack","BIC":999,"edate":"\/Date(1436271156447)\/","r":50}} +# +# Bad amount (overall amount is a string) +/admin/add/incoming {"reserve_pub":"BSEFVVNZ4C3724BPVKTJMQMD73HQREA5FWSS1C1BZ36ZFF2WBTK0","amount":"{\"currency\":\"EUR\",\"value\":5,\"fraction\":3}","execution_date":"\/Date(1436271156447)\/","wire":{"type":"test"}} diff --git a/src/mint/test_taler_mint_httpd.sh b/src/mint/test_taler_mint_httpd.sh new file mode 100755 index 000000000..b56706a16 --- /dev/null +++ b/src/mint/test_taler_mint_httpd.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# +# This file is part of TALER +# Copyright (C) 2015 GNUnet e.V. +# +# TALER is free software; you can redistribute it and/or modify it under the +# terms of the GNU Affero General Public License as published by the Free Software +# Foundation; either version 3, or (at your option) any later version. +# +# TALER is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License along with +# TALER; see the file COPYING. If not, If not, see +# +# +# This script uses 'curl' to POST various ill-formed requests to the +# taler-mint-httpd. Basically, the goal is to make sure that the +# HTTP server survives (and produces the 'correct' error code). +# +# We read the JSON snippets to POST from test_atler_mint_httpd.data +# +# Setup keys. +taler-mint-keyup -d test-mint-home -m test-mint-home/master.priv +# Run Mint HTTPD (in background) +taler-mint-httpd -d test-mint-home & +# Give HTTP time to start +sleep 2 +# Run test... +cat test_taler_mint_httpd.data | grep -v ^\# | awk '{ print "curl -d '\''" $2 "'\'' http://localhost:8081"$1 }' | bash +# Stop HTTP server +kill -TERM %% +# FIXME: not sure this is the 'correct' return code... +exit $? -- cgit v1.2.3