ucb: webdav-curl: convert webdav unit tests to curl

There's no point in building the tests for neon any more, just build
them only if curl is used.

This finds a bug in CurlUri::Init() where query and fragment separators
need to be added manually.

Change-Id: I3dcd1512450522df2c2a7d223b2e29b6c0e794fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124607
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
This commit is contained in:
Michael Stahl
2021-11-02 16:08:53 +01:00
parent 17dface793
commit 5a44e3772a
10 changed files with 37 additions and 28 deletions

View File

@@ -31,8 +31,7 @@ $(eval $(call gb_CppunitTest_use_library_objects,ucb_webdav_local_neon, \
$(eval $(call gb_CppunitTest_use_externals,ucb_webdav_local_neon,\
boost_headers \
libxml2 \
neon \
openssl \
curl \
))
$(eval $(call gb_CppunitTest_use_custom_headers,ucb_webdav_local_neon,\
@@ -45,7 +44,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,ucb_webdav_local_neon, \
$(eval $(call gb_CppunitTest_set_include,ucb_webdav_local_neon,\
$$(INCLUDE) \
-I$(SRCDIR)/ucb/source/ucp/webdav-neon \
-I$(SRCDIR)/ucb/source/ucp/webdav-curl \
))
$(eval $(call gb_CppunitTest_use_static_libraries,ucb_webdav_local_neon))

View File

@@ -34,8 +34,7 @@ $(eval $(call gb_CppunitTest_use_library_objects,ucb_webdav_neon_opts, \
$(eval $(call gb_CppunitTest_use_externals,ucb_webdav_neon_opts,\
boost_headers \
libxml2 \
neon \
openssl \
curl \
))
$(eval $(call gb_CppunitTest_use_custom_headers,ucb_webdav_neon_opts,\
@@ -48,7 +47,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,ucb_webdav_neon_opts, \
$(eval $(call gb_CppunitTest_set_include,ucb_webdav_neon_opts,\
$$(INCLUDE) \
-I$(SRCDIR)/ucb/source/ucp/webdav-neon \
-I$(SRCDIR)/ucb/source/ucp/webdav-curl \
))
$(eval $(call gb_CppunitTest_use_static_libraries,ucb_webdav_neon_opts))

View File

@@ -34,8 +34,7 @@ $(eval $(call gb_CppunitTest_use_library_objects,ucb_webdav_propfindcache, \
$(eval $(call gb_CppunitTest_use_externals,ucb_webdav_propfindcache,\
boost_headers \
libxml2 \
neon \
openssl \
curl \
))
$(eval $(call gb_CppunitTest_use_custom_headers,ucb_webdav_propfindcache,\
@@ -48,7 +47,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,ucb_webdav_propfindcache, \
$(eval $(call gb_CppunitTest_set_include,ucb_webdav_propfindcache,\
$$(INCLUDE) \
-I$(SRCDIR)/ucb/source/ucp/webdav-neon \
-I$(SRCDIR)/ucb/source/ucp/webdav-curl \
))
$(eval $(call gb_CppunitTest_use_static_libraries,ucb_webdav_propfindcache))

View File

@@ -34,8 +34,7 @@ $(eval $(call gb_CppunitTest_use_library_objects,ucb_webdav_res_access, \
$(eval $(call gb_CppunitTest_use_externals,ucb_webdav_res_access,\
boost_headers \
libxml2 \
neon \
openssl \
curl \
))
$(eval $(call gb_CppunitTest_use_custom_headers,ucb_webdav_res_access,\
@@ -48,7 +47,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,ucb_webdav_res_access, \
$(eval $(call gb_CppunitTest_set_include,ucb_webdav_res_access,\
$$(INCLUDE) \
-I$(SRCDIR)/ucb/source/ucp/webdav-neon \
-I$(SRCDIR)/ucb/source/ucp/webdav-curl \
))
$(eval $(call gb_CppunitTest_use_static_libraries,ucb_webdav_res_access))

View File

@@ -31,7 +31,7 @@ $(eval $(call gb_Module_add_targets,ucb,\
))
endif
ifeq ($(WITH_WEBDAV),neon)
ifeq ($(WITH_WEBDAV),curl)
$(eval $(call gb_Module_add_check_targets,ucb,\
CppunitTest_ucb_webdav_local_neon \

View File

@@ -10,9 +10,9 @@
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/plugin/TestPlugIn.h>
#include <NeonUri.hxx>
#include <CurlUri.hxx>
using namespace webdav_ucp;
using namespace http_dav_ucp;
namespace
{
@@ -21,26 +21,39 @@ namespace
{
public:
void NeonUriTest();
void WebdavUriTest();
void WebdavUriTest2();
// Change the following lines only, if you add, remove or rename
// member functions of the current class,
// because these macros are need by auto register mechanism.
CPPUNIT_TEST_SUITE( webdav_local_test );
CPPUNIT_TEST( NeonUriTest );
CPPUNIT_TEST( WebdavUriTest );
CPPUNIT_TEST( WebdavUriTest2 );
CPPUNIT_TEST_SUITE_END();
}; // class webdav_local_test
void webdav_local_test::NeonUriTest()
void webdav_local_test::WebdavUriTest()
{
//try URL decomposition
NeonUri aURI( "http://user%40anothername@server.biz:8040/aService/asegment/nextsegment/check.this?test=true&link=http://anotherserver.com/%3Fcheck=theapplication%26os=linuxintel%26lang=en-US%26version=5.2.0" );
CurlUri aURI(u"http://user%40anothername@server.biz:8040/aService/asegment/nextsegment/check.this?test=true&link=http://anotherserver.com/%3Fcheck=theapplication%26os=linuxintel%26lang=en-US%26version=5.2.0" );
CPPUNIT_ASSERT_EQUAL( OUString( "http" ), aURI.GetScheme() );
CPPUNIT_ASSERT_EQUAL( OUString( "server.biz" ), aURI.GetHost() );
CPPUNIT_ASSERT_EQUAL( OUString( "user%40anothername" ), aURI.GetUserInfo() );
CPPUNIT_ASSERT_EQUAL( sal_Int32( 8040 ), aURI.GetPort() );
CPPUNIT_ASSERT_EQUAL( OUString( "/aService/asegment/nextsegment/check.this?test=true&link=http://anotherserver.com/%3Fcheck=theapplication%26os=linuxintel%26lang=en-US%26version=5.2.0" ), aURI.GetPath( ) );
CPPUNIT_ASSERT_EQUAL( OUString( "user%40anothername" ), aURI.GetUser() );
CPPUNIT_ASSERT_EQUAL( sal_uInt16( 8040 ), aURI.GetPort() );
CPPUNIT_ASSERT_EQUAL( OUString( "/aService/asegment/nextsegment/check.this?test=true&link=http://anotherserver.com/%3Fcheck=theapplication%26os=linuxintel%26lang=en-US%26version=5.2.0" ), aURI.GetRelativeReference() );
}
void webdav_local_test::WebdavUriTest2()
{
CurlUri aURI(u"https://foo:bar@server.biz:8040/aService#aaa" );
CPPUNIT_ASSERT_EQUAL( OUString("https"), aURI.GetScheme() );
CPPUNIT_ASSERT_EQUAL( OUString("server.biz"), aURI.GetHost() );
CPPUNIT_ASSERT_EQUAL( OUString("foo"), aURI.GetUser() );
CPPUNIT_ASSERT_EQUAL( OUString("bar"), aURI.GetPassword() );
CPPUNIT_ASSERT_EQUAL( sal_uInt16( 8040 ), aURI.GetPort() );
CPPUNIT_ASSERT_EQUAL( OUString( "/aService#aaa" ), aURI.GetRelativeReference() );
}
CPPUNIT_TEST_SUITE_REGISTRATION( webdav_local_test );

View File

@@ -11,7 +11,7 @@
#include <cppunit/plugin/TestPlugIn.h>
#include <DAVTypes.hxx>
using namespace webdav_ucp;
using namespace http_dav_ucp;
namespace
{

View File

@@ -11,7 +11,7 @@
#include <cppunit/plugin/TestPlugIn.h>
#include <PropfindCache.hxx>
using namespace webdav_ucp;
using namespace http_dav_ucp;
namespace
{
@@ -113,7 +113,7 @@ namespace
// add the cache an element
aPropsNames.setPropertiesNames( std::vector(aProps) );
PropCache.addCachePropertyNames( aPropsNames );
PropCache.addCachePropertyNames( aPropsNames, 10 );
PropertyNames aRetPropsNames;
//test existence

View File

@@ -12,7 +12,7 @@
#include <DAVResourceAccess.hxx>
#include <DAVException.hxx>
using namespace webdav_ucp;
using namespace http_dav_ucp;
namespace
{

View File

@@ -93,12 +93,12 @@ void CurlUri::Init()
auto const oQuery(GetURLComponent(*m_pUrl, CURLUPART_QUERY, CURLUE_NO_QUERY));
if (oQuery)
{
m_QueryAndFragment += *oQuery;
m_QueryAndFragment += "?" + *oQuery;
}
auto const oFragment(GetURLComponent(*m_pUrl, CURLUPART_FRAGMENT, CURLUE_NO_FRAGMENT));
if (oFragment)
{
m_QueryAndFragment += *oFragment;
m_QueryAndFragment += "#" + *oFragment;
}
}