Files
@ f2a6ba12fc29
Branch filter:
Location: libtransport.git/3rdparty/cpprestsdk/tests/functional/http/client/http_client_fuzz_tests.cpp
f2a6ba12fc29
3.9 KiB
text/x-c++hdr
Slack frontend stub
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | /***
* ==++==
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ==--==
* =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
*
* http_client_fuzz_tests.cpp
*
* Tests cases for fuzzing http_client (headers).
*
* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
****/
#include "stdafx.h"
using namespace web::http;
using namespace web::http::client;
using namespace concurrency;
using namespace concurrency::streams;
using namespace utility;
using namespace tests::functional::http::utilities;
namespace tests { namespace functional { namespace http { namespace client {
SUITE(http_client_fuzz_tests)
{
class fuzz_uri_address
{
public:
//Ensure that your traffic goes to port 8877 on the machine where NetFuzz is running
//Netfuzz sets an HTTP proxy at that location which your client must talk to
fuzz_uri_address() : m_uri(U("http://localhost:8877/")) {}
web::http::uri m_uri;
};
TEST_FIXTURE(fuzz_uri_address, fuzz_header_basic,
"Ignore", "Manual")
{
http_client client(m_uri);
method requestMethod = methods::GET;
http_request msg(requestMethod);
try
{
auto response = client.request(msg).get();
printf("Response code:%d\n", response.status_code());
auto response2 = response.content_ready().get();
printf("Response2 code:%d\n", response2.status_code());
}
catch(http_exception& e)
{
printf("Exception:%s\n", e.what());
}
}
TEST_FIXTURE(fuzz_uri_address, fuzz_request_headers,
"Ignore", "Manual")
{
http_client client(m_uri);
http_request msg(methods::POST);
#ifndef __cplusplus_winrt
// The WinRT-based HTTP stack does not support headers that have no
// value, which means that there is no point in making this particular
// header test, it is an unsupported feature on WinRT.
msg.headers().add(U("HEHE"), U(""));
#endif
msg.headers().add(U("MyHeader"), U("hehe;blach"));
msg.headers().add(U("Yo1"), U("You, Too"));
msg.headers().add(U("Yo2"), U("You2"));
msg.headers().add(U("Yo3"), U("You3"));
msg.headers().add(U("Yo4"), U("You4"));
msg.headers().add(U("Yo5"), U("You5"));
msg.headers().add(U("Yo6"), U("You6"));
msg.headers().add(U("Yo7"), U("You7"));
msg.headers().add(U("Yo8"), U("You8"));
msg.headers().add(U("Yo9"), U("You9"));
msg.headers().add(U("Yo10"), U("You10"));
msg.headers().add(U("Yo11"), U("You11"));
msg.headers().add(U("Accept"), U("text/plain"));
VERIFY_ARE_EQUAL(U("You5"), msg.headers()[U("Yo5")]);
try
{
auto response = client.request(msg).get();
printf("Response code:%d\n", response.status_code());
}
catch(http_exception& e)
{
printf("Exception:%s\n", e.what());
}
}
} // SUITE(http_client_fuzz_tests)
}}}}
|