Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion wsdl4cpp/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Change log - WSDL4CPP

Current release 1.0.0
Current release 1.0.1


## Release 1.0.1

### What's new?:
- Fixed bugs in wsdltest.

## Release 1.0.0

### What's new?:
Expand Down
135 changes: 94 additions & 41 deletions wsdl4cpp/src/test/WsdlTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
#include <numeric>
#include <vector>

#if defined(_WIN32) || defined(WIN32)
#include <windows.h>
#else
#include <unistd.h>
#endif

#include "wsdl/QName.hpp"
#include "wsdl/WsdlErrorHandler.hpp"
#include "wsdl/WsdlFramework.hpp"
Expand Down Expand Up @@ -184,6 +190,15 @@ template <typename Callable> bool invoke(Callable const &callable)

namespace
{
void sleep_between_retries()
{
#if defined(_WIN32) || defined(WIN32)
Sleep(1000);
#else
usleep(1000 * 1000);
#endif
}

class test_case
{
public:
Expand All @@ -194,34 +209,72 @@ class test_case

bool operator()() const
{
std::cout << "Performing HTTP GET to '" << url << " expecting CURL status code '" << expected_curl_status_code
<< "'\n";
initialize_memory_manager();
wsdl::CurlInputSource const source(wsdl::toXmlStr(url).c_str());
forwards_compatibility::unique_ptr<BinInputStream> const stream(source.makeStream());
unsigned int const buffer_size = 8196;
XMLByte buffer[buffer_size] = {'\0'};
unsigned int status = 0;
try
{
status = stream->readBytes(buffer, buffer_size);
}
catch (const XERCES_CPP_NAMESPACE::NetAccessorException &e)
{
std::cerr << "Exception caught: " << wsdl::toLocal(e.getMessage()) << '\n'
<< (exception_expected ? "Success: ignored" : "Fail: unexpected") << '\n';
return exception_expected;
}
bool const success = status == expected_curl_status_code;
if (success)
{
std::cout << "Success\n";
}
else
int const max_attempts = 10;
int attempt = 1;

while (attempt <= max_attempts)
{
std::cout << "Performing HTTP GET to '" << url << " expecting CURL status code '" << expected_curl_status_code
<< "' exception_expected='" << (exception_expected ? "true" : "false")
<< "'\n";
if (attempt > 1)
{
std::cout << " Retry attempt: " << attempt << "/" << max_attempts << "\n";
}

initialize_memory_manager();
wsdl::CurlInputSource const source(wsdl::toXmlStr(url).c_str());
forwards_compatibility::unique_ptr<BinInputStream> const stream(source.makeStream());
unsigned int const buffer_size = 8196;
XMLByte buffer[buffer_size] = {'\0'};
unsigned int status = 0;
try
{
status = stream->readBytes(buffer, buffer_size);
}
catch (const XERCES_CPP_NAMESPACE::NetAccessorException &e)
{
std::cerr << "Exception caught: " << wsdl::toLocal(e.getMessage()) << '\n';

if (exception_expected)
{
std::cout << "Success: expected-failure (exception is acceptable)\n";
return true;
}

if (attempt < max_attempts)
{
std::cout << "Retrying after exception... (attempt " << (attempt + 1) << "/" << max_attempts
<< "), waiting 1s before retry\n";
sleep_between_retries();
attempt++;
continue;
}

std::cout << "Fail: unexpected exception\n";
return false;
}

bool const success = status == expected_curl_status_code;

if (exception_expected)
{
std::cout << "Success: expected-failure (response is acceptable)\n";
return true;
}

if (success)
{
std::cout << "Success\n";
return true;
}

std::cout << "Fail: CURL status code = '" << status << "' Data read: '" << buffer << "'\n";
return false;
}
return success;

std::cout << "All " << max_attempts << " attempts exhausted.\n";
return false;
}

private:
Expand Down Expand Up @@ -267,34 +320,34 @@ bool self_test()
test_cases.push_back(test_case("https://mozilla-old.badssl.com/", 660, false));
test_cases.push_back(test_case("https://mozilla-intermediate.badssl.com/", 721, false));
test_cases.push_back(test_case("https://mozilla-modern.badssl.com/", 669, false));
test_cases.push_back(test_case("https://dh1024.badssl.com/", 573, false));
test_cases.push_back(test_case("https://dh1024.badssl.com/", 573, true));
test_cases.push_back(test_case("https://dh2048.badssl.com/", 593, false));
test_cases.push_back(test_case("https://dh-small-subgroup.badssl.com/", 647, false));
test_cases.push_back(test_case("https://dh-composite.badssl.com/", 615, false));
test_cases.push_back(test_case("https://dh-composite.badssl.com/", 615, true));
test_cases.push_back(test_case("https://static-rsa.badssl.com/", 551, false));
test_cases.push_back(test_case("https://no-sct.badssl.com/", 667, false));
test_cases.push_back(test_case("https://hsts.badssl.com/", 799, false));
test_cases.push_back(test_case("https://upgrade.badssl.com/", 819, false));
test_cases.push_back(test_case("https://preloaded-hsts.badssl.com/", 851, false));
#if defined(_WIN32) || defined(WIN32)
#if defined(_WIN32) || defined(WIN32)
test_cases.push_back(test_case("https://tls-v1-0.badssl.com:1010/", 496, true)); // 4ed2ffd0
test_cases.push_back(test_case("https://tls-v1-1.badssl.com:1011/", 496, true)); // 4ed2ffd0
test_cases.push_back(test_case("https://tls-v1-2.badssl.com:1012/", 502, false));
test_cases.push_back(test_case("https://tls-v1-2.badssl.com:1012/", 502, false));
test_cases.push_back(test_case("https://subdomain.preloaded-hsts.badssl.com/", 0, true));
test_cases.push_back(test_case("https://superfish.badssl.com/", 498, false));
test_cases.push_back(test_case("https://superfish.badssl.com/", 498, false));
test_cases.push_back(test_case("https://wrong.host.badssl.com/", 0, true));
test_cases.push_back(test_case("https://reversed-chain.badssl.com/", 0, true));
test_cases.push_back(test_case("https://10000-sans.badssl.com/", 0, true));
test_cases.push_back(test_case("https://reversed-chain.badssl.com/", 0, true));
test_cases.push_back(test_case("https://10000-sans.badssl.com/", 0, true));
test_cases.push_back(test_case("https://client.badssl.com/", 0, true));
test_cases.push_back(test_case("https://client-cert-missing.badssl.com/", 0, true));
test_cases.push_back(test_case("https://rc4-md5.badssl.com/", 0, true));
test_cases.push_back(test_case("https://rc4.badssl.com/", 0, true));
test_cases.push_back(test_case("https://3des.badssl.com/", 0, true));
test_cases.push_back(test_case("https://null.badssl.com/", 0, true));
test_cases.push_back(test_case("https://dh480.badssl.com/", 0, true));
test_cases.push_back(test_case("https://dh512.badssl.com/", 0, true));
test_cases.push_back(test_case("https://captive-portal.badssl.com/", 0, true));
#endif
test_cases.push_back(test_case("https://client-cert-missing.badssl.com/", 0, true));
test_cases.push_back(test_case("https://rc4-md5.badssl.com/", 0, true));
test_cases.push_back(test_case("https://rc4.badssl.com/", 0, true));
test_cases.push_back(test_case("https://3des.badssl.com/", 0, true));
test_cases.push_back(test_case("https://null.badssl.com/", 0, true));
test_cases.push_back(test_case("https://dh480.badssl.com/", 0, true));
test_cases.push_back(test_case("https://dh512.badssl.com/", 0, true));
test_cases.push_back(test_case("https://captive-portal.badssl.com/", 0, true));
#endif
test_cases.push_back(test_case("https://https-everywhere.badssl.com/", 995, false));
test_cases.push_back(test_case("https://spoofed-favicon.badssl.com/", 620, false));
test_cases.push_back(test_case("https://lock-title.badssl.com/", 707, false));
Expand Down