summaryrefslogtreecommitdiffstats
path: root/ucb/qa/cppunit/webdav
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ucb/qa/cppunit/webdav/webdav_local_neon.cxx96
-rw-r--r--ucb/qa/cppunit/webdav/webdav_options.cxx367
-rw-r--r--ucb/qa/cppunit/webdav/webdav_propfindcache.cxx133
-rw-r--r--ucb/qa/cppunit/webdav/webdav_resource_access.cxx103
4 files changed, 699 insertions, 0 deletions
diff --git a/ucb/qa/cppunit/webdav/webdav_local_neon.cxx b/ucb/qa/cppunit/webdav/webdav_local_neon.cxx
new file mode 100644
index 000000000..bde7652b9
--- /dev/null
+++ b/ucb/qa/cppunit/webdav/webdav_local_neon.cxx
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+#include <CurlUri.hxx>
+
+using namespace http_dav_ucp;
+
+namespace
+{
+
+ class webdav_local_test: public CppUnit::TestFixture
+ {
+
+ public:
+ 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( WebdavUriTest );
+ CPPUNIT_TEST( WebdavUriTest2 );
+ CPPUNIT_TEST_SUITE_END();
+ }; // class webdav_local_test
+
+ void webdav_local_test::WebdavUriTest()
+ {
+ //try URL decomposition
+ 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.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() );
+
+ CurlUri uri2(aURI.CloneWithRelativeRefPathAbsolute(u"/foo/bar"));
+ CPPUNIT_ASSERT_EQUAL( OUString("http"), uri2.GetScheme() );
+ CPPUNIT_ASSERT_EQUAL( OUString("server.biz"), uri2.GetHost() );
+ CPPUNIT_ASSERT_EQUAL( OUString("user%40anothername"), uri2.GetUser() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt16(8040), uri2.GetPort() );
+ CPPUNIT_ASSERT_EQUAL( OUString("/foo/bar"), uri2.GetRelativeReference() );
+ CPPUNIT_ASSERT_EQUAL( OUString("http://user%40anothername@server.biz:8040/foo/bar"), uri2.GetURI() );
+
+ CurlUri uri3(aURI.CloneWithRelativeRefPathAbsolute(u"?query#fragment"));
+ CPPUNIT_ASSERT_EQUAL( OUString("http"), uri3.GetScheme() );
+ CPPUNIT_ASSERT_EQUAL( OUString("server.biz"), uri3.GetHost() );
+ CPPUNIT_ASSERT_EQUAL( OUString("user%40anothername"), uri3.GetUser() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt16(8040), uri3.GetPort() );
+ CPPUNIT_ASSERT_EQUAL( OUString("?query#fragment"), uri3.GetRelativeReference() );
+ CPPUNIT_ASSERT_EQUAL( OUString("http://user%40anothername@server.biz:8040/?query#fragment"), uri3.GetURI() );
+ }
+
+ 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() );
+
+ CurlUri uri2(aURI.CloneWithRelativeRefPathAbsolute(u"/foo/bar"));
+ CPPUNIT_ASSERT_EQUAL( OUString("https"), uri2.GetScheme() );
+ CPPUNIT_ASSERT_EQUAL( OUString("server.biz"), uri2.GetHost() );
+ CPPUNIT_ASSERT_EQUAL( OUString("foo"), uri2.GetUser() );
+ CPPUNIT_ASSERT_EQUAL( OUString("bar"), uri2.GetPassword() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt16( 8040 ), uri2.GetPort() );
+ CPPUNIT_ASSERT_EQUAL( OUString("/foo/bar"), uri2.GetRelativeReference() );
+ CPPUNIT_ASSERT_EQUAL( OUString("https://foo:bar@server.biz:8040/foo/bar"), uri2.GetURI() );
+
+ CurlUri uri3(aURI.CloneWithRelativeRefPathAbsolute(u"?query"));
+ CPPUNIT_ASSERT_EQUAL( OUString("https"), uri3.GetScheme() );
+ CPPUNIT_ASSERT_EQUAL( OUString("server.biz"), uri3.GetHost() );
+ CPPUNIT_ASSERT_EQUAL( OUString("foo"), uri3.GetUser() );
+ CPPUNIT_ASSERT_EQUAL( OUString("bar"), uri3.GetPassword() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt16(8040), uri3.GetPort() );
+ CPPUNIT_ASSERT_EQUAL( OUString("?query"), uri3.GetRelativeReference() );
+ CPPUNIT_ASSERT_EQUAL( OUString("https://foo:bar@server.biz:8040/?query"), uri3.GetURI() );
+ }
+
+ CPPUNIT_TEST_SUITE_REGISTRATION( webdav_local_test );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/qa/cppunit/webdav/webdav_options.cxx b/ucb/qa/cppunit/webdav/webdav_options.cxx
new file mode 100644
index 000000000..d8e3d0946
--- /dev/null
+++ b/ucb/qa/cppunit/webdav/webdav_options.cxx
@@ -0,0 +1,367 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#include <test/bootstrapfixture.hxx>
+#include <cppunit/plugin/TestPlugIn.h>
+#include <DAVTypes.hxx>
+
+using namespace http_dav_ucp;
+
+namespace
+{
+
+ class webdav_opts_test: public test::BootstrapFixture
+ {
+
+ public:
+ webdav_opts_test() : BootstrapFixture( true, true ) {}
+
+ // initialise your test code values here.
+ void setUp( ) override;
+
+ void tearDown( ) override;
+
+ void DAVTypesCheckInit( DAVOptions const & aDavType );
+ void DAVTypesTest();
+
+ void DAVOptsCacheTests();
+
+ // 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_opts_test );
+ CPPUNIT_TEST( DAVTypesTest );
+ CPPUNIT_TEST( DAVOptsCacheTests );
+ CPPUNIT_TEST_SUITE_END();
+ }; // class webdav_local_test
+
+ // initialise your test code values here.
+ void webdav_opts_test::setUp()
+ {
+ }
+
+ void webdav_opts_test::tearDown()
+ {
+ }
+
+ void webdav_opts_test::DAVTypesCheckInit( DAVOptions const & aDavType )
+ {
+ // check if the class is at reset state
+ // using accessors
+ CPPUNIT_ASSERT_EQUAL( false, aDavType.isClass1() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavType.isClass2() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavType.isClass3() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavType.isLocked() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavType.isHeadAllowed() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavType.getAllowedMethods().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavType.isLockAllowed() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavType.getURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavType.getRedirectedURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavType.getStaleTime() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavType.getRequestedTimeLife() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavType.getHttpResponseStatusCode() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavType.getHttpResponseStatusText().isEmpty() );
+ }
+
+ void webdav_opts_test::DAVTypesTest()
+ {
+ //our DAVOptions
+ DAVOptions aDavOpt;
+ DAVTypesCheckInit( aDavOpt );
+
+ aDavOpt.setClass1();
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isClass1() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getAllowedMethods().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() );
+
+ aDavOpt.setClass1( false );
+ aDavOpt.setClass2();
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isClass2() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getAllowedMethods().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() );
+
+ aDavOpt.setClass2( false );
+ aDavOpt.setClass3();
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isClass3() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getAllowedMethods().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() );
+
+ aDavOpt.setClass3( false );
+
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getAllowedMethods().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() );
+
+ DAVTypesCheckInit( aDavOpt );
+ //example of allowed method for a Web resource
+ OUString aAllowedMethods = "POST,OPTIONS,GET,HEAD,TRACE";
+ aDavOpt.setAllowedMethods( aAllowedMethods );
+ // now check...
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() );
+ CPPUNIT_ASSERT_EQUAL( aAllowedMethods, aDavOpt.getAllowedMethods() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() );
+
+ //example of allowed method for a WebDAV resource supporting LOCK
+ aAllowedMethods = "OPTIONS,GET,HEAD,POST,DELETE,TRACE,PROPFIND,PROPPATCH,COPY,MOVE,PUT,LOCK,UNLOCK";
+ aDavOpt.setAllowedMethods( aAllowedMethods );
+ // now check...
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isLockAllowed() );
+ CPPUNIT_ASSERT_EQUAL( aAllowedMethods, aDavOpt.getAllowedMethods() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() );
+
+ aAllowedMethods.clear();
+ aDavOpt.setAllowedMethods( aAllowedMethods );
+ aDavOpt.setStaleTime( 12345678 );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getAllowedMethods().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 12345678 ), aDavOpt.getStaleTime() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() );
+
+ aDavOpt.setStaleTime( 0 );
+
+ aDavOpt.setRequestedTimeLife( 300 );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getAllowedMethods().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 300 ), aDavOpt.getRequestedTimeLife() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() );
+
+ aDavOpt.setRequestedTimeLife( 0 );
+
+ OUString aHTTPResponseStatusText = "522 Origin Connection Time-out";
+ aDavOpt.setHttpResponseStatusCode( 522 );
+ aDavOpt.setHttpResponseStatusText( aHTTPResponseStatusText );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getAllowedMethods().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() );
+ CPPUNIT_ASSERT_EQUAL( true , aDavOpt.getURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt16( 522 ), aDavOpt.getHttpResponseStatusCode() );
+ CPPUNIT_ASSERT_EQUAL( aHTTPResponseStatusText, aDavOpt.getHttpResponseStatusText() );
+
+ aDavOpt.setHttpResponseStatusCode( 0 );
+ aHTTPResponseStatusText.clear();
+ aDavOpt.setHttpResponseStatusText( aHTTPResponseStatusText );
+
+ OUString aURL = "http://my.server.org/a%20fake%20url/to%20test";
+ aDavOpt.setURL( aURL );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getAllowedMethods().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() );
+ CPPUNIT_ASSERT_EQUAL( aURL, aDavOpt.getURL() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getRedirectedURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() );
+
+ aURL.clear();
+ aDavOpt.setURL( aURL );
+ aURL = "http://my.server.org/a%20fake%20url/to%20test/another-url";
+ aDavOpt.setRedirectedURL( aURL );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass1() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass2() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isClass3() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.isHeadAllowed() );
+ CPPUNIT_ASSERT_EQUAL( false, aDavOpt.isLockAllowed() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getAllowedMethods().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getStaleTime() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32( 0 ), aDavOpt.getRequestedTimeLife() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getURL().isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( aURL, aDavOpt.getRedirectedURL() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt16( 0 ), aDavOpt.getHttpResponseStatusCode() );
+ CPPUNIT_ASSERT_EQUAL( true, aDavOpt.getHttpResponseStatusText().isEmpty() );
+
+ //check the init() function
+ aAllowedMethods = "OPTIONS,GET,HEAD,POST,DELETE,TRACE,PROPFIND,PROPPATCH,COPY,MOVE,PUT,LOCK,UNLOCK";
+ aURL = "http://my.server.org/a%20fake%20url/to%20test/another-url";
+ aHTTPResponseStatusText = "404 Not Found";
+ aDavOpt.setClass1();
+ aDavOpt.setClass2();
+ aDavOpt.setClass3();
+ aDavOpt.setHeadAllowed( false );
+ aDavOpt.setLocked();
+ aDavOpt.setAllowedMethods( aAllowedMethods );
+ aDavOpt.setStaleTime( 1234567 );
+ aDavOpt.setRequestedTimeLife( 300 );
+ aDavOpt.setURL( aURL );
+ aDavOpt.setRedirectedURL( aURL );
+ aDavOpt.setHttpResponseStatusCode( 404 );
+ aDavOpt.setHttpResponseStatusText( aHTTPResponseStatusText );
+
+ aDavOpt.init();
+ DAVTypesCheckInit( aDavOpt );
+ // equality check
+ DAVOptions aDavOptTarget;
+ CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget );
+
+ aDavOpt.setClass1();
+ CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget );
+ aDavOpt.setClass1( false );
+ CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget );
+
+ aDavOpt.setClass2();
+ CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget );
+ aDavOpt.setClass2( false );
+ CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget );
+
+ aDavOpt.setClass3();
+ CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget );
+ aDavOpt.setClass3( false );
+ CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget );
+
+ aDavOpt.setHeadAllowed( false );
+ CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget );
+ aDavOpt.setHeadAllowed();
+ CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget );
+
+ aDavOpt.setLocked();
+ CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget );
+ aDavOpt.setLocked( false );
+ CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget );
+
+ aDavOpt.setStaleTime( 1234567 );
+ CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget );
+ aDavOpt.setStaleTime( 0 );
+ CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget );
+
+ aDavOpt.setRequestedTimeLife( 1234567 );
+ CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget );
+ aDavOpt.setRequestedTimeLife( 0 );
+ CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget );
+
+ aDavOpt.setHttpResponseStatusCode( 404 );
+ CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget );
+ aDavOpt.setHttpResponseStatusCode( 0 );
+ CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget );
+
+ aDavOpt.setAllowedMethods( aAllowedMethods );
+ CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget );
+ aAllowedMethods.clear();
+ aDavOpt.setAllowedMethods( aAllowedMethods );
+ CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget );
+
+ aDavOpt.setURL( aURL );
+ CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget );
+ aURL.clear();
+ aDavOpt.setURL( aURL );
+ CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget );
+
+ aDavOpt.setHttpResponseStatusText( aHTTPResponseStatusText );
+ CPPUNIT_ASSERT_EQUAL( false , aDavOpt == aDavOptTarget );
+ aHTTPResponseStatusText.clear();
+ aDavOpt.setHttpResponseStatusText( aHTTPResponseStatusText );
+ CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptTarget );
+
+ }
+
+ void webdav_opts_test::DAVOptsCacheTests()
+ {
+ // define a local cache to test
+ DAVOptionsCache aDAVOptsCache;
+ // the value to cache
+ DAVOptions aDavOpt;
+ // the returned value to test
+ DAVOptions aDavOptCached;
+ // init the values
+ OUString aURL = "http://my.server.org/a%20fake%20url/to%20test/another-url";
+ aDavOpt.setURL( aURL );
+ aDavOpt.setRedirectedURL( "http://my.server.org/a%20fake%20url/to%20test/another-url/redirected" );
+ aDavOpt.setClass1();
+ aDavOpt.setClass2();
+ aDavOpt.setClass3();
+ aDavOpt.setHeadAllowed( false );
+ aDavOpt.setAllowedMethods( "OPTIONS,GET,HEAD,POST,DELETE,TRACE,PROPFIND,PROPPATCH,COPY,MOVE,PUT,LOCK,UNLOCK" );
+ // add to cache
+ aDAVOptsCache.addDAVOptions( aDavOpt, 30000 );
+ CPPUNIT_ASSERT_EQUAL( true ,aDAVOptsCache.getDAVOptions( aURL, aDavOptCached ) );
+ CPPUNIT_ASSERT_EQUAL( true , aDavOpt == aDavOptCached );
+ }
+
+ CPPUNIT_TEST_SUITE_REGISTRATION( webdav_opts_test );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/qa/cppunit/webdav/webdav_propfindcache.cxx b/ucb/qa/cppunit/webdav/webdav_propfindcache.cxx
new file mode 100644
index 000000000..da790442e
--- /dev/null
+++ b/ucb/qa/cppunit/webdav/webdav_propfindcache.cxx
@@ -0,0 +1,133 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#include <test/bootstrapfixture.hxx>
+#include <cppunit/plugin/TestPlugIn.h>
+#include <PropfindCache.hxx>
+
+using namespace http_dav_ucp;
+
+namespace
+{
+
+ class webdav_propcache_test: public test::BootstrapFixture
+ {
+
+ public:
+ webdav_propcache_test() : BootstrapFixture( true, true ) {}
+
+ // initialise your test code values here.
+ void setUp( ) override;
+
+ void tearDown( ) override;
+
+ void PropfindCacheElemTests();
+ void PropfindCacheTests();
+
+ // 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_propcache_test );
+ CPPUNIT_TEST( PropfindCacheElemTests );
+ CPPUNIT_TEST( PropfindCacheTests );
+ CPPUNIT_TEST_SUITE_END();
+ }; // class webdav_local_test
+
+ // initialise your test code values here.
+ void webdav_propcache_test::setUp()
+ {
+ }
+
+ void webdav_propcache_test::tearDown()
+ {
+ }
+
+ void webdav_propcache_test::PropfindCacheElemTests( )
+ {
+ OUString aTheURL( "http:://server/path/filename.odt" );
+ PropertyNames aPropsNames( aTheURL );
+
+ CPPUNIT_ASSERT_EQUAL( aTheURL, aPropsNames.getURL() );
+ CPPUNIT_ASSERT_EQUAL( static_cast< sal_uInt32 >(0), aPropsNames.getStaleTime() );
+
+ sal_uInt32 maxTime = static_cast< sal_uInt32 >(std::pow(2,32)-1);
+
+ aPropsNames.setStaleTime( maxTime );
+ CPPUNIT_ASSERT_EQUAL( maxTime, aPropsNames.getStaleTime() );
+
+ std::vector < OUString > properties {
+ "DAV:lockdiscovery",
+ "DAV:supportedlock",
+ "DAV:resourcetype",
+ "DAV:displayname",
+ "DAV:getlastmodified",
+ "DAV:getcontentlength",
+ "DAV:creationdate",
+ "DAV:getetag",
+ "DAV:authticket",
+ };
+
+ DAVResourceInfo aSingleInfo { properties };
+ std::vector< DAVResourceInfo > aProps { aSingleInfo };
+ std::vector< DAVResourceInfo > aRetProp;
+
+ aPropsNames.setPropertiesNames( std::vector(aProps) );
+ aRetProp = aPropsNames.getPropertiesNames();
+ CPPUNIT_ASSERT_EQUAL( true, ( aProps == aRetProp ) );
+
+ aProps[0].properties.emplace_back("DAV:getlastmodified" );
+ aRetProp = aPropsNames.getPropertiesNames();
+ CPPUNIT_ASSERT_EQUAL( false, ( aProps == aRetProp ) );
+ }
+
+ void webdav_propcache_test::PropfindCacheTests( )
+ {
+ PropertyNamesCache PropCache;
+ OUString aTheURL( "http:://server/path/filename.odt" );
+ PropertyNames aPropsNames( aTheURL );
+
+ // check cache emptiness
+ CPPUNIT_ASSERT_EQUAL( false, PropCache.getCachedPropertyNames( aTheURL, aPropsNames ) );
+
+ std::vector < OUString > properties {
+ "DAV:lockdiscovery",
+ "DAV:supportedlock",
+ "DAV:resourcetype",
+ "DAV:displayname",
+ "DAV:getlastmodified",
+ "DAV:getcontentlength",
+ "DAV:creationdate",
+ "DAV:getetag",
+ "DAV:authticket",
+ };
+
+ DAVResourceInfo aSingleInfo { properties };
+ std::vector< DAVResourceInfo > aProps { aSingleInfo };
+
+ // add the cache an element
+ aPropsNames.setPropertiesNames( std::vector(aProps) );
+ PropCache.addCachePropertyNames( aPropsNames, 10 );
+
+ PropertyNames aRetPropsNames;
+ //test existence
+ CPPUNIT_ASSERT_EQUAL( true, PropCache.getCachedPropertyNames( aTheURL, aRetPropsNames ) );
+ //check equality
+ std::vector< DAVResourceInfo > aRetProp = aRetPropsNames.getPropertiesNames();
+ CPPUNIT_ASSERT_EQUAL( true, ( aProps == aRetProp ) );
+ //remove from cache
+ PropCache.removeCachedPropertyNames( aTheURL );
+ //check absence
+ CPPUNIT_ASSERT_EQUAL( false, PropCache.getCachedPropertyNames( aTheURL, aPropsNames ) );
+ }
+
+ CPPUNIT_TEST_SUITE_REGISTRATION( webdav_propcache_test );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/qa/cppunit/webdav/webdav_resource_access.cxx b/ucb/qa/cppunit/webdav/webdav_resource_access.cxx
new file mode 100644
index 000000000..2379139c0
--- /dev/null
+++ b/ucb/qa/cppunit/webdav/webdav_resource_access.cxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#include <test/bootstrapfixture.hxx>
+#include <cppunit/plugin/TestPlugIn.h>
+#include <DAVResourceAccess.hxx>
+#include <DAVException.hxx>
+
+using namespace http_dav_ucp;
+
+namespace
+{
+
+ class webdav_resource_access_test: public test::BootstrapFixture
+ {
+
+ public:
+ webdav_resource_access_test() : BootstrapFixture( true, true ) {}
+
+ // initialise your test code values here.
+ void setUp() override;
+
+ void tearDown() override;
+
+ void DAVCheckRetries();
+
+ // 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_resource_access_test );
+ CPPUNIT_TEST( DAVCheckRetries );
+ CPPUNIT_TEST_SUITE_END();
+ }; // class webdav_local_test
+
+ // initialise your test code values here.
+ void webdav_resource_access_test::setUp()
+ {
+ }
+
+ void webdav_resource_access_test::tearDown()
+ {
+ }
+
+ // test when http connection should retry
+ void webdav_resource_access_test::DAVCheckRetries()
+ {
+ // instantiate a resource access class
+ DAVResourceAccess ResourceAccess(nullptr, nullptr, "http://url");
+ // first check: all http errors from 100 to 399 should return true, to force a retry
+ for (auto i = SC_CONTINUE; i < SC_BAD_REQUEST; i++)
+ {
+ const DAVException aTheException(DAVException::DAV_HTTP_ERROR, "http error code", i );
+ CPPUNIT_ASSERT_EQUAL( true , ResourceAccess.handleException( aTheException, 1 ) );
+ }
+ // http error code from 400 to 499 should NOT force a retry
+ for (auto i = SC_BAD_REQUEST; i < SC_INTERNAL_SERVER_ERROR; i++)
+ {
+ const DAVException aTheException(DAVException::DAV_HTTP_ERROR, "http error code", i );
+ CPPUNIT_ASSERT_EQUAL( false , ResourceAccess.handleException( aTheException, 1 ) );
+ }
+
+ // http error code from 500 (SC_INTERNAL_SERVER_ERROR) up should force a retry
+ // except in special value
+ // 1999 as high limit is just a current (2016-09-25) choice.
+ // RFC poses no limit to the max value of response status code
+ for (auto i = SC_INTERNAL_SERVER_ERROR; i < 2000; i++)
+ {
+ const DAVException aTheException(DAVException::DAV_HTTP_ERROR, "http error code", i );
+ switch ( i )
+ {
+ // the HTTP response status codes that can be retried
+ case SC_BAD_GATEWAY:
+ case SC_GATEWAY_TIMEOUT:
+ case SC_SERVICE_UNAVAILABLE:
+ case SC_INSUFFICIENT_STORAGE:
+ CPPUNIT_ASSERT_EQUAL( true , ResourceAccess.handleException( aTheException, 1 ) );
+ break;
+ // default is NOT retry
+ default:
+ CPPUNIT_ASSERT_EQUAL( false , ResourceAccess.handleException( aTheException, 1 ) );
+ }
+ }
+
+ // check the retry request
+ {
+ const DAVException aTheException(DAVException::DAV_HTTP_RETRY, "the-host-name", 8080 );
+ CPPUNIT_ASSERT_EQUAL( true , ResourceAccess.handleException( aTheException, 1 ) );
+ }
+ }
+
+ CPPUNIT_TEST_SUITE_REGISTRATION( webdav_resource_access_test );
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */