test/Makefile.am | 6 ++++-- test/UnitFuzz.cpp | 4 ---- test/UnitOOB.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ test/run_unit.sh.in | 8 +++++--- wsd/LOOLWSD.cpp | 40 +++++++++++++++++++++++++++++++++++++--- 5 files changed, 97 insertions(+), 12 deletions(-)
New commits: commit 166c77f0d148aa39ceedfbc7399661a51ffe7cdb Author: Michael Meeks <[email protected]> Date: Thu Dec 8 17:47:03 2016 +0000 Make admin console easier to find in 'make run' diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 16802e1..0acfe40 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -13,6 +13,9 @@ /* Default host used in the start test URI */ #define LOOLWSD_TEST_HOST "localhost" +/* Default loleaflet UI used in the admin console URI */ +#define LOOLWSD_TEST_ADMIN_CONSOLE "/loleaflet/dist/admin/admin.html" + /* Default loleaflet UI used in the start test URI */ #define LOOLWSD_TEST_LOLEAFLET_UI "/loleaflet/" LOOLWSD_VERSION_HASH "/loleaflet.html" @@ -1434,15 +1437,25 @@ ServerSocket* findFreeMasterPort(int &nMasterPortNumber) return socket; } -static inline std::string getLaunchURI() +static inline std::string getLaunchBase(const std::string &credentials) { - const std::string aAbsTopSrcDir = Poco::Path(Application::instance().commandPath()).parent().toString(); - std::ostringstream oss; oss << " "; oss << ((LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination()) ? "https://" : "http://"); + oss << credentials; oss << LOOLWSD_TEST_HOST ":"; oss << ClientPortNumber; + + return oss.str(); +} + +static inline std::string getLaunchURI() +{ + const std::string aAbsTopSrcDir = Poco::Path(Application::instance().commandPath()).parent().toString(); + + std::ostringstream oss; + + oss << getLaunchBase(""); oss << LOOLWSD_TEST_LOLEAFLET_UI; oss << "?file_path=file://"; oss << Poco::Path(aAbsTopSrcDir).absolute().toString(); @@ -1451,6 +1464,22 @@ static inline std::string getLaunchURI() return oss.str(); } +static inline std::string getAdminURI(const Poco::Util::LayeredConfiguration &config) +{ + std::string user = config.getString("admin_console.username", ""); + std::string passwd = config.getString("admin_console.password", ""); + + if (user.empty() || passwd.empty()) + return ""; + + std::ostringstream oss; + + oss << getLaunchBase(user + ":" + passwd + "@"); + oss << LOOLWSD_TEST_ADMIN_CONSOLE; + + return oss.str(); +} + } // anonymous namespace std::atomic<unsigned> LOOLWSD::NextSessionId; @@ -1681,6 +1710,11 @@ void LOOLWSD::initialize(Application& self) #if ENABLE_DEBUG std::cerr << "\nLaunch this in your browser:\n\n" << getLaunchURI() << '\n' << std::endl; + + std::string adminURI = getAdminURI(config()); + if (!adminURI.empty()) + std::cerr << "\nOr for the Admin Console see:: \n\n" + << adminURI << '\n' << std::endl; #endif } commit 07d385630b78b65e15252d2811096c431e1af428 Author: Michael Meeks <[email protected]> Date: Thu Dec 8 17:30:53 2016 +0000 Cleanup unit test output a little. diff --git a/test/run_unit.sh.in b/test/run_unit.sh.in index 69fddb8..43108be 100755 --- a/test/run_unit.sh.in +++ b/test/run_unit.sh.in @@ -3,9 +3,7 @@ # DO NOT EDIT - this file is generated from run_unit.sh.in. # -echo -echo "Running unit-test:" -echo $0 $@ +cmd_line="$0 $@" # substituted variables in one place: DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -32,6 +30,10 @@ while test $# -gt 0; do shift done +echo +echo "Running $tst" +echo " $cmd_line" + # drop .la suffix tst=`echo $tst | sed s/\.la//`; commit 51949df882d2bba87a363926d1ffcb9a90b9ba37 Author: Michael Meeks <[email protected]> Date: Thu Dec 8 17:22:23 2016 +0000 Unit test to avoid assert returning. diff --git a/test/Makefile.am b/test/Makefile.am index e18d3db..98a8ce9 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -16,7 +16,8 @@ noinst_LTLIBRARIES = \ unit-timeout.la unit-prefork.la \ unit-storage.la unit-fonts.la \ unit-admin.la unit-tilecache.la \ - unit-fuzz.la unit-requests.la + unit-fuzz.la unit-requests.la \ + unit-oob.la MAGIC_TO_FORCE_SHLIB_CREATION = -rpath /dummy AM_LDFLAGS = -pthread -module $(MAGIC_TO_FORCE_SHLIB_CREATION) @@ -51,6 +52,7 @@ unittest_LDADD = $(CPPUNIT_LIBS) # unit test modules: unit_requests_la_SOURCES = UnitRequests.cpp +unit_oob_la_SOURCES = UnitOOB.cpp unit_fuzz_la_SOURCES = UnitFuzz.cpp unit_admin_la_SOURCES = UnitAdmin.cpp unit_admin_la_LIBADD = $(CPPUNIT_LIBS) @@ -70,7 +72,7 @@ if HAVE_LO_PATH check-local: ./run_unit.sh --log-file test.log --trs-file test.trs # FIXME unit-fonts.la is unstable, disabled for now. -TESTS = unit-tilecache.la unit-storage.la unit-timeout.la unit-prefork.la unit-admin.la unit-requests.la +TESTS = unit-oob.la unit-tilecache.la unit-storage.la unit-timeout.la unit-prefork.la unit-admin.la unit-requests.la else TESTS = ${top_builddir}/test/test endif diff --git a/test/UnitFuzz.cpp b/test/UnitFuzz.cpp index 1363ae7..6460962 100644 --- a/test/UnitFuzz.cpp +++ b/test/UnitFuzz.cpp @@ -7,12 +7,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <dlfcn.h> -#include <ftw.h> #include <cassert> #include <iostream> -#include <sys/types.h> -#include <dirent.h> #include <random> #include "Common.hpp" diff --git a/test/UnitOOB.cpp b/test/UnitOOB.cpp new file mode 100644 index 0000000..f879808 --- /dev/null +++ b/test/UnitOOB.cpp @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/* + * A great place for testing out of bound data, as found by + * UnitFuzz. + */ + +#include "Common.hpp" +#include "IoUtil.hpp" +#include "Protocol.hpp" +#include <LOOLWebSocket.hpp> +#include "Unit.hpp" +#include "UnitHTTP.hpp" +#include "Util.hpp" + +#include <Poco/Timestamp.h> +#include <Poco/StringTokenizer.h> +#include <Poco/Net/HTTPServerRequest.h> + +class UnitOOB : public UnitWSD +{ +public: + UnitOOB() + { + setHasKitHooks(); + } + + virtual void invokeTest() override + { + UnitHTTPServerResponse response; + UnitHTTPServerRequest request(response, "nonsense URI"); + + // ensure we handle invalid URIs without asserting. + testHandleRequest(TestRequest::TEST_REQ_PRISONER, request, response); + exitTest(TestResult::TEST_OK); + } +}; + +UnitBase *unit_create_wsd(void) +{ + return new UnitOOB(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
