aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-12-11 09:33:01 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-12-23 11:29:52 +0000
commitf1bdc9a42a7d75f90cc0c1e4191f4ef1a016a11a (patch)
tree7867b606420df406a44c4ca5fa0852ecf44a1e83 /contrib
parentadd parse_url fuzz test (diff)
downloadmonero-f1bdc9a42a7d75f90cc0c1e4191f4ef1a016a11a.tar.xz
tests: add http client fuzz test
Diffstat (limited to 'contrib')
-rw-r--r--contrib/epee/include/net/http_client.h17
-rwxr-xr-xcontrib/fuzz_testing/fuzz.sh6
2 files changed, 17 insertions, 6 deletions
diff --git a/contrib/epee/include/net/http_client.h b/contrib/epee/include/net/http_client.h
index 1a9d5d064..5c448fcb3 100644
--- a/contrib/epee/include/net/http_client.h
+++ b/contrib/epee/include/net/http_client.h
@@ -236,7 +236,8 @@ namespace net_utils
namespace http
{
- class http_simple_client: public i_target_handler
+ template<typename net_client_type>
+ class http_simple_client_template: public i_target_handler
{
private:
enum reciev_machine_state
@@ -259,7 +260,7 @@ namespace net_utils
};
- blocked_mode_client m_net_client;
+ net_client_type m_net_client;
std::string m_host_buff;
std::string m_port;
http_client_auth m_auth;
@@ -276,7 +277,7 @@ namespace net_utils
bool m_ssl;
public:
- explicit http_simple_client()
+ explicit http_simple_client_template()
: i_target_handler()
, m_net_client()
, m_host_buff()
@@ -428,6 +429,15 @@ namespace net_utils
CRITICAL_REGION_LOCAL(m_lock);
return invoke(uri, "POST", body, timeout, ppresponse_info, additional_params);
}
+ //---------------------------------------------------------------------------
+ bool test(const std::string &s, std::chrono::milliseconds timeout) // TEST FUNC ONLY
+ {
+ CRITICAL_REGION_LOCAL(m_lock);
+ m_net_client.set_test_data(s);
+ m_state = reciev_machine_state_header;
+ return handle_reciev(timeout);
+ }
+ //---------------------------------------------------------------------------
private:
//---------------------------------------------------------------------------
inline bool handle_reciev(std::chrono::milliseconds timeout)
@@ -957,6 +967,7 @@ namespace net_utils
return true;
}
};
+ typedef http_simple_client_template<blocked_mode_client> http_simple_client;
}
}
}
diff --git a/contrib/fuzz_testing/fuzz.sh b/contrib/fuzz_testing/fuzz.sh
index 5be16a7d6..a97713510 100755
--- a/contrib/fuzz_testing/fuzz.sh
+++ b/contrib/fuzz_testing/fuzz.sh
@@ -10,12 +10,12 @@ fi
type="$1"
if test -z "$type"
then
- echo "usage: $0 block|transaction|signature|cold-outputs|cold-transaction|load-from-binary|load-from-json|base58|parse-url"
+ echo "usage: $0 block|transaction|signature|cold-outputs|cold-transaction|load-from-binary|load-from-json|base58|parse-url|http-client"
exit 1
fi
case "$type" in
- block|transaction|signature|cold-outputs|cold-transaction|load-from-binary|load-from-json|base58|parse-url) ;;
- *) echo "usage: $0 block|transaction|signature|cold-outputs|cold-transaction|load-from-binary|load-from-json|base58|parse-url"; exit 1 ;;
+ block|transaction|signature|cold-outputs|cold-transaction|load-from-binary|load-from-json|base58|parse-url|http-client) ;;
+ *) echo "usage: $0 block|transaction|signature|cold-outputs|cold-transaction|load-from-binary|load-from-json|base58|parse-url|http-client"; exit 1 ;;
esac
if test -d "fuzz-out/$type"