mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Honor SSL config settings for ValidatorSites:
FIXES: #2990 * refactor common SSL client setup * enable SSL in unit-test http server * add tests for SSLHTTPDownloader * misc test refactoring
This commit is contained in:
@@ -111,18 +111,23 @@ class FileDirGuard : public DirGuard
|
||||
{
|
||||
protected:
|
||||
path const file_;
|
||||
bool created_ = false;
|
||||
|
||||
public:
|
||||
FileDirGuard(beast::unit_test::suite& test,
|
||||
path subDir, path file, std::string const& contents,
|
||||
bool useCounter = true)
|
||||
bool useCounter = true, bool create = true)
|
||||
: DirGuard(test, subDir, useCounter)
|
||||
, file_(file.is_absolute() ? file : subdir() / file)
|
||||
{
|
||||
if (!exists (file_))
|
||||
{
|
||||
std::ofstream o (file_.string ());
|
||||
o << contents;
|
||||
if (create)
|
||||
{
|
||||
std::ofstream o (file_.string ());
|
||||
o << contents;
|
||||
created_ = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -137,11 +142,16 @@ public:
|
||||
try
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
if (!exists (file_))
|
||||
test_.log << "Expected " << file_.string ()
|
||||
<< " to be an existing file." << std::endl;
|
||||
else
|
||||
if (exists (file_))
|
||||
{
|
||||
remove (file_);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (created_)
|
||||
test_.log << "Expected " << file_.string ()
|
||||
<< " to be an existing file." << std::endl;
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
|
||||
@@ -94,6 +94,29 @@ public:
|
||||
operator beast::Journal&() { return journal_; }
|
||||
};
|
||||
|
||||
// this sink can be used to create a custom journal
|
||||
// whose log messages will be captured to a stringstream
|
||||
// that can be later inspected.
|
||||
class StreamSink : public beast::Journal::Sink
|
||||
{
|
||||
std::stringstream strm_;
|
||||
public:
|
||||
StreamSink (
|
||||
beast::severities::Severity threshold = beast::severities::kDebug)
|
||||
: Sink (threshold, false) { }
|
||||
|
||||
void
|
||||
write (beast::severities::Severity level,
|
||||
std::string const& text) override
|
||||
{
|
||||
if (level < threshold())
|
||||
return;
|
||||
|
||||
strm_ << text << std::endl;
|
||||
}
|
||||
std::stringstream const& messages() const { return strm_ ; }
|
||||
};
|
||||
|
||||
} // test
|
||||
} // ripple
|
||||
|
||||
|
||||
Reference in New Issue
Block a user