From 9e028f4b594a06fc8893f59de6e087a0c9929ed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Je=CC=81ro=CC=82me=20Schneider?= Date: Mon, 27 Feb 2012 21:33:52 +0100 Subject: [PATCH] Sending in Baikal 0.0.1 --- Core | 1 + CoreVersions/Baikal_0.1/Bootstrap.php | 95 + CoreVersions/Baikal_0.1/Frameworks/SabreDAV | 1 + .../Versions/SabreDAV.1.5.7-stable/ChangeLog | 636 ++++++ .../Versions/SabreDAV.1.5.7-stable/LICENSE | 28 + .../bin/naturalselection.py | 140 ++ .../SabreDAV.1.5.7-stable/examples/.htdigest | 1 + .../SabreDAV.1.5.7-stable/examples/Sabre | 1 + .../examples/addressbookserver.php | 56 + .../examples/basicauth.php | 28 + .../examples/calendarserver.php | 45 + .../examples/digestauth.php | 27 + .../examples/fileserver.php | 60 + .../examples/groupwareserver.php | 91 + .../examples/simplefsserver.php | 125 ++ .../examples/sql/mysql.addressbook.sql | 17 + .../examples/sql/mysql.calendars.sql | 20 + .../examples/sql/mysql.locks.sql | 10 + .../examples/sql/mysql.principals.sql | 21 + .../examples/sql/mysql.users.sql | 9 + .../examples/sql/sqlite.addressbooks.sql | 17 + .../examples/sql/sqlite.calendars.sql | 20 + .../examples/sql/sqlite.locks.sql | 12 + .../examples/sql/sqlite.principals.sql | 20 + .../examples/sql/sqlite.users.sql | 9 + .../lib/Sabre.includes.php | 128 ++ .../lib/Sabre/CalDAV/Backend/Abstract.php | 163 ++ .../lib/Sabre/CalDAV/Backend/PDO.php | 386 ++++ .../lib/Sabre/CalDAV/Calendar.php | 318 +++ .../lib/Sabre/CalDAV/CalendarObject.php | 260 +++ .../lib/Sabre/CalDAV/CalendarRootNode.php | 75 + .../Exception/InvalidICalendarObject.php | 18 + .../lib/Sabre/CalDAV/ICSExportPlugin.php | 135 ++ .../lib/Sabre/CalDAV/ICalendar.php | 18 + .../lib/Sabre/CalDAV/ICalendarObject.php | 20 + .../lib/Sabre/CalDAV/ICalendarUtil.php | 157 ++ .../lib/Sabre/CalDAV/Plugin.php | 788 +++++++ .../lib/Sabre/CalDAV/Principal/Collection.php | 31 + .../lib/Sabre/CalDAV/Principal/ProxyRead.php | 178 ++ .../lib/Sabre/CalDAV/Principal/ProxyWrite.php | 178 ++ .../lib/Sabre/CalDAV/Principal/User.php | 122 ++ .../SupportedCalendarComponentSet.php | 85 + .../CalDAV/Property/SupportedCalendarData.php | 38 + .../CalDAV/Property/SupportedCollationSet.php | 44 + .../lib/Sabre/CalDAV/Server.php | 65 + .../lib/Sabre/CalDAV/UserCalendars.php | 280 +++ .../lib/Sabre/CalDAV/Version.php | 24 + .../lib/Sabre/CalDAV/XMLUtil.php | 208 ++ .../lib/Sabre/CardDAV/AddressBook.php | 293 +++ .../Sabre/CardDAV/AddressBookQueryParser.php | 211 ++ .../lib/Sabre/CardDAV/AddressBookRoot.php | 78 + .../lib/Sabre/CardDAV/Backend/Abstract.php | 121 + .../lib/Sabre/CardDAV/Backend/PDO.php | 277 +++ .../lib/Sabre/CardDAV/Card.php | 225 ++ .../lib/Sabre/CardDAV/IAddressBook.php | 18 + .../lib/Sabre/CardDAV/ICard.php | 18 + .../lib/Sabre/CardDAV/IDirectory.php | 21 + .../lib/Sabre/CardDAV/Plugin.php | 463 ++++ .../CardDAV/Property/SupportedAddressData.php | 69 + .../lib/Sabre/CardDAV/UserAddressBooks.php | 240 ++ .../lib/Sabre/CardDAV/Version.php | 26 + .../Sabre/DAV/Auth/Backend/AbstractBasic.php | 79 + .../Sabre/DAV/Auth/Backend/AbstractDigest.php | 96 + .../lib/Sabre/DAV/Auth/Backend/Apache.php | 60 + .../lib/Sabre/DAV/Auth/Backend/File.php | 76 + .../lib/Sabre/DAV/Auth/Backend/PDO.php | 66 + .../lib/Sabre/DAV/Auth/IBackend.php | 34 + .../lib/Sabre/DAV/Auth/Plugin.php | 111 + .../Sabre/DAV/Browser/GuessContentType.php | 97 + .../Sabre/DAV/Browser/MapGetToPropFind.php | 54 + .../lib/Sabre/DAV/Browser/Plugin.php | 283 +++ .../lib/Sabre/DAV/Client.php | 431 ++++ .../lib/Sabre/DAV/Collection.php | 90 + .../lib/Sabre/DAV/Directory.php | 17 + .../lib/Sabre/DAV/Exception.php | 63 + .../lib/Sabre/DAV/Exception/BadRequest.php | 28 + .../lib/Sabre/DAV/Exception/Conflict.php | 28 + .../Sabre/DAV/Exception/ConflictingLock.php | 35 + .../lib/Sabre/DAV/Exception/FileNotFound.php | 28 + .../lib/Sabre/DAV/Exception/Forbidden.php | 27 + .../DAV/Exception/InsufficientStorage.php | 27 + .../DAV/Exception/InvalidResourceType.php | 33 + .../Exception/LockTokenMatchesRequestUri.php | 39 + .../lib/Sabre/DAV/Exception/Locked.php | 67 + .../Sabre/DAV/Exception/MethodNotAllowed.php | 44 + .../Sabre/DAV/Exception/NotAuthenticated.php | 28 + .../Sabre/DAV/Exception/NotImplemented.php | 27 + .../DAV/Exception/PreconditionFailed.php | 69 + .../DAV/Exception/ReportNotImplemented.php | 30 + .../RequestedRangeNotSatisfiable.php | 29 + .../DAV/Exception/UnsupportedMediaType.php | 28 + .../lib/Sabre/DAV/FS/Directory.php | 121 + .../lib/Sabre/DAV/FS/File.php | 89 + .../lib/Sabre/DAV/FS/Node.php | 81 + .../lib/Sabre/DAV/FSExt/Directory.php | 135 ++ .../lib/Sabre/DAV/FSExt/File.php | 88 + .../lib/Sabre/DAV/FSExt/Node.php | 276 +++ .../lib/Sabre/DAV/File.php | 81 + .../lib/Sabre/DAV/ICollection.php | 58 + .../lib/Sabre/DAV/IExtendedCollection.php | 28 + .../lib/Sabre/DAV/IFile.php | 63 + .../lib/Sabre/DAV/ILockable.php | 38 + .../lib/Sabre/DAV/INode.php | 44 + .../lib/Sabre/DAV/IProperties.php | 67 + .../lib/Sabre/DAV/IQuota.php | 27 + .../lib/Sabre/DAV/Locks/Backend/Abstract.php | 50 + .../lib/Sabre/DAV/Locks/Backend/FS.php | 189 ++ .../lib/Sabre/DAV/Locks/Backend/File.php | 182 ++ .../lib/Sabre/DAV/Locks/Backend/PDO.php | 165 ++ .../lib/Sabre/DAV/Locks/LockInfo.php | 81 + .../lib/Sabre/DAV/Locks/Plugin.php | 679 ++++++ .../lib/Sabre/DAV/Mount/Plugin.php | 79 + .../lib/Sabre/DAV/Node.php | 55 + .../lib/Sabre/DAV/ObjectTree.php | 154 ++ .../lib/Sabre/DAV/Property.php | 25 + .../Sabre/DAV/Property/GetLastModified.php | 75 + .../lib/Sabre/DAV/Property/Href.php | 91 + .../lib/Sabre/DAV/Property/HrefList.php | 96 + .../lib/Sabre/DAV/Property/IHref.php | 25 + .../lib/Sabre/DAV/Property/LockDiscovery.php | 102 + .../lib/Sabre/DAV/Property/ResourceType.php | 125 ++ .../lib/Sabre/DAV/Property/Response.php | 156 ++ .../lib/Sabre/DAV/Property/ResponseList.php | 58 + .../lib/Sabre/DAV/Property/SupportedLock.php | 76 + .../Sabre/DAV/Property/SupportedReportSet.php | 110 + .../lib/Sabre/DAV/Server.php | 1941 +++++++++++++++++ .../lib/Sabre/DAV/ServerPlugin.php | 90 + .../lib/Sabre/DAV/SimpleCollection.php | 106 + .../lib/Sabre/DAV/SimpleDirectory.php | 21 + .../lib/Sabre/DAV/SimpleFile.php | 120 + .../lib/Sabre/DAV/StringUtil.php | 91 + .../Sabre/DAV/TemporaryFileFilterPlugin.php | 279 +++ .../lib/Sabre/DAV/Tree.php | 192 ++ .../lib/Sabre/DAV/Tree/Filesystem.php | 124 ++ .../lib/Sabre/DAV/URLUtil.php | 125 ++ .../lib/Sabre/DAV/UUIDUtil.php | 64 + .../lib/Sabre/DAV/Version.php | 24 + .../lib/Sabre/DAV/XMLUtil.php | 183 ++ .../DAVACL/AbstractPrincipalCollection.php | 121 + .../Sabre/DAVACL/Exception/AceConflict.php | 34 + .../Sabre/DAVACL/Exception/NeedPrivileges.php | 80 + .../lib/Sabre/DAVACL/Exception/NoAbstract.php | 34 + .../Exception/NotRecognizedPrincipal.php | 34 + .../Exception/NotSupportedPrivilege.php | 34 + .../lib/Sabre/DAVACL/IACL.php | 58 + .../lib/Sabre/DAVACL/IPrincipal.php | 75 + .../lib/Sabre/DAVACL/IPrincipalBackend.php | 73 + .../lib/Sabre/DAVACL/Plugin.php | 1240 +++++++++++ .../lib/Sabre/DAVACL/Principal.php | 263 +++ .../lib/Sabre/DAVACL/PrincipalBackend/PDO.php | 206 ++ .../lib/Sabre/DAVACL/PrincipalCollection.php | 35 + .../lib/Sabre/DAVACL/Property/Acl.php | 186 ++ .../Property/CurrentUserPrivilegeSet.php | 75 + .../lib/Sabre/DAVACL/Property/Principal.php | 154 ++ .../DAVACL/Property/SupportedPrivilegeSet.php | 92 + .../lib/Sabre/DAVACL/Version.php | 24 + .../lib/Sabre/HTTP/AWSAuth.php | 226 ++ .../lib/Sabre/HTTP/AbstractAuth.php | 111 + .../lib/Sabre/HTTP/BasicAuth.php | 61 + .../lib/Sabre/HTTP/DigestAuth.php | 234 ++ .../lib/Sabre/HTTP/Request.php | 243 +++ .../lib/Sabre/HTTP/Response.php | 152 ++ .../lib/Sabre/HTTP/Util.php | 65 + .../lib/Sabre/HTTP/Version.php | 24 + .../lib/Sabre/VObject/Component.php | 307 +++ .../lib/Sabre/VObject/Element.php | 15 + .../lib/Sabre/VObject/Element/DateTime.php | 245 +++ .../Sabre/VObject/Element/MultiDateTime.php | 168 ++ .../lib/Sabre/VObject/ElementList.php | 172 ++ .../lib/Sabre/VObject/Node.php | 149 ++ .../lib/Sabre/VObject/Parameter.php | 81 + .../lib/Sabre/VObject/ParseException.php | 12 + .../lib/Sabre/VObject/Property.php | 289 +++ .../lib/Sabre/VObject/Reader.php | 191 ++ .../lib/Sabre/VObject/Version.php | 24 + .../lib/Sabre/VObject/includes.php | 29 + .../lib/Sabre/autoload.php | 27 + .../Sabre/CalDAV/Backend/AbstractPDOTest.php | 153 ++ .../Sabre/CalDAV/Backend/AbstractTest.php | 25 + .../tests/Sabre/CalDAV/Backend/Mock.php | 201 ++ .../Sabre/CalDAV/Backend/PDOMySQLTest.php | 48 + .../Sabre/CalDAV/Backend/PDOSqliteTest.php | 21 + .../tests/Sabre/CalDAV/CalendarObjectTest.php | 294 +++ .../Sabre/CalDAV/CalendarQueryFilterTest.php | 201 ++ .../tests/Sabre/CalDAV/CalendarTest.php | 215 ++ .../Sabre/CalDAV/ICSExportPluginTest.php | 121 + .../tests/Sabre/CalDAV/ICalendarUtilTest.php | 233 ++ .../tests/Sabre/CalDAV/Issue166Test.php | 49 + .../tests/Sabre/CalDAV/PluginTest.php | 600 +++++ .../Sabre/CalDAV/Principal/CollectionTest.php | 18 + .../Sabre/CalDAV/Principal/ProxyReadTest.php | 98 + .../Sabre/CalDAV/Principal/ProxyWriteTest.php | 36 + .../tests/Sabre/CalDAV/Principal/UserTest.php | 104 + .../SupportedCalendarComponentSetTest.php | 66 + .../Property/SupportedCalendarDataTest.php | 40 + .../Property/SupportedCollationSetTest.php | 42 + .../tests/Sabre/CalDAV/ServerTest.php | 31 + .../tests/Sabre/CalDAV/TestUtil.php | 207 ++ .../tests/Sabre/CalDAV/UserCalendarsTest.php | 174 ++ .../tests/Sabre/CalDAV/VersionTest.php | 15 + .../tests/Sabre/CalDAV/XMLUtilTest.php | 325 +++ .../Sabre/CardDAV/AbstractPluginTest.php | 30 + .../CardDAV/AddressBookQueryParserTest.php | 296 +++ .../Sabre/CardDAV/AddressBookQueryTest.php | 187 ++ .../Sabre/CardDAV/AddressBookRootTest.php | 27 + .../tests/Sabre/CardDAV/AddressBookTest.php | 147 ++ .../Sabre/CardDAV/Backend/AbstractPDOTest.php | 237 ++ .../Sabre/CardDAV/Backend/PDOMySQLTest.php | 55 + .../Sabre/CardDAV/Backend/PDOSqliteTest.php | 64 + .../tests/Sabre/CardDAV/CardTest.php | 128 ++ .../tests/Sabre/CardDAV/IDirectoryTest.php | 25 + .../tests/Sabre/CardDAV/MockBackend.php | 121 + .../tests/Sabre/CardDAV/MultiGetTest.php | 50 + .../tests/Sabre/CardDAV/PluginTest.php | 59 + .../Property/SupportedAddressDataTest.php | 39 + .../Sabre/CardDAV/UserAddressBooksTest.php | 151 ++ .../Sabre/CardDAV/ValidateFilterTest.php | 203 ++ .../tests/Sabre/CardDAV/VersionTest.php | 15 + .../tests/Sabre/DAV/AbstractServer.php | 56 + .../DAV/Auth/Backend/AbstractBasicTest.php | 77 + .../DAV/Auth/Backend/AbstractDigestTest.php | 150 ++ .../DAV/Auth/Backend/AbstractPDOTest.php | 31 + .../Sabre/DAV/Auth/Backend/ApacheTest.php | 40 + .../tests/Sabre/DAV/Auth/Backend/FileTest.php | 40 + .../Sabre/DAV/Auth/Backend/PDOMySQLTest.php | 29 + .../Sabre/DAV/Auth/Backend/PDOSqliteTest.php | 26 + .../tests/Sabre/DAV/Auth/MockBackend.php | 27 + .../tests/Sabre/DAV/Auth/PluginTest.php | 80 + .../tests/Sabre/DAV/BasicNodeTest.php | 232 ++ .../DAV/Browser/GuessContentTypeTest.php | 64 + .../DAV/Browser/MapGetToPropFindTest.php | 38 + .../tests/Sabre/DAV/Browser/PluginTest.php | 35 + .../tests/Sabre/DAV/ClientMock.php | 27 + .../tests/Sabre/DAV/ClientTest.php | 514 +++++ .../tests/Sabre/DAV/ExceptionTest.php | 28 + .../tests/Sabre/DAV/FSExt/FileTest.php | 65 + .../tests/Sabre/DAV/FSExt/NodeTest.php | 307 +++ .../tests/Sabre/DAV/FSExt/ServerTest.php | 222 ++ .../tests/Sabre/DAV/Issue33Test.php | 102 + .../Sabre/DAV/Locks/Backend/AbstractTest.php | 188 ++ .../tests/Sabre/DAV/Locks/Backend/FSTest.php | 29 + .../Sabre/DAV/Locks/Backend/FileTest.php | 22 + .../Sabre/DAV/Locks/Backend/PDOMySQLTest.php | 30 + .../tests/Sabre/DAV/Locks/Backend/PDOTest.php | 27 + .../Sabre/DAV/Locks/GetIfConditionsTest.php | 369 ++++ .../tests/Sabre/DAV/Locks/MSWordTest.php | 118 + .../tests/Sabre/DAV/Locks/PluginTest.php | 958 ++++++++ .../tests/Sabre/DAV/Mount/PluginTest.php | 53 + .../tests/Sabre/DAV/ObjectTreeTest.php | 98 + .../DAV/Property/GetLastModifiedTest.php | 63 + .../tests/Sabre/DAV/Property/HrefListTest.php | 88 + .../tests/Sabre/DAV/Property/HrefTest.php | 88 + .../Sabre/DAV/Property/ResourceTypeTest.php | 107 + .../tests/Sabre/DAV/Property/ResponseTest.php | 231 ++ .../DAV/Property/SupportedReportSetTest.php | 123 ++ .../tests/Sabre/DAV/ServerCopyMoveTest.php | 264 +++ .../tests/Sabre/DAV/ServerEventsTest.php | 53 + .../tests/Sabre/DAV/ServerFinderBlockTest.php | 54 + .../tests/Sabre/DAV/ServerMKCOLTest.php | 338 +++ .../tests/Sabre/DAV/ServerPluginTest.php | 94 + .../Sabre/DAV/ServerPreconditionTest.php | 368 ++++ .../tests/Sabre/DAV/ServerPropsTest.php | 395 ++++ .../tests/Sabre/DAV/ServerRangeTest.php | 273 +++ .../tests/Sabre/DAV/ServerSimpleTest.php | 685 ++++++ .../Sabre/DAV/ServerUpdatePropertiesTest.php | 127 ++ .../tests/Sabre/DAV/SimpleFileTest.php | 19 + .../tests/Sabre/DAV/StringUtilTest.php | 120 + .../Sabre/DAV/TemporaryFileFilterTest.php | 250 +++ .../tests/Sabre/DAV/TestPlugin.php | 32 + .../tests/Sabre/DAV/Tree/FilesystemTest.php | 72 + .../tests/Sabre/DAV/TreeTest.php | 173 ++ .../tests/Sabre/DAV/URLUtilTest.php | 129 ++ .../tests/Sabre/DAV/UUIDUtilTest.php | 23 + .../tests/Sabre/DAV/XMLUtilTest.php | 282 +++ .../tests/Sabre/DAVACL/ACLMethodTest.php | 326 +++ .../tests/Sabre/DAVACL/AllowAccessTest.php | 131 ++ .../tests/Sabre/DAVACL/BlockAccessTest.php | 182 ++ .../DAVACL/Exception/AceConflictTest.php | 35 + .../Exception/NeedPrivilegesExceptionTest.php | 45 + .../Sabre/DAVACL/Exception/NoAbstractTest.php | 35 + .../Exception/NotRecognizedPrincipalTest.php | 35 + .../Exception/NotSupportedPrivilegeTest.php | 35 + .../Sabre/DAVACL/ExpandPropertiesTest.php | 353 +++ .../tests/Sabre/DAVACL/MockACLNode.php | 45 + .../tests/Sabre/DAVACL/MockPrincipal.php | 61 + .../Sabre/DAVACL/MockPrincipalBackend.php | 57 + .../Sabre/DAVACL/PluginPropertiesTest.php | 361 +++ .../DAVACL/PluginUpdatePropertiesTest.php | 123 ++ .../PrincipalBackend/AbstractPDOTest.php | 100 + .../DAVACL/PrincipalBackend/PDOMySQLTest.php | 38 + .../DAVACL/PrincipalBackend/PDOSqliteTest.php | 36 + .../Sabre/DAVACL/PrincipalCollectionTest.php | 48 + .../DAVACL/PrincipalPropertySearchTest.php | 182 ++ .../DAVACL/PrincipalSearchPropertySetTest.php | 128 ++ .../tests/Sabre/DAVACL/PrincipalTest.php | 192 ++ .../tests/Sabre/DAVACL/Property/ACLTest.php | 223 ++ .../Property/CurrentUserPrivilegeSetTest.php | 41 + .../Sabre/DAVACL/Property/PrincipalTest.php | 176 ++ .../Property/SupportedPrivilegeSetTest.php | 99 + .../tests/Sabre/DAVACL/SimplePluginTest.php | 270 +++ .../tests/Sabre/DAVACL/VersionTest.php | 15 + .../tests/Sabre/HTTP/AWSAuthTest.php | 237 ++ .../tests/Sabre/HTTP/BasicAuthTest.php | 89 + .../tests/Sabre/HTTP/DigestAuthTest.php | 192 ++ .../tests/Sabre/HTTP/RequestTest.php | 139 ++ .../tests/Sabre/HTTP/ResponseMock.php | 29 + .../tests/Sabre/HTTP/ResponseTest.php | 60 + .../tests/Sabre/HTTP/UtilTest.php | 53 + .../tests/Sabre/HTTP/VersionTest.php | 15 + .../tests/Sabre/TestUtil.php | 49 + .../tests/Sabre/VObject/ComponentTest.php | 332 +++ .../Sabre/VObject/Element/DateTimeTest.php | 204 ++ .../VObject/Element/MultiDateTimeTest.php | 202 ++ .../tests/Sabre/VObject/ElementListTest.php | 32 + .../tests/Sabre/VObject/Issue153Test.php | 12 + .../tests/Sabre/VObject/ParameterTest.php | 21 + .../tests/Sabre/VObject/PropertyTest.php | 266 +++ .../tests/Sabre/VObject/ReaderTest.php | 226 ++ .../tests/Sabre/VObject/VersionTest.php | 15 + .../SabreDAV.1.5.7-stable/tests/bootstrap.php | 21 + .../SabreDAV.1.5.7-stable/tests/phpunit.xml | 21 + .../Baikal_0.1/Resources/baikal.empty.sqlite | Bin 0 -> 14336 bytes CoreVersions/Baikal_0.1/Scripts/adduser.php | 102 + .../Baikal_0.1/Scripts/inc/functions.php | 35 + CoreVersions/Baikal_0.1/Scripts/moduser.php | 106 + CoreVersions/Baikal_0.1/WWWRoot/cal.php | 56 + CoreVersions/Baikal_0.1/WWWRoot/card.php | 55 + CoreVersions/Baikal_0.1/WWWRoot/index.php | 41 + INSTALL.txt | 213 ++ LICENSE.txt | 674 ++++++ README.txt | 52 + Specific/config.php | 49 + Specific/db/baikal.sqlite | Bin 0 -> 14336 bytes Specific/virtualhosts/baikal.apache2 | 12 + html/cal.php | 1 + html/card.php | 1 + html/index.php | 1 + 337 files changed, 42834 insertions(+) create mode 120000 Core create mode 100644 CoreVersions/Baikal_0.1/Bootstrap.php create mode 120000 CoreVersions/Baikal_0.1/Frameworks/SabreDAV create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/ChangeLog create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/LICENSE create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/bin/naturalselection.py create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/.htdigest create mode 120000 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/Sabre create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/addressbookserver.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/basicauth.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/calendarserver.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/digestauth.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/fileserver.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/groupwareserver.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/simplefsserver.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.addressbook.sql create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.calendars.sql create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.locks.sql create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.principals.sql create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.users.sql create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.addressbooks.sql create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.calendars.sql create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.locks.sql create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.principals.sql create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.users.sql create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre.includes.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Backend/Abstract.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Backend/PDO.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Calendar.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/CalendarObject.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/CalendarRootNode.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Exception/InvalidICalendarObject.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/ICSExportPlugin.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/ICalendar.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/ICalendarObject.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/ICalendarUtil.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Plugin.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Principal/Collection.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Principal/ProxyRead.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Principal/ProxyWrite.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Principal/User.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Property/SupportedCalendarComponentSet.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Property/SupportedCalendarData.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Property/SupportedCollationSet.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Server.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/UserCalendars.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Version.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/XMLUtil.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/AddressBook.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/AddressBookQueryParser.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/AddressBookRoot.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/Backend/Abstract.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/Backend/PDO.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/Card.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/IAddressBook.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/ICard.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/IDirectory.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/Plugin.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/Property/SupportedAddressData.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/UserAddressBooks.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/Version.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/Backend/AbstractBasic.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/Backend/AbstractDigest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/Backend/Apache.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/Backend/File.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/Backend/PDO.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/IBackend.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/Plugin.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Browser/GuessContentType.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Browser/MapGetToPropFind.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Browser/Plugin.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Client.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Collection.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Directory.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/BadRequest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/Conflict.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/ConflictingLock.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/FileNotFound.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/Forbidden.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/InsufficientStorage.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/InvalidResourceType.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/LockTokenMatchesRequestUri.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/Locked.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/MethodNotAllowed.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/NotAuthenticated.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/NotImplemented.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/PreconditionFailed.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/ReportNotImplemented.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/RequestedRangeNotSatisfiable.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/UnsupportedMediaType.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FS/Directory.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FS/File.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FS/Node.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FSExt/Directory.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FSExt/File.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FSExt/Node.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/File.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/ICollection.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/IExtendedCollection.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/IFile.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/ILockable.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/INode.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/IProperties.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/IQuota.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Locks/Backend/Abstract.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Locks/Backend/FS.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Locks/Backend/File.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Locks/Backend/PDO.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Locks/LockInfo.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Locks/Plugin.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Mount/Plugin.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Node.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/ObjectTree.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/GetLastModified.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/Href.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/HrefList.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/IHref.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/LockDiscovery.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/ResourceType.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/Response.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/ResponseList.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/SupportedLock.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/SupportedReportSet.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Server.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/ServerPlugin.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/SimpleCollection.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/SimpleDirectory.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/SimpleFile.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/StringUtil.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/TemporaryFileFilterPlugin.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Tree.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Tree/Filesystem.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/URLUtil.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/UUIDUtil.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Version.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/XMLUtil.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/AbstractPrincipalCollection.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/AceConflict.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/NeedPrivileges.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/NoAbstract.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/NotRecognizedPrincipal.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/NotSupportedPrivilege.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/IACL.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/IPrincipal.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/IPrincipalBackend.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Plugin.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Principal.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/PrincipalBackend/PDO.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/PrincipalCollection.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Property/Acl.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Property/CurrentUserPrivilegeSet.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Property/Principal.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Property/SupportedPrivilegeSet.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Version.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/AWSAuth.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/AbstractAuth.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/BasicAuth.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/DigestAuth.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/Request.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/Response.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/Util.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/Version.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Component.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Element.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Element/DateTime.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Element/MultiDateTime.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/ElementList.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Node.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Parameter.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/ParseException.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Property.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Reader.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Version.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/includes.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/autoload.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Backend/AbstractTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Backend/Mock.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/CalendarObjectTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/CalendarQueryFilterTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/CalendarTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/ICSExportPluginTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/ICalendarUtilTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Issue166Test.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/PluginTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Principal/CollectionTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Principal/ProxyReadTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Principal/ProxyWriteTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Principal/UserTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Property/SupportedCalendarComponentSetTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Property/SupportedCalendarDataTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Property/SupportedCollationSetTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/ServerTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/TestUtil.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/UserCalendarsTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/VersionTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/XMLUtilTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AbstractPluginTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AddressBookQueryParserTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AddressBookQueryTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AddressBookRootTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AddressBookTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/Backend/PDOSqliteTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/CardTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/IDirectoryTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/MockBackend.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/MultiGetTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/PluginTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/Property/SupportedAddressDataTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/UserAddressBooksTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/ValidateFilterTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/VersionTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/AbstractServer.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/ApacheTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/FileTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/MockBackend.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/PluginTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/BasicNodeTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Browser/GuessContentTypeTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Browser/PluginTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ClientMock.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ClientTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ExceptionTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/FSExt/FileTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/FSExt/NodeTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/FSExt/ServerTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Issue33Test.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/Backend/AbstractTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/Backend/FSTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/Backend/FileTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/Backend/PDOTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/GetIfConditionsTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/MSWordTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/PluginTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Mount/PluginTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ObjectTreeTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/GetLastModifiedTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/HrefListTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/HrefTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/ResourceTypeTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/ResponseTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/SupportedReportSetTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerCopyMoveTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerEventsTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerFinderBlockTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerMKCOLTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerPluginTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerPreconditionTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerPropsTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerRangeTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerSimpleTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerUpdatePropertiesTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/SimpleFileTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/StringUtilTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/TemporaryFileFilterTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/TestPlugin.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Tree/FilesystemTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/TreeTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/URLUtilTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/UUIDUtilTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/XMLUtilTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/ACLMethodTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/AllowAccessTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/BlockAccessTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/AceConflictTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/NoAbstractTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/ExpandPropertiesTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/MockACLNode.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/MockPrincipal.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/MockPrincipalBackend.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PluginPropertiesTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalCollectionTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Property/ACLTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Property/CurrentUserPrivilegeSetTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Property/PrincipalTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Property/SupportedPrivilegeSetTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/SimplePluginTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/VersionTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/AWSAuthTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/BasicAuthTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/DigestAuthTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/RequestTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/ResponseMock.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/ResponseTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/UtilTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/VersionTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/TestUtil.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/ComponentTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/Element/DateTimeTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/Element/MultiDateTimeTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/ElementListTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/Issue153Test.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/ParameterTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/PropertyTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/ReaderTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/VersionTest.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/bootstrap.php create mode 100755 CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/phpunit.xml create mode 100755 CoreVersions/Baikal_0.1/Resources/baikal.empty.sqlite create mode 100755 CoreVersions/Baikal_0.1/Scripts/adduser.php create mode 100755 CoreVersions/Baikal_0.1/Scripts/inc/functions.php create mode 100755 CoreVersions/Baikal_0.1/Scripts/moduser.php create mode 100755 CoreVersions/Baikal_0.1/WWWRoot/cal.php create mode 100755 CoreVersions/Baikal_0.1/WWWRoot/card.php create mode 100755 CoreVersions/Baikal_0.1/WWWRoot/index.php create mode 100644 INSTALL.txt create mode 100644 LICENSE.txt create mode 100644 README.txt create mode 100755 Specific/config.php create mode 100755 Specific/db/baikal.sqlite create mode 100755 Specific/virtualhosts/baikal.apache2 create mode 120000 html/cal.php create mode 120000 html/card.php create mode 120000 html/index.php diff --git a/Core b/Core new file mode 120000 index 0000000..f6981be --- /dev/null +++ b/Core @@ -0,0 +1 @@ +CoreVersions/Baikal_0.1 \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Bootstrap.php b/CoreVersions/Baikal_0.1/Bootstrap.php new file mode 100644 index 0000000..2391dad --- /dev/null +++ b/CoreVersions/Baikal_0.1/Bootstrap.php @@ -0,0 +1,95 @@ + +* All rights reserved +* +* http://baikal.codr.fr +* +* This script is part of the Baïkal Server project. The Baïkal +* Server project is free software; you can redistribute it +* and/or modify it under the terms of the GNU General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* The GNU General Public License can be found at +* http://www.gnu.org/copyleft/gpl.html. +* +* This script is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* This copyright notice MUST APPEAR in all copies of the script! +***************************************************************/ + +if(!defined("BAIKAL_CONTEXT") || BAIKAL_CONTEXT !== TRUE) { + die("Bootstrap.php may not be included outside the Baikal context"); +} + +if(version_compare(PHP_VERSION, '5.2.0', '<')) { + die('Baikal Fatal Error: Baikal requires PHP 5.2.0+ to run properly. You version is: ' . PHP_VERSION . '.'); +} + +if(!defined('PDO::ATTR_DRIVER_NAME')) { + die('Baikal Fatal Error: PDO is unavailable. It\'s required by Baikal.'); +} + +if(!in_array('sqlite', PDO::getAvailableDrivers())) { + die('Baikal Fatal Error: PDO::sqlite is unavailable. It\'s required by Baikal.'); +} + +# determine Baïkal install root path +# adaptive, either ../../ or ../ relative to the Bootstrap +# not using realpath here as it resolves symlinks + +$sTemp = dirname(dirname(__FILE__)) . "/"; #../ if Baïkal distrib is at the same level than "Core" symlink +if(@file_exists($sTemp) && (@is_dir($sTemp . "Core") || @is_link($sTemp . "Core"))) { + define("BAIKAL_PATH_ROOT", $sTemp); # ../ +} else { + $sTemp = dirname($sTemp) . "/"; # ../../ relative to bootstrap + if(@file_exists($sTemp) && (@is_dir($sTemp . "Core") || @is_link($sTemp . "Core"))) { + define("BAIKAL_PATH_ROOT", $sTemp); # ../../ + } else { + die('Baikal Fatal Error: Unable to determine Baikal root path.'); + } +} + +define("BAIKAL_PATH_CORE", BAIKAL_PATH_ROOT . "Core/"); +define("BAIKAL_PATH_SPECIFIC", BAIKAL_PATH_ROOT . "Specific/"); + +require_once(BAIKAL_PATH_SPECIFIC . "config.php"); + +date_default_timezone_set(BAIKAL_TIMEZONE); + +# Check if DB exists +if(!file_exists(BAIKAL_SQLITE_FILE)) { + die("DB file does not exist.
To create it, please copy 'Core/Resources/baikal.empty.sqlite' to 'Specific/db/baikal.sqlite'.
Please note the change in the file name while doing so (from 'baikal.empty.sqlite' to 'baikal.sqlite')."); +} + +# Database +$pdo = new PDO('sqlite:' . BAIKAL_SQLITE_FILE); +$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); + +# Check if at least one user exists +if(!defined("BAIKAL_CONTEXT_CLI") || BAIKAL_CONTEXT_CLI === FALSE) { + if(($iNbUsers = intval($pdo->query('SELECT count(*) FROM users')->fetchColumn())) === 0) { + die("No users are defined.
To create a user, you can use the helper Core/Scripts/adduser.php (requires command line access)"); + } +} + + +if(!defined("BAIKAL_CONTEXT_CLI") || BAIKAL_CONTEXT_CLI === FALSE) { + # Mapping PHP errors to exceptions + function exception_error_handler($errno, $errstr, $errfile, $errline) { + throw new ErrorException($errstr, 0, $errno, $errfile, $errline); + } + + set_error_handler("exception_error_handler"); +} else { + error_reporting(E_ALL ^ E_NOTICE); +} + +// Autoloader +require_once(BAIKAL_PATH_SABREDAV . 'autoload.php'); diff --git a/CoreVersions/Baikal_0.1/Frameworks/SabreDAV b/CoreVersions/Baikal_0.1/Frameworks/SabreDAV new file mode 120000 index 0000000..4d2f8a8 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/SabreDAV @@ -0,0 +1 @@ +Versions/SabreDAV.1.5.7-stable \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/ChangeLog b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/ChangeLog new file mode 100755 index 0000000..df4cf39 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/ChangeLog @@ -0,0 +1,636 @@ +1.5.7-stable (2012-02-19) + * Fixed: VObject properties are now always encoded before components. + * Fixed: Sabre_DAVACL had issues with multiple levels of privilege + aggregration. + * Changed: Added 'GuessContentType' plugin to fileserver.php example. + * Fixed: The Browser plugin will now trigger the correct events when + creating files. + * Fixed: The ICSExportPlugin now considers ACL's. + * Added: Made it optional to supply carddata from an Addressbook backend + when requesting getCards. This can make some operations much faster, and + could result in much lower memory use. + * Fixed: Issue 187: Sabre_DAV_UUIDUtil was missing from includes file. + * Fixed: Issue 191: beforeUnlock was triggered twice. + +1.5.6-stable (2012-01-07) + * Fixed: Issue 174: VObject could break UTF-8 characters. + * Fixed: pear package installation issues. + +1.5.5-stable (2011-12-16) + * Fixed: CalDAV time-range filter workaround for recurring events. + * Fixed: Bug in Sabre_DAV_Locks_Backend_File that didn't allow multiple + files to be locked at the same time. + +1.5.4-stable (2011-10-28) + * Fixed: GuessContentType plugin now supports mixed case file extensions. + * Fixed: DATE-TIME encoding was wrong in VObject. (we used 'DATETIME'). + * Changed: Sending back HTTP 204 after a PUT request on an existing resource + instead of HTTP 200. This should fix Evolution CardDAV client + compatibility. + * Fixed: Issue 95: Parsing X-LIC-LOCATION if it's available. + * Added: All VObject elements now have a reference to their parent node. + +1.5.3-stable (2011-09-28) + * Fixed: Sabre_DAV_Collection was missing from the includes file. + * Fixed: Issue 152. iOS 1.4.2 apparantly requires HTTP/1.1 200 OK to be in + uppercase. + * Fixed: Issue 153: Support for files with mixed newline styles in + Sabre_VObject. + * Fixed: Issue 159: Automatically converting any vcard and icalendardata + to UTF-8. + * Added: Sabre_DAV_SimpleFile class for easy static file creation. + * Added: Issue 158: Support for the CARDDAV:supported-address-data + property. + +1.5.2-stable (2011-09-21) + * Fixed: carddata and calendardata MySQL fields are now of type + 'mediumblob'. 'TEXT' was too small sometimes to hold all the data. + * Fixed: {DAV:}supported-report-set is now correctly reporting the reports + for IAddressBook. + * Added: Sabre_VObject_Property::add() to add duplicate parameters to + properties. + * Added: Issue 151: Sabre_CalDAV_ICalendar and Sabre_CalDAV_ICalendarObject + interfaces. + * Fixed: Issue 140: Not returning 201 Created if an event cancelled the + creation of a file. + * Fixed: Issue 150: Faster URLUtil::encodePath() implementation. + * Fixed: Issue 144: Browser plugin could interfere with + TemporaryFileFilterPlugin if it was loaded first. + * Added: It's not possible to specify more 'alternate uris' in principal + backends. + +1.5.1-stable (2011-08-24) + * Fixed: Issue 137. Hiding action interface in HTML browser for + non-collections. + * Fixed: addressbook-query is now correctly returned from the + {DAV:}supported-report-set property. + * Fixed: Issue 142: Bugs in groupwareserver.php example. + * Fixed: Issue 139: Rejecting PUT requests with Content-Range. + +1.5.0-stable (2011-08-12) + * Added: CardDAV support. + * Added: An experimental WebDAV client. + * Added: MIME-Directory grouping support in the VObject library. This is + very useful for people attempting to parse vcards. + * BC Break: Adding parameters with the VObject libraries now overwrites + the previous parameter, rather than just add it. This makes more sense + for 99% of the cases. + * BC Break: lib/Sabre.autoload.php is now removed in favor of + lib/Sabre/autoload.php. + * Deprecated: Sabre_DAV_Directory is now deprecated and will be removed in + a future version. Use Sabre_DAV_Collection instead. + * Deprecated: Sabre_DAV_SimpleDirectory is now deprecated and will be + removed in a future version. Use Sabre_DAV_SimpleCollection instead. + * Fixed: Problem with overriding tablenames for the CalDAV backend. + * Added: Clark-notation parser to XML utility. + * Added: unset() support to VObject components. + * Fixed: Refactored CalDAV property fetching to be faster and simpler. + * Added: Central string-matcher for CalDAV and CardDAV plugins. + * Added: i;unicode-casemap support + * Fixed: VObject bug: wouldn't parse parameters if they weren't specified + in uppercase. + * Fixed: VObject bug: Parameters now behave more like Properties. + * Fixed: VObject bug: Parameters with no value are now correctly parsed. + * Changed: If calendars don't specify which components they allow, 'all' + components are assumed (e.g.: VEVENT, VTODO, VJOURNAL). + * Changed: Browser plugin now uses POST variable 'sabreAction' instead of + 'action' to reduce the chance of collisions. + +1.4.4-stable (2011-07-07) + * Fixed: Issue 131: Custom CalDAV backends could break in certain cases. + * Added: The option to override the default tablename all PDO backends + use. (Issue 60). + * Fixed: Issue 124: 'File' authentication backend now takes realm into + consideration. + * Fixed: Sabre_DAV_Property_HrefList now properly deserializes. This + allows users to update the {DAV:}group-member-set property. + * Added: Helper functions for DateTime-values in Sabre_VObject package. + * Added: VObject library can now automatically map iCalendar properties to + custom classes. + +1.4.3-stable (2011-04-25) + * Fixed: Issue 123: Added workaround for Windows 7 UNLOCK bug. + * Fixed: datatype of lastmodified field in mysql.calendars.sql. Please + change the DATETIME field to an INT to ensure this field will work + correctly. + * Change: Sabre_DAV_Property_Principal is now renamed to + Sabre_DAVACL_Property_Principal. + * Added: API level support for ACL HTTP method. + * Fixed: Bug in serializing {DAV:}acl property. + * Added: deserializer for {DAV:}resourcetype property. + * Added: deserializer for {DAV:}acl property. + * Added: deserializer for {DAV:}principal property. + +1.4.2-beta (2011-04-01) + * Added: It's not possible to disable listing of nodes that are denied + read access by ACL. + * Fixed: Changed a few properties in CalDAV classes from private to + protected. + * Fixed: Issue 119: Terrible things could happen when relying on + guessBaseUri, the server was running on the root of the domain and a user + tried to access a file ending in .php. This is a slight BC break. + * Fixed: Issue 118: Lock tokens in If headers without a uri should be + treated as the request uri, not 'all relevant uri's. + * Fixed: Issue 120: PDO backend was incorrectly fetching too much locks in + cases where there were similar named locked files in a directory. + +1.4.1-beta (2011-02-26) + * Fixed: Sabre_DAV_Locks_Backend_PDO returned too many locks. + * Fixed: Sabre_HTTP_Request::getHeader didn't return Content-Type when + running on apache, so a few workarounds were added. + * Change: Slightly changed CalDAV Backend API's, to allow for heavy + optimizations. This is non-bc breaking. + +1.4.0-beta (2011-02-12) + * Added: Partly RFC3744 ACL support. + * Added: Calendar-delegation (caldav-proxy) support. + * BC break: In order to fix Issue 99, a new argument had to be added to + Sabre_DAV_Locks_Backend_*::getLocks classes. Consult the classes for + details. + * Deprecated: Sabre_DAV_Locks_Backend_FS is now deprecated and will be + removed in a later version. Use PDO or the new File class instead. + * Deprecated: The Sabre_CalDAV_ICalendarUtil class is now marked + deprecated, and will be removed in a future version. Please use + Sabre_VObject instead. + * Removed: All principal-related functionality has been removed from the + Sabre_DAV_Auth_Plugin, and moved to the Sabre_DAVACL_Plugin. + * Added: VObject library, for easy vcard/icalendar parsing using a natural + interface. + * Added: Ability to automatically generate full .ics feeds off calendars. + To use: Add the Sabre_CalDAV_ICSExportPlugin, and add ?export to your + calendar url. + * Added: Plugins can now specify a pluginname, for easy access using + Sabre_DAV_Server::getPlugin(). + * Added: beforeGetProperties event. + * Added: updateProperties event. + * Added: Principal listings and calendar-access can now be done privately, + disallowing users from accessing or modifying other users' data. + * Added: You can now pass arrays to the Sabre_DAV_Server constructor. If + it's an array with node-objects, a Root collection will automatically be + created, and the nodes are used as top-level children. + * Added: The principal base uri is now customizable. It used to be + hardcoded to 'principals/[user]'. + * Added: getSupportedReportSet method in ServerPlugin class. This allows + you to easily specify which reports you're implementing. + * Added: A '..' link to the HTML browser. + * Fixed: Issue 99: Locks on child elements were ignored when their parent + nodes were deleted. + * Fixed: Issue 90: lockdiscovery property and LOCK response now include a + {DAV}lockroot element. + * Fixed: Issue 96: support for 'default' collation in CalDAV text-match + filters. + * Fixed: Issue 102: Ensuring that copy and move with identical source and + destination uri's fails. + * Fixed: Issue 105: Supporting MKCALENDAR with no body. + * Fixed: Issue 109: Small fixes in Sabre_HTTP_Util. + * Fixed: Issue 111: Properly catching the ownername in a lock (if it's a + string) + * Fixed: Sabre_DAV_ObjectTree::nodeExist always returned false for the + root node. + * Added: Global way to easily supply new resourcetypes for cetain node + classes. + * Fixed: Issue 59: Allowing the user to override the authentication realm + in Sabre_CalDAV_Server. + * Update: Issue 97: Looser time-range checking if there's a reccurrence + rule in an event. This fixes 'missing recurring events'. + +1.3.0 (2010-10-14) + * Added: childExists method to Sabre_DAV_ICollection. This is an api + break, so if you implement Sabre_DAV_ICollection directly, add the method. + * Changed: Almost all HTTP method implementations now take a uri argument, + including events. This allows for internal rerouting of certain calls. + If you have custom plugins, make sure they use this argument. If they + don't, they will likely still work, but it might get in the way of + future changes. + * Changed: All getETag methods MUST now surround the etag with + double-quotes. This was a mistake made in all previous SabreDAV + versions. If you don't do this, any If-Match, If-None-Match and If: + headers using Etags will work incorrectly. (Issue 85). + * Added: Sabre_DAV_Auth_Backend_AbstractBasic class, which can be used to + easily implement basic authentication. + * Removed: Sabre_DAV_PermissionDenied class. Use Sabre_DAV_Forbidden + instead. + * Removed: Sabre_DAV_IDirectory interface, use Sabre_DAV_ICollection + instead. + * Added: Browser plugin now uses {DAV:}displayname if this property is + available. + * Added: Cache layer in the ObjectTree. + * Added: Tree classes now have a delete and getChildren method. + * Fixed: If-Modified-Since and If-Unmodified-Since would be incorrect if + the date is an exact match. + * Fixed: Support for multiple ETags in If-Match and If-None-Match headers. + * Fixed: Improved baseUrl handling. + * Fixed: Issue 67: Non-seekable stream support in ::put()/::get(). + * Fixed: Issue 65: Invalid dates are now ignored. + * Updated: Refactoring in Sabre_CalDAV to make everything a bit more + ledgable. + * Fixed: Issue 88, Issue 89: Fixed compatibility for running SabreDAV on + Windows. + * Fixed: Issue 86: Fixed Content-Range top-boundary from 'file size' to + 'file size'-1. + +1.2.4 (2010-07-13) + * Fixed: Issue 62: Guessing baseUrl fails when url contains a + query-string. + * Added: Apache configuration sample for CGI/FastCGI setups. + * Fixed: Issue 64: Only returning calendar-data when it was actually + requested. + +1.2.3 (2010-06-26) + * Fixed: Issue 57: Supporting quotes around etags in If-Match and + If-None-Match + +1.2.2 (2010-06-21) + * Updated: SabreDAV now attempts to guess the BaseURI if it's not set. + * Updated: Better compatibility with BitKinex + * Fixed: Issue 56: Incorrect behaviour for If-None-Match headers and GET + requests. + * Fixed: Issue with certain encoded paths in Browser Plugin. + +1.2.1 (2010-06-07) + * Fixed: Issue 50, patch by Mattijs Hoitink. + * Fixed: Issue 51, Adding windows 7 lockfiles to TemporaryFileFilter. + * Fixed: Issue 38, Allowing custom filters to be added to + TemporaryFileFilter. + * Fixed: Issue 53, ETags in the If: header were always failing. This + behaviour is now corrected. + * Added: Apache Authentication backend, in case authentication through + .htaccess is desired. + * Updated: Small improvements to example files. + +1.2.0 (2010-05-24) + * Fixed: Browser plugin now displays international characters. + * Changed: More properties in CalDAV classes are now protected instead of + private. + +1.2.0beta3 (2010-05-14) + * Fixed: Custom properties were not propertly sent back for allprops + requests. + * Fixed: Issue 49, incorrect parsing of PROPPATCH, affecting Office 2007. + * Changed: Removed CalDAV items from includes.php, and added a few missing + ones. + +1.2.0beta2 (2010-05-04) + * Fixed: Issue 46: Fatal error for some non-existant nodes. + * Updated: some example sql to include email address. + * Added: 208 and 508 statuscodes from RFC5842. + * Added: Apache2 configuration examples + +1.2.0beta1 (2010-04-28) + * Fixed: redundant namespace declaration in resourcetypes. + * Fixed: 2 locking bugs triggered by litmus when no Sabre_DAV_ILockable + interface is used. + * Changed: using http://sabredav.org/ns for all custom xml properties. + * Added: email address property to principals. + * Updated: CalendarObject validation. + +1.2.0alpha4 (2010-04-24) + * Added: Support for If-Range, If-Match, If-None-Match, If-Modified-Since, + If-Unmodified-Since. + * Changed: Brand new build system. Functionality is split up between + Sabre, Sabre_HTTP, Sabre_DAV and Sabre_CalDAV packages. In addition to + that a new non-pear package will be created with all this functionality + combined. + * Changed: Autoloader moved to Sabre/autoload.php. + * Changed: The Allow: header is now more accurate, with appropriate HTTP + methods per uri. + * Changed: Now throwing back Sabre_DAV_Exception_MethodNotAllowed on a few + places where Sabre_DAV_Exception_NotImplemented was used. + +1.2.0alpha3 (2010-04-20) + * Update: Complete rewrite of property updating. Now easier to use and + atomic. + * Fixed: Issue 16, automatically adding trailing / to baseUri. + * Added: text/plain is used for .txt files in GuessContentType plugin. + * Added: support for principal-property-search and + principal-search-property-set reports. + * Added: Issue 31: Hiding exception information by default. Can be turned + on with the Sabre_DAV_Server::$debugExceptions property. + +1.2.0alpha2 (2010-04-08) + * Added: Calendars are now private and can only be read by the owner. + * Fixed: double namespace declaration in multistatus responses. + * Added: MySQL database dumps. MySQL is now also supported next to SQLite. + * Added: expand-properties REPORT from RFC 3253. + * Added: Sabre_DAV_Property_IHref interface for properties exposing urls. + * Added: Issue 25: Throwing error on broken Finder behaviour. + * Changed: Authentication backend is now aware of current user. + +1.2.0alpha1 (2010-03-31) + * Fixed: Issue 26: Workaround for broken GVFS behaviour with encoded + special characters. + * Fixed: Issue 34: Incorrect Lock-Token response header for LOCK. Fixes + Office 2010 compatibility. + * Added: Issue 35: SabreDAV version to header to OPTIONS response to ease + debugging. + * Fixed: Issue 36: Incorrect variable name, throwing error in some + requests. + * Fixed: Issue 37: Incorrect smultron regex in temporary filefilter. + * Fixed: Issue 33: Converting ISO-8859-1 characters to UTF-8. + * Fixed: Issue 39 & Issue 40: Basename fails on non-utf-8 locales. + * Added: More unittests. + * Added: SabreDAV version to all error responses. + * Added: URLUtil class for decoding urls. + * Changed: Now using pear.sabredav.org pear channel. + * Changed: Sabre_DAV_Server::getCopyAndMoveInfo is now a public method. + +1.1.2-alpha (2010-03-18) + * Added: RFC5397 - current-user-principal support. + * Fixed: Issue 27: encoding entities in property responses. + * Added: naturalselection script now allows the user to specify a 'minimum + number of bytes' for deletion. This should reduce load due to less + crawling + * Added: Full support for the calendar-query report. + * Added: More unittests. + * Added: Support for complex property deserialization through the static + ::unserialize() method. + * Added: Support for modifying calendar-component-set + * Fixed: Issue 29: Added TIMEOUT_INFINITE constant + +1.1.1-alpha (2010-03-11) + * Added: RFC5689 - Extended MKCOL support. + * Fixed: Evolution support for CalDAV. + * Fixed: PDO-locks backend was pretty much completely broken. This is + 100% unittested now. + * Added: support for ctags. + * Fixed: Comma's between HTTP methods in 'Allow' method. + * Changed: default argument for Sabre_DAV_Locks_Backend_FS. This means a + datadirectory must always be specified from now on. + * Changed: Moved Sabre_DAV_Server::parseProps to + Sabre_DAV_XMLUtil::parseProperties. + * Changed: Sabre_DAV_IDirectory is now Sabre_DAV_ICollection. + * Changed: Sabre_DAV_Exception_PermissionDenied is now + Sabre_DAV_Exception_Forbidden. + * Changed: Sabre_CalDAV_ICalendarCollection is removed. + * Added: Sabre_DAV_IExtendedCollection. + * Added: Many more unittests. + * Added: support for calendar-timezone property. + +1.1.0-alpha (2010-03-01) + * Added: CalDAV - RFC 4791 + * Removed: Sabre_PHP_Exception. PHP has a built-in ErrorException for + this. + * Added: PDO authentication backend. + * Added: Example sql for auth, caldav, locks for sqlite. + * Added: Sabre_DAV_Browser_GuessContentType plugin + * Changed: Authentication plugin refactored, making it possible to + implement non-digest authentication. + * Fixed: Better error display in browser plugin. + * Added: Support for {DAV:}supported-report-set + * Added: XML utility class with helper functions for the WebDAV protocol. + * Added: Tons of unittests + * Added: PrincipalCollection and Principal classes + * Added: Sabre_DAV_Server::getProperties for easy property retrieval + * Changed: {DAV:}resourceType defaults to 0 + * Changed: Any non-null resourceType now gets a / appended to the href + value. Before this was just for {DAV:}collection's, but this is now also + the case for for example {DAV:}principal. + * Changed: The Href property class can now optionally create non-relative + uri's. + * Changed: Sabre_HTTP_Response now returns false if headers are already + sent and header-methods are called. + * Fixed: Issue 19: HEAD requests on Collections + * Fixed: Issue 21: Typo in Sabre_DAV_Property_Response + * Fixed: Issue 18: Doesn't work with Evolution Contacts + +1.0.5-stable (2010-01-22) + * Fixed: Fatal error when a malformed url was used for unlocking, in + conjuction with Sabre.autoload.php due to a incorrect filename. + * Fixed: Improved unittests and build system + +1.0.4-stable (2010-01-11) + * Fixed: needed 2 different releases. One for googlecode and one for + pearfarm. This is to retain the old method to install SabreDAV until + pearfarm becomes the standard installation method. + +1.0.3-stable (2010-01-11) + * Added: RFC4709 support (davmount) + * Added: 6 unittests + * Added: naturalselection. A tool to keep cache directories below a + specified theshold. + * Changed: Now using pearfarm.org channel server. + +1.0.1-stable (2009-12-22) + * Fixed: Issue 15: typos in examples + * Fixed: Minor pear installation issues + +1.0.0-stable (2009-11-02) + * Added: SimpleDirectory class. This class allows creating static + directory structures with ease. + * Changed: Custom complex properties and exceptions now get an instance of + Sabre_DAV_Server as their first argument in serialize() + * Changed: Href complex property now prepends server's baseUri + * Changed: delete before an overwriting copy/move is now handles by server + class instead of tree classes + * Changed: events must now explicitly return false to stop execution. + Before, execution would be stopped by anything loosely evaluating to + false. + * Changed: the getPropertiesForPath method now takes a different set of + arguments, and returns a different response. This allows plugin + developers to return statuses for properties other than 200 and 404. The + hrefs are now also always calculated relative to the baseUri, and not + the uri of the request. + * Changed: generatePropFindResponse is renamed to generateMultiStatus, and + now takes a list of properties similar to the response of + getPropertiesForPath. This was also needed to improve flexibility for + plugin development. + * Changed: Auth plugins are no longer included. They were not yet stable + quality, so they will probably be reintroduced in a later version. + * Changed: PROPPATCH also used generateMultiStatus now. + * Removed: unknownProperties event. This is replaced by the + afterGetProperties event, which should provide more flexibility. + * Fixed: Only calling getSize() on IFile instances in httpHead() + * Added: beforeBind event. This is invoked upon file or directory creation + * Added: beforeWriteContent event, this is invoked by PUT and LOCK on an + existing resource. + * Added: beforeUnbind event. This is invoked right before deletion of any + resource. + * Added: afterGetProperties event. This event can be used to make + modifications to property responses. + * Added: beforeLock and beforeUnlock events. + * Added: afterBind event. + * Fixed: Copy and Move could fail in the root directory. This is now + fixed. + * Added: Plugins can now be retrieved by their classname. This is useful + for inter-plugin communication. + * Added: The Auth backend can now return usernames and user-id's. + * Added: The Auth backend got a getUsers method + * Added: Sabre_DAV_FSExt_Directory now returns quota info + +0.12.1-beta (2009-09-11) + * Fixed: UNLOCK bug. Unlock didn't work at all + +0.12-beta (2009-09-10) + * Updated: Browser plugin now shows multiple {DAV:}resourcetype values + if available. + * Added: Experimental PDO backend for Locks Manager + * Fixed: Sending Content-Length: 0 for every empty response. This + improves NGinx compatibility. + * Fixed: Last modification time is reported in UTC timezone. This improves + Finder compatibility. + +0.11-beta (2009-08-11) + * Updated: Now in Beta + * Updated: Pear package no longer includes docs/ directory. These just + contained rfc's, which are publically available. This reduces the + package from ~800k to ~60k + * Added: generatePropfindResponse now takes a baseUri argument + * Added: ResourceType property can now contain multiple resourcetypes. + * Fixed: Issue 13. + +0.10-alpha (2009-08-03) + * Added: Plugin to automatically map GET requests to non-files to + PROPFIND (Sabre_DAV_Browser_MapGetToPropFind). This should allow + easier debugging of complicated WebDAV setups. + * Added: Sabre_DAV_Property_Href class. For future use. + * Added: Ability to choose to use auth-int, auth or both for HTTP Digest + authentication. (Issue 11) + * Changed: Made more methods in Sabre_DAV_Server public. + * Fixed: TemporaryFileFilter plugin now intercepts HTTP LOCK requests + to non-existant files. (Issue 12) + * Added: Central list of defined xml namespace prefixes. This can reduce + Bandwidth and legibility for xml bodies with user-defined namespaces. + * Added: now a PEAR-compatible package again, thanks to Michael Gauthier + * Changed: moved default copy and move logic from ObjectTree to Tree class + +0.9-alpha (2009-07-21) + * Changed: Major refactoring, removed most of the logic from the Tree + objects. The Server class now directly works with the INode, IFile + and IDirectory objects. If you created your own Tree objects, + this will most likely break in this release. + * Changed: Moved all the Locking logic from the Tree and Server classes + into a separate plugin. + * Changed: TemporaryFileFilter is now a plugin. + * Added: Comes with an autoloader script. This can be used instead of + the includer script, and is preferered by some people. + * Added: AWS Authentication class. + * Added: simpleserversetup.py script. This will quickly get a fileserver + up and running. + * Added: When subscribing to events, it is now possible to supply a + priority. This is for example needed to ensure that the Authentication + Plugin is used before any other Plugin. + * Added: 22 new tests. + * Added: Users-manager plugin for .htdigest files. Experimental and + subject to change. + * Added: RFC 2324 HTTP 418 status code + * Fixed: Exclusive locks could in some cases be picked up as shared locks + * Fixed: Digest auth for non-apache servers had a bug (still not actually + tested this well). + +0.8-alpha (2009-05-30) + * Changed: Renamed all exceptions! This is a compatibility break. Every + Exception now follows Sabre_DAV_Exception_FileNotFound convention + instead of Sabre_DAV_FileNotFoundException. + * Added: Browser plugin now allows uploading and creating directories + straight from the browser. + * Added: 12 more unittests + * Fixed: Locking bug, which became prevalent on Windows Vista. + * Fixed: Netdrive support + * Fixed: TemporaryFileFilter filtered out too many files. Fixed some + of the regexes. + * Fixed: Added README and ChangeLog to package + +0.7-alpha (2009-03-29) + * Added: System to return complex properties from PROPFIND. + * Added: support for {DAV:}supportedlock. + * Added: support for {DAV:}lockdiscovery. + * Added: 6 new tests. + * Added: New plugin system. + * Added: Simple HTML directory plugin, for browser access. + * Added: Server class now sends back standard pre-condition error xml + bodies. This was new since RFC4918. + * Added: Sabre_DAV_Tree_Aggregrate, which can 'host' multiple Tree objects + into one. + * Added: simple basis for HTTP REPORT method. This method is not used yet, + but can be used by plugins to add reports. + * Changed: ->getSize is only called for files, no longer for collections. + r303 + * Changed: Sabre_DAV_FilterTree is now Sabre_DAV_Tree_Filter + * Changed: Sabre_DAV_TemporaryFileFilter is now called + Sabre_DAV_Tree_TemporaryFileFilter. + * Changed: removed functions (get(/set)HTTPRequest(/Response)) from Server + class, and using a public property instead. + * Fixed: bug related to parsing proppatch and propfind requests. Didn't + show up in most clients, but it needed fixing regardless. (r255) + * Fixed: auth-int is now properly supported within HTTP Digest. + * Fixed: Using application/xml for a mimetype vs. text/xml as per RFC4918 + sec 8.2. + * Fixed: TemporaryFileFilter now lets through GET's if they actually + exist on the backend. (r274) + * FIxed: Some methods didn't get passed through in the FilterTree (r283). + * Fixed: LockManager is now slightly more complex, Tree classes slightly + less. (r287) + +0.6-alpha (2009-02-16) + * Added: Now uses streams for files, instead of strings. + This means it won't require to hold entire files in memory, which can be + an issue if you're dealing with big files. Note that this breaks + compatibility for put() and createFile methods. + * Added: HTTP Digest Authentication helper class. + * Added: Support for HTTP Range header + * Added: Support for ETags within If: headers + * Added: The API can now return ETags and override the default Content-Type + * Added: starting with basic framework for unittesting, using PHPUnit. + * Added: 49 unittests. + * Added: Abstraction for the HTTP request. + * Updated: Using Clark Notation for tags in properties. This means tags + are serialized as {namespace}tagName instead of namespace#tagName + * Fixed: HTTP_BasicAuth class now works as expected. + * Fixed: DAV_Server uses / for a default baseUrl. + * Fixed: Last modification date is no longer ignored in PROPFIND. + * Fixed: PROPFIND now sends back information about the requestUri even + when "Depth: 1" is specified. + +0.5-alpha (2009-01-14) + * Added: Added a very simple example for implementing a mapping to PHP + file streams. This should allow easy implementation of for example a + WebDAV to FTP proxy. + * Added: HTTP Basic Authentication helper class. + * Added: Sabre_HTTP_Reponse class. This centralizes HTTP operations and + will be a start towards the creating of a testing framework. + * Updated: Backwards compatibility break: all require_once() statements + are removed + from all the files. It is now recommended to use autoloading of + classes, or just including lib/Sabre.includes.php. This fix was made + to allow easier integration into applications not using this standard + inclusion model. + * Updated: Better in-file documentation. + * Updated: Sabre_DAV_Tree can now work with Sabre_DAV_LockManager. + * Updated: Fixes a shared-lock bug. + * Updated: Removed ?> from the bottom of each php file. + * Updated: Split up some operations from Sabre_DAV_Server to + Sabre_HTTP_Response. + * Fixed: examples are now actually included in the pear package. + +0.4-alpha (2008-11-05) + * Passes all litmus tests! + * Added: more examples + * Added: Custom property support + * Added: Shared lock support + * Added: Depth support to locks + * Added: Locking on unmapped urls (non-existant nodes) + * Fixed: Advertising as WebDAV class 3 support + +0.3-alpha (2008-06-29) + * Fully working in MS Windows clients. + * Added: temporary file filter: support for smultron files. + * Added: Phing build scripts + * Added: PEAR package + * Fixed: MOVE bug identied using finder. + * Fixed: Using gzuncompress instead of gzdecode in the temporary file + filter. This seems more common. + +0.2-alpha (2008-05-27) + * Somewhat working in Windows clients + * Added: Working PROPPATCH method (doesn't support custom properties yet) + * Added: Temporary filename handling system + * Added: Sabre_DAV_IQuota to return quota information + * Added: PROPFIND now reads the request body and only supplies the + requested properties + +0.1-alpha (2008-04-04) + * First release! + * Passes litmus: basic, http and copymove test. + * Fully working in Finder and DavFSv2 + +Project started: 2007-12-13 diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/LICENSE b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/LICENSE new file mode 100755 index 0000000..e038f6e --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/LICENSE @@ -0,0 +1,28 @@ +Copyright (C) 2007-2012 Rooftop Solutions. +Copyright (C) 2007-2009 FileMobile inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the SabreDAV nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/bin/naturalselection.py b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/bin/naturalselection.py new file mode 100755 index 0000000..a924f7a --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/bin/naturalselection.py @@ -0,0 +1,140 @@ +#!/usr/bin/env python + +# +# Copyright (c) 2009-2010 Evert Pot +# All rights reserved. +# http://www.rooftopsolutions.nl/ +# +# This utility is distributed along with SabreDAV +# license: http://code.google.com/p/sabredav/wiki/License Modified BSD License + +import os +from optparse import OptionParser +import time + +def getfreespace(path): + stat = os.statvfs(path) + return stat.f_frsize * stat.f_bavail + +def getbytesleft(path,treshold): + return getfreespace(path)-treshold + +def run(cacheDir, treshold, sleep=5, simulate=False, min_erase = 0): + + bytes = getbytesleft(cacheDir,treshold) + if (bytes>0): + print "Bytes to go before we hit treshhold:", bytes + else: + print "Treshold exceeded with:", -bytes, "bytes" + dir = os.listdir(cacheDir) + dir2 = [] + for file in dir: + path = cacheDir + '/' + file + dir2.append({ + "path" : path, + "atime": os.stat(path).st_atime, + "size" : os.stat(path).st_size + }) + + dir2.sort(lambda x,y: int(x["atime"]-y["atime"])) + + filesunlinked = 0 + gainedspace = 0 + + # Left is the amount of bytes that need to be freed up + # The default is the 'min_erase setting' + left = min_erase + + # If the min_erase setting is lower than the amount of bytes over + # the treshold, we use that number instead. + if left < -bytes : + left = -bytes + + print "Need to delete at least:", left; + + for file in dir2: + + # Only deleting files if we're not simulating + if not simulate: os.unlink(file["path"]) + left = int(left - file["size"]) + gainedspace = gainedspace + file["size"] + filesunlinked = filesunlinked + 1 + + if(left<0): + break + + print "%d files deleted (%d bytes)" % (filesunlinked, gainedspace) + + + time.sleep(sleep) + + + +def main(): + parser = OptionParser( + version="naturalselecton v0.3", + description="Cache directory manager. Deletes cache entries based on accesstime and free space tresholds.\n" + + "This utility is distributed alongside SabreDAV.", + usage="usage: %prog [options] cacheDirectory", + ) + parser.add_option( + '-s', + dest="simulate", + action="store_true", + help="Don't actually make changes, but just simulate the behaviour", + ) + parser.add_option( + '-r','--runs', + help="How many times to check before exiting. -1 is infinite, which is the default", + type="int", + dest="runs", + default=-1 + ) + parser.add_option( + '-n','--interval', + help="Sleep time in seconds (default = 5)", + type="int", + dest="sleep", + default=5 + ) + parser.add_option( + '-l','--treshold', + help="Treshhold in bytes (default = 10737418240, which is 10GB)", + type="int", + dest="treshold", + default=10737418240 + ) + parser.add_option( + '-m', '--min-erase', + help="Minimum number of bytes to erase when the treshold is reached. " + + "Setting this option higher will reduce the amount of times the cache directory will need to be scanned. " + + "(the default is 1073741824, which is 1GB.)", + type="int", + dest="min_erase", + default=1073741824 + ) + + options,args = parser.parse_args() + if len(args)<1: + parser.error("This utility requires at least 1 argument") + cacheDir = args[0] + + print "Natural Selection" + print "Cache directory:", cacheDir + free = getfreespace(cacheDir); + print "Current free disk space:", free + + runs = options.runs; + while runs!=0 : + run( + cacheDir, + sleep=options.sleep, + simulate=options.simulate, + treshold=options.treshold, + min_erase=options.min_erase + ) + if runs>0: + runs = runs - 1 + +if __name__ == '__main__' : + main() diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/.htdigest b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/.htdigest new file mode 100755 index 0000000..020db74 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/.htdigest @@ -0,0 +1 @@ +jerome:Domaine:69b58669c7c355c2a7c85395b27421b5 diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/Sabre b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/Sabre new file mode 120000 index 0000000..9fd460f --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/Sabre @@ -0,0 +1 @@ +../lib/Sabre \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/addressbookserver.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/addressbookserver.php new file mode 100755 index 0000000..bc2e44a --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/addressbookserver.php @@ -0,0 +1,56 @@ +setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); + +//Mapping PHP errors to exceptions +function exception_error_handler($errno, $errstr, $errfile, $errline ) { + throw new ErrorException($errstr, 0, $errno, $errfile, $errline); +} +set_error_handler("exception_error_handler"); + +// Autoloader +require_once 'lib/Sabre/autoload.php'; + +// Backends +$authBackend = new Sabre_DAV_Auth_Backend_PDO($pdo); +$principalBackend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo); +$carddavBackend = new Sabre_CardDAV_Backend_PDO($pdo); +//$caldavBackend = new Sabre_CalDAV_Backend_PDO($pdo); + +// Setting up the directory tree // +$nodes = array( + new Sabre_DAVACL_PrincipalCollection($principalBackend), +// new Sabre_CalDAV_CalendarRootNode($authBackend, $caldavBackend), + new Sabre_CardDAV_AddressBookRoot($principalBackend, $carddavBackend), +); + +// The object tree needs in turn to be passed to the server class +$server = new Sabre_DAV_Server($nodes); +$server->setBaseUri($baseUri); + +// Plugins +$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend,'SabreDAV')); +$server->addPlugin(new Sabre_DAV_Browser_Plugin()); +//$server->addPlugin(new Sabre_CalDAV_Plugin()); +$server->addPlugin(new Sabre_CardDAV_Plugin()); +$server->addPlugin(new Sabre_DAVACL_Plugin()); + +// And off we go! +$server->exec(); diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/basicauth.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/basicauth.php new file mode 100755 index 0000000..9255c19 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/basicauth.php @@ -0,0 +1,28 @@ +getUserPass(); + +if (!$result || $result[0]!=$u || $result[1]!=$p) { + + $auth->requireLogin(); + echo "Authentication required\n"; + die(); + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/calendarserver.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/calendarserver.php new file mode 100755 index 0000000..2c7b4d8 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/calendarserver.php @@ -0,0 +1,45 @@ +setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); + +//Mapping PHP errors to exceptions +function exception_error_handler($errno, $errstr, $errfile, $errline ) { + throw new ErrorException($errstr, 0, $errno, $errfile, $errline); +} +set_error_handler("exception_error_handler"); + +// Files we need +require_once 'lib/Sabre/autoload.php'; + +// The 'caldav server' only needs the pdo object. Note that if you plan to +// extend the server in any way, you'll probably don't want to use +// Sabre_CalDAV_Server, but plain Sabre_DAV_Server instead. +// You'll need to add your own nodes and plugins manually then. +$server = new Sabre_CalDAV_Server($pdo); + +if (isset($baseUri)) + $server->setBaseUri($baseUri); + +// Support for html frontend +$browser = new Sabre_DAV_Browser_Plugin(); +$server->addPlugin($browser); + +// And off we go! +$server->exec(); diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/digestauth.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/digestauth.php new file mode 100755 index 0000000..94e2499 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/digestauth.php @@ -0,0 +1,27 @@ +init(); + +if ($auth->getUsername() != $u || !$auth->validatePassword($p)) { + + $auth->requireLogin(); + echo "Authentication required\n"; + die(); + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/fileserver.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/fileserver.php new file mode 100755 index 0000000..a41205f --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/fileserver.php @@ -0,0 +1,60 @@ +setBaseUri($baseUri); + +// Support for LOCK and UNLOCK +$lockBackend = new Sabre_DAV_Locks_Backend_File($tmpDir . '/locksdb'); +$lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend); +$server->addPlugin($lockPlugin); + +// Support for html frontend +$browser = new Sabre_DAV_Browser_Plugin(); +$server->addPlugin($browser); + +// Automatically guess (some) contenttypes, based on extesion +$server->addPlugin(new Sabre_DAV_Browser_GuessContentType()); + +// Authentication backend +$authBackend = new Sabre_DAV_Auth_Backend_File('.htdigest'); +$auth = new Sabre_DAV_Auth_Plugin($authBackend,'SabreDAV'); +$server->addPlugin($auth); + +// Temporary file filter +$tempFF = new Sabre_DAV_TemporaryFileFilterPlugin($tmpDir); +$server->addPlugin($tempFF); + +// And off we go! +$server->exec(); diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/groupwareserver.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/groupwareserver.php new file mode 100755 index 0000000..c164772 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/groupwareserver.php @@ -0,0 +1,91 @@ +setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); + +/** + * Mapping PHP errors to exceptions. + * + * While this is not strictly needed, it makes a lot of sense to do so. If an + * E_NOTICE or anything appears in your code, this allows SabreDAV to intercept + * the issue and send a proper response back to the client (HTTP/1.1 500). + */ +function exception_error_handler($errno, $errstr, $errfile, $errline ) { + throw new ErrorException($errstr, 0, $errno, $errfile, $errline); +} +set_error_handler("exception_error_handler"); + +// Autoloader +require_once 'lib/Sabre/autoload.php'; + +/** + * The backends. Yes we do really need all of them. + * + * This allows any developer to subclass just any of them and hook into their + * own backend systems. + */ +$authBackend = new Sabre_DAV_Auth_Backend_PDO($pdo); +$principalBackend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo); +$carddavBackend = new Sabre_CardDAV_Backend_PDO($pdo); +$caldavBackend = new Sabre_CalDAV_Backend_PDO($pdo); + +/** + * The directory tree + * + * Basically this is an array which contains the 'top-level' directories in the + * WebDAV server. + */ +$nodes = array( + // /principals + new Sabre_CalDAV_Principal_Collection($principalBackend), + // /calendars + new Sabre_CalDAV_CalendarRootNode($principalBackend, $caldavBackend), + // /addressbook + new Sabre_CardDAV_AddressBookRoot($principalBackend, $carddavBackend), +); + +// The object tree needs in turn to be passed to the server class +$server = new Sabre_DAV_Server($nodes); +$server->setBaseUri($baseUri); + +// Plugins +$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend,'SabreDAV')); +$server->addPlugin(new Sabre_DAV_Browser_Plugin()); +$server->addPlugin(new Sabre_CalDAV_Plugin()); +$server->addPlugin(new Sabre_CardDAV_Plugin()); +$server->addPlugin(new Sabre_DAVACL_Plugin()); + +// And off we go! +$server->exec(); diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/simplefsserver.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/simplefsserver.php new file mode 100755 index 0000000..f000099 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/simplefsserver.php @@ -0,0 +1,125 @@ +myPath = $myPath; + + } + + function getChildren() { + + $children = array(); + // Loop through the directory, and create objects for each node + foreach(scandir($this->myPath) as $node) { + + // Ignoring files staring with . + if ($node[0]==='.') continue; + + $children[] = $this->getChild($node); + + } + + return $children; + + } + + function getChild($name) { + + $path = $this->myPath . '/' . $name; + + // We have to throw a FileNotFound exception if the file didn't exist + if (!file_exists($this->myPath)) throw new Sabre_DAV_Exception_FileNotFound('The file with name: ' . $name . ' could not be found'); + // Some added security + + if ($name[0]=='.') throw new Sabre_DAV_Exception_FileNotFound('Access denied'); + + if (is_dir($path)) { + + return new MyDirectory($name); + + } else { + + return new MyFile($path); + + } + + } + + function getName() { + + return basename($this->myPath); + + } + +} + +class MyFile extends Sabre_DAV_File { + + private $myPath; + + function __construct($myPath) { + + $this->myPath = $myPath; + + } + + function getName() { + + return basename($this->myPath); + + } + + function get() { + + return fopen($this->myPath,'r'); + + } + + function getSize() { + + return filesize($this->myPath); + + } + +} + +// Make sure there is a directory in your current directory named 'public'. We will be exposing that directory to WebDAV +$rootNode = new MyDirectory($publicDir); + +// The rootNode needs to be passed to the server object. +$server = new Sabre_DAV_Server($rootNode); + +// And off we go! +$server->exec(); + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.addressbook.sql b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.addressbook.sql new file mode 100755 index 0000000..c6e9f58 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.addressbook.sql @@ -0,0 +1,17 @@ +CREATE TABLE addressbooks ( + id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + principaluri VARCHAR(255), + displayname VARCHAR(255), + uri VARCHAR(100), + description TEXT, + ctag INT(11) UNSIGNED NOT NULL DEFAULT '1' +); + +CREATE TABLE cards ( + id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + addressbookid INT(11) UNSIGNED NOT NULL, + carddata MEDIUMBLOB, + uri VARCHAR(100), + lastmodified INT(11) UNSIGNED +); + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.calendars.sql b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.calendars.sql new file mode 100755 index 0000000..51263ad --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.calendars.sql @@ -0,0 +1,20 @@ +CREATE TABLE calendarobjects ( + id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + calendardata MEDIUMBLOB, + uri VARCHAR(100), + calendarid INTEGER UNSIGNED NOT NULL, + lastmodified INT(11) +); + +CREATE TABLE calendars ( + id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + principaluri VARCHAR(100), + displayname VARCHAR(100), + uri VARCHAR(100), + ctag INTEGER UNSIGNED NOT NULL DEFAULT '0', + description TEXT, + calendarorder INTEGER UNSIGNED NOT NULL DEFAULT '0', + calendarcolor VARCHAR(10), + timezone TEXT, + components VARCHAR(20) +); diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.locks.sql b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.locks.sql new file mode 100755 index 0000000..1342c3b --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.locks.sql @@ -0,0 +1,10 @@ +CREATE TABLE locks ( + id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + owner VARCHAR(100), + timeout INTEGER UNSIGNED, + created INTEGER, + token VARCHAR(100), + scope TINYINT, + depth TINYINT, + uri text +); diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.principals.sql b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.principals.sql new file mode 100755 index 0000000..87c0ac3 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.principals.sql @@ -0,0 +1,21 @@ +CREATE TABLE principals ( + id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + uri VARCHAR(100) NOT NULL, + email VARCHAR(80), + displayname VARCHAR(80), + UNIQUE(uri) +); + +CREATE TABLE groupmembers ( + id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + principal_id INTEGER UNSIGNED NOT NULL, + member_id INTEGER UNSIGNED NOT NULL, + UNIQUE(principal_id, member_id) +); + + +INSERT INTO principals (uri,email,displayname) VALUES +('principals/admin', 'admin@example.org','Adminstrator'), +('principals/admin/calendar-proxy-read', null, null), +('principals/admin/calendar-proxy-write', null, null); + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.users.sql b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.users.sql new file mode 100755 index 0000000..b9dfdcf --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/mysql.users.sql @@ -0,0 +1,9 @@ +CREATE TABLE users ( + id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + username VARCHAR(50), + digesta1 VARCHAR(32), + UNIQUE(username) +); + +INSERT INTO users (username,digesta1) VALUES +('admin', '87fd274b7b6c01e48d7c2f965da8ddf7'); diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.addressbooks.sql b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.addressbooks.sql new file mode 100755 index 0000000..d8ae68c --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.addressbooks.sql @@ -0,0 +1,17 @@ +CREATE TABLE addressbooks ( + id integer primary key asc, + principaluri text, + displayname text, + uri text, + description text, + ctag integer +); + +CREATE TABLE cards ( + id integer primary key asc, + addressbookid integer, + carddata blob, + uri text, + lastmodified integer +); + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.calendars.sql b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.calendars.sql new file mode 100755 index 0000000..0dc4ed3 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.calendars.sql @@ -0,0 +1,20 @@ +CREATE TABLE calendarobjects ( + id integer primary key asc, + calendardata blob, + uri text, + calendarid integer, + lastmodified integer +); + +CREATE TABLE calendars ( + id integer primary key asc, + principaluri text, + displayname text, + uri text, + ctag integer, + description text, + calendarorder integer, + calendarcolor text, + timezone text, + components text +); diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.locks.sql b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.locks.sql new file mode 100755 index 0000000..9e5580d --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.locks.sql @@ -0,0 +1,12 @@ +BEGIN TRANSACTION; +CREATE TABLE locks ( + id integer primary key asc, + owner text, + timeout integer, + created integer, + token text, + scope integer, + depth integer, + uri text +); +COMMIT; diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.principals.sql b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.principals.sql new file mode 100755 index 0000000..4d02b1b --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.principals.sql @@ -0,0 +1,20 @@ +CREATE TABLE principals ( + id INTEGER PRIMARY KEY ASC, + uri TEXT, + email TEXT, + displayname TEXT, + UNIQUE(uri) +); + +CREATE TABLE groupmembers ( + id INTEGER PRIMARY KEY ASC, + principal_id INTEGER, + member_id INTEGER, + UNIQUE(principal_id, member_id) +); + + +INSERT INTO principals (uri,email,displayname) VALUES ('principals/admin', 'admin@example.org','Adminstrator'); +INSERT INTO principals (uri,email,displayname) VALUES ('principals/admin/calendar-proxy-read', null, null); +INSERT INTO principals (uri,email,displayname) VALUES ('principals/admin/calendar-proxy-write', null, null); + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.users.sql b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.users.sql new file mode 100755 index 0000000..373be48 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/examples/sql/sqlite.users.sql @@ -0,0 +1,9 @@ +CREATE TABLE users ( + id integer primary key asc, + username TEXT, + digesta1 TEXT, + UNIQUE(username) +); + +INSERT INTO users (username,digesta1) VALUES +('admin', '87fd274b7b6c01e48d7c2f965da8ddf7'); diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre.includes.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre.includes.php new file mode 100755 index 0000000..bad2a3e --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre.includes.php @@ -0,0 +1,128 @@ + array( + * '{DAV:}displayname' => null, + * ), + * 424 => array( + * '{DAV:}owner' => null, + * ) + * ) + * + * In this example it was forbidden to update {DAV:}displayname. + * (403 Forbidden), which in turn also caused {DAV:}owner to fail + * (424 Failed Dependency) because the request needs to be atomic. + * + * @param string $calendarId + * @param array $mutations + * @return bool|array + */ + public function updateCalendar($calendarId, array $mutations) { + + return false; + + } + + /** + * Delete a calendar and all it's objects + * + * @param string $calendarId + * @return void + */ + abstract function deleteCalendar($calendarId); + + /** + * Returns all calendar objects within a calendar. + * + * Every item contains an array with the following keys: + * * id - unique identifier which will be used for subsequent updates + * * calendardata - The iCalendar-compatible calnedar data + * * uri - a unique key which will be used to construct the uri. This can be any arbitrary string. + * * lastmodified - a timestamp of the last modification time + * * etag - An arbitrary string, surrounded by double-quotes. (e.g.: + * ' "abcdef"') + * * calendarid - The calendarid as it was passed to this function. + * + * Note that the etag is optional, but it's highly encouraged to return for + * speed reasons. + * + * The calendardata is also optional. If it's not returned + * 'getCalendarObject' will be called later, which *is* expected to return + * calendardata. + * + * @param string $calendarId + * @return array + */ + abstract function getCalendarObjects($calendarId); + + /** + * Returns information from a single calendar object, based on it's object + * uri. + * + * The returned array must have the same keys as getCalendarObjects. The + * 'calendardata' object is required here though, while it's not required + * for getCalendarObjects. + * + * @param string $calendarId + * @param string $objectUri + * @return array + */ + abstract function getCalendarObject($calendarId,$objectUri); + + /** + * Creates a new calendar object. + * + * @param string $calendarId + * @param string $objectUri + * @param string $calendarData + * @return void + */ + abstract function createCalendarObject($calendarId,$objectUri,$calendarData); + + /** + * Updates an existing calendarobject, based on it's uri. + * + * @param string $calendarId + * @param string $objectUri + * @param string $calendarData + * @return void + */ + abstract function updateCalendarObject($calendarId,$objectUri,$calendarData); + + /** + * Deletes an existing calendar object. + * + * @param string $calendarId + * @param string $objectUri + * @return void + */ + abstract function deleteCalendarObject($calendarId,$objectUri); + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Backend/PDO.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Backend/PDO.php new file mode 100755 index 0000000..da04f99 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Backend/PDO.php @@ -0,0 +1,386 @@ + 'displayname', + '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'description', + '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => 'timezone', + '{http://apple.com/ns/ical/}calendar-order' => 'calendarorder', + '{http://apple.com/ns/ical/}calendar-color' => 'calendarcolor', + ); + + /** + * Creates the backend + * + * @param PDO $pdo + */ + public function __construct(PDO $pdo, $calendarTableName = 'calendars', $calendarObjectTableName = 'calendarobjects') { + + $this->pdo = $pdo; + $this->calendarTableName = $calendarTableName; + $this->calendarObjectTableName = $calendarObjectTableName; + + } + + /** + * Returns a list of calendars for a principal. + * + * Every project is an array with the following keys: + * * id, a unique id that will be used by other functions to modify the + * calendar. This can be the same as the uri or a database key. + * * uri, which the basename of the uri with which the calendar is + * accessed. + * * principalUri. The owner of the calendar. Almost always the same as + * principalUri passed to this method. + * + * Furthermore it can contain webdav properties in clark notation. A very + * common one is '{DAV:}displayname'. + * + * @param string $principalUri + * @return array + */ + public function getCalendarsForUser($principalUri) { + + $fields = array_values($this->propertyMap); + $fields[] = 'id'; + $fields[] = 'uri'; + $fields[] = 'ctag'; + $fields[] = 'components'; + $fields[] = 'principaluri'; + + // Making fields a comma-delimited list + $fields = implode(', ', $fields); + $stmt = $this->pdo->prepare("SELECT " . $fields . " FROM `".$this->calendarTableName."` WHERE principaluri = ?"); + $stmt->execute(array($principalUri)); + + $calendars = array(); + while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + + $components = explode(',',$row['components']); + + $calendar = array( + 'id' => $row['id'], + 'uri' => $row['uri'], + 'principaluri' => $row['principaluri'], + '{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}getctag' => $row['ctag']?$row['ctag']:'0', + '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet($components), + ); + + + foreach($this->propertyMap as $xmlName=>$dbName) { + $calendar[$xmlName] = $row[$dbName]; + } + + $calendars[] = $calendar; + + } + + return $calendars; + + } + + /** + * Creates a new calendar for a principal. + * + * If the creation was a success, an id must be returned that can be used to reference + * this calendar in other methods, such as updateCalendar + * + * @param string $principalUri + * @param string $calendarUri + * @param array $properties + */ + public function createCalendar($principalUri,$calendarUri, array $properties) { + + $fieldNames = array( + 'principaluri', + 'uri', + 'ctag', + ); + $values = array( + ':principaluri' => $principalUri, + ':uri' => $calendarUri, + ':ctag' => 1, + ); + + // Default value + $sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set'; + $fieldNames[] = 'components'; + if (!isset($properties[$sccs])) { + $values[':components'] = 'VEVENT,VTODO'; + } else { + if (!($properties[$sccs] instanceof Sabre_CalDAV_Property_SupportedCalendarComponentSet)) { + throw new Sabre_DAV_Exception('The ' . $sccs . ' property must be of type: Sabre_CalDAV_Property_SupportedCalendarComponentSet'); + } + $values[':components'] = implode(',',$properties[$sccs]->getValue()); + } + + foreach($this->propertyMap as $xmlName=>$dbName) { + if (isset($properties[$xmlName])) { + + $myValue = $properties[$xmlName]; + $values[':' . $dbName] = $properties[$xmlName]; + $fieldNames[] = $dbName; + } + } + + $stmt = $this->pdo->prepare("INSERT INTO `".$this->calendarTableName."` (".implode(', ', $fieldNames).") VALUES (".implode(', ',array_keys($values)).")"); + $stmt->execute($values); + + return $this->pdo->lastInsertId(); + + } + + /** + * Updates properties for a calendar. + * + * The mutations array uses the propertyName in clark-notation as key, + * and the array value for the property value. In the case a property + * should be deleted, the property value will be null. + * + * This method must be atomic. If one property cannot be changed, the + * entire operation must fail. + * + * If the operation was successful, true can be returned. + * If the operation failed, false can be returned. + * + * Deletion of a non-existant property is always succesful. + * + * Lastly, it is optional to return detailed information about any + * failures. In this case an array should be returned with the following + * structure: + * + * array( + * 403 => array( + * '{DAV:}displayname' => null, + * ), + * 424 => array( + * '{DAV:}owner' => null, + * ) + * ) + * + * In this example it was forbidden to update {DAV:}displayname. + * (403 Forbidden), which in turn also caused {DAV:}owner to fail + * (424 Failed Dependency) because the request needs to be atomic. + * + * @param string $calendarId + * @param array $mutations + * @return bool|array + */ + public function updateCalendar($calendarId, array $mutations) { + + $newValues = array(); + $result = array( + 200 => array(), // Ok + 403 => array(), // Forbidden + 424 => array(), // Failed Dependency + ); + + $hasError = false; + + foreach($mutations as $propertyName=>$propertyValue) { + + // We don't know about this property. + if (!isset($this->propertyMap[$propertyName])) { + $hasError = true; + $result[403][$propertyName] = null; + unset($mutations[$propertyName]); + continue; + } + + $fieldName = $this->propertyMap[$propertyName]; + $newValues[$fieldName] = $propertyValue; + + } + + // If there were any errors we need to fail the request + if ($hasError) { + // Properties has the remaining properties + foreach($mutations as $propertyName=>$propertyValue) { + $result[424][$propertyName] = null; + } + + // Removing unused statuscodes for cleanliness + foreach($result as $status=>$properties) { + if (is_array($properties) && count($properties)===0) unset($result[$status]); + } + + return $result; + + } + + // Success + + // Now we're generating the sql query. + $valuesSql = array(); + foreach($newValues as $fieldName=>$value) { + $valuesSql[] = $fieldName . ' = ?'; + } + $valuesSql[] = 'ctag = ctag + 1'; + + $stmt = $this->pdo->prepare("UPDATE `" . $this->calendarTableName . "` SET " . implode(', ',$valuesSql) . " WHERE id = ?"); + $newValues['id'] = $calendarId; + $stmt->execute(array_values($newValues)); + + return true; + + } + + /** + * Delete a calendar and all it's objects + * + * @param string $calendarId + * @return void + */ + public function deleteCalendar($calendarId) { + + $stmt = $this->pdo->prepare('DELETE FROM `'.$this->calendarObjectTableName.'` WHERE calendarid = ?'); + $stmt->execute(array($calendarId)); + + $stmt = $this->pdo->prepare('DELETE FROM `'.$this->calendarTableName.'` WHERE id = ?'); + $stmt->execute(array($calendarId)); + + } + + /** + * Returns all calendar objects within a calendar. + * + * Every item contains an array with the following keys: + * * id - unique identifier which will be used for subsequent updates + * * calendardata - The iCalendar-compatible calnedar data + * * uri - a unique key which will be used to construct the uri. This can be any arbitrary string. + * * lastmodified - a timestamp of the last modification time + * * etag - An arbitrary string, surrounded by double-quotes. (e.g.: + * ' "abcdef"') + * * calendarid - The calendarid as it was passed to this function. + * + * Note that the etag is optional, but it's highly encouraged to return for + * speed reasons. + * + * The calendardata is also optional. If it's not returned + * 'getCalendarObject' will be called later, which *is* expected to return + * calendardata. + * + * @param string $calendarId + * @return array + */ + public function getCalendarObjects($calendarId) { + + $stmt = $this->pdo->prepare('SELECT * FROM `'.$this->calendarObjectTableName.'` WHERE calendarid = ?'); + $stmt->execute(array($calendarId)); + return $stmt->fetchAll(); + + } + + /** + * Returns information from a single calendar object, based on it's object + * uri. + * + * The returned array must have the same keys as getCalendarObjects. The + * 'calendardata' object is required here though, while it's not required + * for getCalendarObjects. + * + * @param string $calendarId + * @param string $objectUri + * @return array + */ + public function getCalendarObject($calendarId,$objectUri) { + + $stmt = $this->pdo->prepare('SELECT * FROM `'.$this->calendarObjectTableName.'` WHERE calendarid = ? AND uri = ?'); + $stmt->execute(array($calendarId, $objectUri)); + return $stmt->fetch(); + + } + + /** + * Creates a new calendar object. + * + * @param string $calendarId + * @param string $objectUri + * @param string $calendarData + * @return void + */ + public function createCalendarObject($calendarId,$objectUri,$calendarData) { + + $stmt = $this->pdo->prepare('INSERT INTO `'.$this->calendarObjectTableName.'` (calendarid, uri, calendardata, lastmodified) VALUES (?,?,?,?)'); + $stmt->execute(array($calendarId,$objectUri,$calendarData,time())); + $stmt = $this->pdo->prepare('UPDATE `'.$this->calendarTableName.'` SET ctag = ctag + 1 WHERE id = ?'); + $stmt->execute(array($calendarId)); + + } + + /** + * Updates an existing calendarobject, based on it's uri. + * + * @param string $calendarId + * @param string $objectUri + * @param string $calendarData + * @return void + */ + public function updateCalendarObject($calendarId,$objectUri,$calendarData) { + + $stmt = $this->pdo->prepare('UPDATE `'.$this->calendarObjectTableName.'` SET calendardata = ?, lastmodified = ? WHERE calendarid = ? AND uri = ?'); + $stmt->execute(array($calendarData,time(),$calendarId,$objectUri)); + $stmt = $this->pdo->prepare('UPDATE `'.$this->calendarTableName.'` SET ctag = ctag + 1 WHERE id = ?'); + $stmt->execute(array($calendarId)); + + } + + /** + * Deletes an existing calendar object. + * + * @param string $calendarId + * @param string $objectUri + * @return void + */ + public function deleteCalendarObject($calendarId,$objectUri) { + + $stmt = $this->pdo->prepare('DELETE FROM `'.$this->calendarObjectTableName.'` WHERE calendarid = ? AND uri = ?'); + $stmt->execute(array($calendarId,$objectUri)); + $stmt = $this->pdo->prepare('UPDATE `'. $this->calendarTableName .'` SET ctag = ctag + 1 WHERE id = ?'); + $stmt->execute(array($calendarId)); + + } + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Calendar.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Calendar.php new file mode 100755 index 0000000..d526564 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Calendar.php @@ -0,0 +1,318 @@ +caldavBackend = $caldavBackend; + $this->principalBackend = $principalBackend; + $this->calendarInfo = $calendarInfo; + + + } + + /** + * Returns the name of the calendar + * + * @return string + */ + public function getName() { + + return $this->calendarInfo['uri']; + + } + + /** + * Updates properties such as the display name and description + * + * @param array $mutations + * @return array + */ + public function updateProperties($mutations) { + + return $this->caldavBackend->updateCalendar($this->calendarInfo['id'],$mutations); + + } + + /** + * Returns the list of properties + * + * @param array $properties + * @return array + */ + public function getProperties($requestedProperties) { + + $response = array(); + + foreach($requestedProperties as $prop) switch($prop) { + + case '{urn:ietf:params:xml:ns:caldav}supported-calendar-data' : + $response[$prop] = new Sabre_CalDAV_Property_SupportedCalendarData(); + break; + case '{urn:ietf:params:xml:ns:caldav}supported-collation-set' : + $response[$prop] = new Sabre_CalDAV_Property_SupportedCollationSet(); + break; + case '{DAV:}owner' : + $response[$prop] = new Sabre_DAVACL_Property_Principal(Sabre_DAVACL_Property_Principal::HREF,$this->calendarInfo['principaluri']); + break; + default : + if (isset($this->calendarInfo[$prop])) $response[$prop] = $this->calendarInfo[$prop]; + break; + + } + return $response; + + } + + /** + * Returns a calendar object + * + * The contained calendar objects are for example Events or Todo's. + * + * @param string $name + * @return Sabre_DAV_ICalendarObject + */ + public function getChild($name) { + + $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'],$name); + if (!$obj) throw new Sabre_DAV_Exception_FileNotFound('Calendar object not found'); + return new Sabre_CalDAV_CalendarObject($this->caldavBackend,$this->calendarInfo,$obj); + + } + + /** + * Returns the full list of calendar objects + * + * @return array + */ + public function getChildren() { + + $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']); + $children = array(); + foreach($objs as $obj) { + $children[] = new Sabre_CalDAV_CalendarObject($this->caldavBackend,$this->calendarInfo,$obj); + } + return $children; + + } + + /** + * Checks if a child-node exists. + * + * @param string $name + * @return bool + */ + public function childExists($name) { + + $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'],$name); + if (!$obj) + return false; + else + return true; + + } + + /** + * Creates a new directory + * + * We actually block this, as subdirectories are not allowed in calendars. + * + * @param string $name + * @return void + */ + public function createDirectory($name) { + + throw new Sabre_DAV_Exception_MethodNotAllowed('Creating collections in calendar objects is not allowed'); + + } + + /** + * Creates a new file + * + * The contents of the new file must be a valid ICalendar string. + * + * @param string $name + * @param resource $calendarData + * @return void + */ + public function createFile($name,$calendarData = null) { + + $calendarData = stream_get_contents($calendarData); + // Converting to UTF-8, if needed + $calendarData = Sabre_DAV_StringUtil::ensureUTF8($calendarData); + + $supportedComponents = $this->calendarInfo['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set']; + if ($supportedComponents) { + $supportedComponents = $supportedComponents->getValue(); + } else { + $supportedComponents = null; + } + Sabre_CalDAV_ICalendarUtil::validateICalendarObject($calendarData, $supportedComponents); + + $this->caldavBackend->createCalendarObject($this->calendarInfo['id'],$name,$calendarData); + + } + + /** + * Deletes the calendar. + * + * @return void + */ + public function delete() { + + $this->caldavBackend->deleteCalendar($this->calendarInfo['id']); + + } + + /** + * Renames the calendar. Note that most calendars use the + * {DAV:}displayname to display a name to display a name. + * + * @param string $newName + * @return void + */ + public function setName($newName) { + + throw new Sabre_DAV_Exception_MethodNotAllowed('Renaming calendars is not yet supported'); + + } + + /** + * Returns the last modification date as a unix timestamp. + * + * @return void + */ + public function getLastModified() { + + return null; + + } + + /** + * Returns the owner principal + * + * This must be a url to a principal, or null if there's no owner + * + * @return string|null + */ + public function getOwner() { + + return $this->calendarInfo['principaluri']; + + } + + /** + * Returns a group principal + * + * This must be a url to a principal, or null if there's no owner + * + * @return string|null + */ + public function getGroup() { + + return null; + + } + + /** + * Returns a list of ACE's for this node. + * + * Each ACE has the following properties: + * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are + * currently the only supported privileges + * * 'principal', a url to the principal who owns the node + * * 'protected' (optional), indicating that this ACE is not allowed to + * be updated. + * + * @return array + */ + public function getACL() { + + return array( + array( + 'privilege' => '{DAV:}read', + 'principal' => $this->calendarInfo['principaluri'], + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => $this->calendarInfo['principaluri'], + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}read', + 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}read', + 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-read', + 'protected' => true, + ), + + ); + + } + + /** + * Updates the ACL + * + * This method will receive a list of new ACE's. + * + * @param array $acl + * @return void + */ + public function setACL(array $acl) { + + throw new Sabre_DAV_Exception_MethodNotAllowed('Changing ACL is not yet supported'); + + } + + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/CalendarObject.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/CalendarObject.php new file mode 100755 index 0000000..3c2a752 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/CalendarObject.php @@ -0,0 +1,260 @@ +caldavBackend = $caldavBackend; + + if (!isset($objectData['calendarid'])) { + throw new InvalidArgumentException('The objectData argument must contain a \'calendarid\' property'); + } + if (!isset($objectData['uri'])) { + throw new InvalidArgumentException('The objectData argument must contain an \'uri\' property'); + } + + $this->calendarInfo = $calendarInfo; + $this->objectData = $objectData; + + } + + /** + * Returns the uri for this object + * + * @return string + */ + public function getName() { + + return $this->objectData['uri']; + + } + + /** + * Returns the ICalendar-formatted object + * + * @return string + */ + public function get() { + + // Pre-populating the 'calendardata' is optional, if we don't have it + // already we fetch it from the backend. + if (!isset($this->objectData['calendardata'])) { + $this->objectData = $this->caldavBackend->getCalendarObject($this->objectData['calendarid'], $this->objectData['uri']); + } + return $this->objectData['calendardata']; + + } + + /** + * Updates the ICalendar-formatted object + * + * @param string $calendarData + * @return void + */ + public function put($calendarData) { + + if (is_resource($calendarData)) + $calendarData = stream_get_contents($calendarData); + + // Converting to UTF-8, if needed + $calendarData = Sabre_DAV_StringUtil::ensureUTF8($calendarData); + + $supportedComponents = $this->calendarInfo['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set']; + if ($supportedComponents) { + $supportedComponents = $supportedComponents->getValue(); + } else { + $supportedComponents = null; + } + Sabre_CalDAV_ICalendarUtil::validateICalendarObject($calendarData, $supportedComponents); + + $this->caldavBackend->updateCalendarObject($this->calendarInfo['id'],$this->objectData['uri'],$calendarData); + $this->objectData['calendardata'] = $calendarData; + + } + + /** + * Deletes the calendar object + * + * @return void + */ + public function delete() { + + $this->caldavBackend->deleteCalendarObject($this->calendarInfo['id'],$this->objectData['uri']); + + } + + /** + * Returns the mime content-type + * + * @return string + */ + public function getContentType() { + + return 'text/calendar'; + + } + + /** + * Returns an ETag for this object. + * + * The ETag is an arbritrary string, but MUST be surrounded by double-quotes. + * + * @return string + */ + public function getETag() { + + if (isset($this->objectData['etag'])) { + return $this->objectData['etag']; + } else { + return '"' . md5($this->get()). '"'; + } + + } + + /** + * Returns the last modification date as a unix timestamp + * + * @return time + */ + public function getLastModified() { + + return $this->objectData['lastmodified']; + + } + + /** + * Returns the size of this object in bytes + * + * @return int + */ + public function getSize() { + + return strlen($this->objectData['calendardata']); + + } + + /** + * Returns the owner principal + * + * This must be a url to a principal, or null if there's no owner + * + * @return string|null + */ + public function getOwner() { + + return $this->calendarInfo['principaluri']; + + } + + /** + * Returns a group principal + * + * This must be a url to a principal, or null if there's no owner + * + * @return string|null + */ + public function getGroup() { + + return null; + + } + + /** + * Returns a list of ACE's for this node. + * + * Each ACE has the following properties: + * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are + * currently the only supported privileges + * * 'principal', a url to the principal who owns the node + * * 'protected' (optional), indicating that this ACE is not allowed to + * be updated. + * + * @return array + */ + public function getACL() { + + return array( + array( + 'privilege' => '{DAV:}read', + 'principal' => $this->calendarInfo['principaluri'], + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => $this->calendarInfo['principaluri'], + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}read', + 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}read', + 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-read', + 'protected' => true, + ), + + ); + + } + + /** + * Updates the ACL + * + * This method will receive a list of new ACE's. + * + * @param array $acl + * @return void + */ + public function setACL(array $acl) { + + throw new Sabre_DAV_Exception_MethodNotAllowed('Changing ACL is not yet supported'); + + } + + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/CalendarRootNode.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/CalendarRootNode.php new file mode 100755 index 0000000..0f7dca7 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/CalendarRootNode.php @@ -0,0 +1,75 @@ +caldavBackend = $caldavBackend; + + } + + /** + * Returns the nodename + * + * We're overriding this, because the default will be the 'principalPrefix', + * and we want it to be Sabre_CalDAV_Plugin::CALENDAR_ROOT + * + * @return void + */ + public function getName() { + + return Sabre_CalDAV_Plugin::CALENDAR_ROOT; + + } + + /** + * This method returns a node for a principal. + * + * The passed array contains principal information, and is guaranteed to + * at least contain a uri item. Other properties may or may not be + * supplied by the authentication backend. + * + * @param array $principal + * @return Sabre_DAV_INode + */ + public function getChildForPrincipal(array $principal) { + + return new Sabre_CalDAV_UserCalendars($this->principalBackend, $this->caldavBackend, $principal['uri']); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Exception/InvalidICalendarObject.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Exception/InvalidICalendarObject.php new file mode 100755 index 0000000..24b2c82 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Exception/InvalidICalendarObject.php @@ -0,0 +1,18 @@ +server = $server; + $this->server->subscribeEvent('beforeMethod',array($this,'beforeMethod'), 90); + + } + + /** + * 'beforeMethod' event handles. This event handles intercepts GET requests ending + * with ?export + * + * @param string $method + * @param string $uri + * @return void + */ + public function beforeMethod($method, $uri) { + + if ($method!='GET') return; + if ($this->server->httpRequest->getQueryString()!='export') return; + + // splitting uri + list($uri) = explode('?',$uri,2); + + $node = $this->server->tree->getNodeForPath($uri); + + if (!($node instanceof Sabre_CalDAV_Calendar)) return; + + // Checking ACL, if available. + if ($aclPlugin = $this->server->getPlugin('acl')) { + $aclPlugin->checkPrivileges($uri, '{DAV:}read'); + } + + $this->server->httpResponse->setHeader('Content-Type','text/calendar'); + $this->server->httpResponse->sendStatus(200); + + $nodes = $this->server->getPropertiesForPath($uri, array( + '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}calendar-data', + ),1); + + $this->server->httpResponse->sendBody($this->generateICS($nodes)); + + // Returning false to break the event chain + return false; + + } + + /** + * Merges all calendar objects, and builds one big ics export + * + * @param array $nodes + * @return void + */ + public function generateICS(array $nodes) { + + $calendar = new Sabre_VObject_Component('vcalendar'); + $calendar->version = '2.0'; + $calendar->prodid = '-//SabreDAV//SabreDAV ' . Sabre_DAV_Version::VERSION . '//EN'; + $calendar->calscale = 'GREGORIAN'; + + $collectedTimezones = array(); + + $timezones = array(); + $objects = array(); + + foreach($nodes as $node) { + + if (!isset($node[200]['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}calendar-data'])) { + continue; + } + $nodeData = $node[200]['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}calendar-data']; + + $nodeComp = Sabre_VObject_Reader::read($nodeData); + + foreach($nodeComp->children() as $child) { + + switch($child->name) { + case 'VEVENT' : + case 'VTODO' : + case 'VJOURNAL' : + $objects[] = $child; + break; + + // VTIMEZONE is special, because we need to filter out the duplicates + case 'VTIMEZONE' : + // Naively just checking tzid. + if (in_array((string)$child->TZID, $collectedTimezones)) continue; + + $timezones[] = $child; + $collectedTimezones[] = $child->TZID; + break; + + } + + } + + } + + foreach($timezones as $tz) $calendar->add($tz); + foreach($objects as $obj) $calendar->add($obj); + + return $calendar->serialize(); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/ICalendar.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/ICalendar.php new file mode 100755 index 0000000..291b7a7 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/ICalendar.php @@ -0,0 +1,18 @@ +registerXPathNameSpace('cal','urn:ietf:params:xml:ns:xcal'); + + // Check if there's only 1 component + $components = array('vevent','vtodo','vjournal','vfreebusy'); + $componentsFound = array(); + + foreach($components as $component) { + $test = $xcal->xpath('/cal:iCalendar/cal:vcalendar/cal:' . $component); + if (is_array($test)) $componentsFound = array_merge($componentsFound, $test); + } + if (count($componentsFound)<1) { + throw new Sabre_CalDAV_Exception_InvalidICalendarObject('One VEVENT, VTODO, VJOURNAL or VFREEBUSY must be specified. 0 found.'); + } + $component = $componentsFound[0]; + + if (is_null($allowedComponents)) return true; + + // Check if the component is allowed + $name = $component->getName(); + if (!in_array(strtoupper($name),$allowedComponents)) { + throw new Sabre_CalDAV_Exception_InvalidICalendarObject(strtoupper($name) . ' is not allowed in this calendar.'); + } + + if (count($xcal->xpath('/cal:iCalendar/cal:vcalendar/cal:method'))>0) { + throw new Sabre_CalDAV_Exception_InvalidICalendarObject('The METHOD property is not allowed in calendar objects'); + } + + return true; + + } + + /** + * Converts ICalendar data to XML. + * + * Properties are converted to lowercase xml elements. Parameters are; + * converted to attributes. BEGIN:VEVENT is converted to and + * END:VEVENT as well as other components. + * + * It's a very loose parser. If any line does not conform to the spec, it + * will simply be ignored. It will try to detect if \r\n or \n line endings + * are used. + * + * @todo Currently quoted attributes are not parsed correctly. + * @see http://tools.ietf.org/html/draft-royer-calsch-xcal-03 + * @param string $icalData + * @return string. + */ + static function toXCAL($icalData) { + + // Detecting line endings + $lb="\r\n"; + if (strpos($icalData,"\r\n")!==false) $lb = "\r\n"; + elseif (strpos($icalData,"\n")!==false) $lb = "\n"; + + // Splitting up items per line + $lines = explode($lb,$icalData); + + // Properties can be folded over 2 lines. In this case the second + // line will be preceeded by a space or tab. + $lines2 = array(); + foreach($lines as $line) { + + if (!$line) continue; + if ($line[0]===" " || $line[0]==="\t") { + $lines2[count($lines2)-1].=substr($line,1); + continue; + } + + $lines2[]=$line; + + } + + $xml = '' . "\n"; + $xml.= "\n"; + + $spaces = 2; + foreach($lines2 as $line) { + + $matches = array(); + // This matches PROPERTYNAME;ATTRIBUTES:VALUE + if (!preg_match('/^([^:^;]*)(?:;([^:]*))?:(.*)$/',$line,$matches)) + continue; + + $propertyName = strtolower($matches[1]); + $attributes = $matches[2]; + $value = $matches[3]; + + // If the line was in the format BEGIN:COMPONENT or END:COMPONENT, we need to special case it. + if ($propertyName === 'begin') { + $xml.=str_repeat(" ",$spaces); + $xml.='<' . strtolower($value) . ">\n"; + $spaces+=2; + continue; + } elseif ($propertyName === 'end') { + $spaces-=2; + $xml.=str_repeat(" ",$spaces); + $xml.='\n"; + continue; + } + + $xml.=str_repeat(" ",$spaces); + $xml.='<' . $propertyName; + if ($attributes) { + // There can be multiple attributes + $attributes = explode(';',$attributes); + foreach($attributes as $att) { + + list($attName,$attValue) = explode('=',$att,2); + $attName = strtolower($attName); + if ($attName === 'language') $attName='xml:lang'; + $xml.=' ' . $attName . '="' . htmlspecialchars($attValue) . '"'; + + } + } + + $xml.='>'. htmlspecialchars(trim($value)) . '\n"; + + } + $xml.=""; + return $xml; + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Plugin.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Plugin.php new file mode 100755 index 0000000..b045d8a --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Plugin.php @@ -0,0 +1,788 @@ +server->tree->getNodeForPath($parent); + + if ($node instanceof Sabre_DAV_IExtendedCollection) { + try { + $node->getChild($name); + } catch (Sabre_DAV_Exception_FileNotFound $e) { + return array('MKCALENDAR'); + } + } + return array(); + + } + + /** + * Returns a list of features for the DAV: HTTP header. + * + * @return array + */ + public function getFeatures() { + + return array('calendar-access', 'calendar-proxy'); + + } + + /** + * Returns a plugin name. + * + * Using this name other plugins will be able to access other plugins + * using Sabre_DAV_Server::getPlugin + * + * @return string + */ + public function getPluginName() { + + return 'caldav'; + + } + + /** + * Returns a list of reports this plugin supports. + * + * This will be used in the {DAV:}supported-report-set property. + * Note that you still need to subscribe to the 'report' event to actually + * implement them + * + * @param string $uri + * @return array + */ + public function getSupportedReportSet($uri) { + + $node = $this->server->tree->getNodeForPath($uri); + if ($node instanceof Sabre_CalDAV_ICalendar || $node instanceof Sabre_CalDAV_ICalendarObject) { + return array( + '{' . self::NS_CALDAV . '}calendar-multiget', + '{' . self::NS_CALDAV . '}calendar-query', + ); + } + return array(); + + } + + /** + * Initializes the plugin + * + * @param Sabre_DAV_Server $server + * @return void + */ + public function initialize(Sabre_DAV_Server $server) { + + $this->server = $server; + $server->subscribeEvent('unknownMethod',array($this,'unknownMethod')); + //$server->subscribeEvent('unknownMethod',array($this,'unknownMethod2'),1000); + $server->subscribeEvent('report',array($this,'report')); + $server->subscribeEvent('beforeGetProperties',array($this,'beforeGetProperties')); + + $server->xmlNamespaces[self::NS_CALDAV] = 'cal'; + $server->xmlNamespaces[self::NS_CALENDARSERVER] = 'cs'; + + $server->propertyMap['{' . self::NS_CALDAV . '}supported-calendar-component-set'] = 'Sabre_CalDAV_Property_SupportedCalendarComponentSet'; + + $server->resourceTypeMapping['Sabre_CalDAV_ICalendar'] = '{urn:ietf:params:xml:ns:caldav}calendar'; + $server->resourceTypeMapping['Sabre_CalDAV_Principal_ProxyRead'] = '{http://calendarserver.org/ns/}calendar-proxy-read'; + $server->resourceTypeMapping['Sabre_CalDAV_Principal_ProxyWrite'] = '{http://calendarserver.org/ns/}calendar-proxy-write'; + + array_push($server->protectedProperties, + + '{' . self::NS_CALDAV . '}supported-calendar-component-set', + '{' . self::NS_CALDAV . '}supported-calendar-data', + '{' . self::NS_CALDAV . '}max-resource-size', + '{' . self::NS_CALDAV . '}min-date-time', + '{' . self::NS_CALDAV . '}max-date-time', + '{' . self::NS_CALDAV . '}max-instances', + '{' . self::NS_CALDAV . '}max-attendees-per-instance', + '{' . self::NS_CALDAV . '}calendar-home-set', + '{' . self::NS_CALDAV . '}supported-collation-set', + '{' . self::NS_CALDAV . '}calendar-data', + + // scheduling extension + '{' . self::NS_CALDAV . '}calendar-user-address-set', + + // CalendarServer extensions + '{' . self::NS_CALENDARSERVER . '}getctag', + '{' . self::NS_CALENDARSERVER . '}calendar-proxy-read-for', + '{' . self::NS_CALENDARSERVER . '}calendar-proxy-write-for' + + ); + } + + /** + * This function handles support for the MKCALENDAR method + * + * @param string $method + * @return bool + */ + public function unknownMethod($method, $uri) { + + if ($method!=='MKCALENDAR') return; + + $this->httpMkCalendar($uri); + // false is returned to stop the unknownMethod event + return false; + + } + + /** + * This functions handles REPORT requests specific to CalDAV + * + * @param string $reportName + * @param DOMNode $dom + * @return bool + */ + public function report($reportName,$dom) { + + switch($reportName) { + case '{'.self::NS_CALDAV.'}calendar-multiget' : + $this->calendarMultiGetReport($dom); + return false; + case '{'.self::NS_CALDAV.'}calendar-query' : + $this->calendarQueryReport($dom); + return false; + + } + + + } + + /** + * This function handles the MKCALENDAR HTTP method, which creates + * a new calendar. + * + * @param string $uri + * @return void + */ + public function httpMkCalendar($uri) { + + // Due to unforgivable bugs in iCal, we're completely disabling MKCALENDAR support + // for clients matching iCal in the user agent + //$ua = $this->server->httpRequest->getHeader('User-Agent'); + //if (strpos($ua,'iCal/')!==false) { + // throw new Sabre_DAV_Exception_Forbidden('iCal has major bugs in it\'s RFC3744 support. Therefore we are left with no other choice but disabling this feature.'); + //} + + $body = $this->server->httpRequest->getBody(true); + $properties = array(); + + if ($body) { + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($body); + + foreach($dom->firstChild->childNodes as $child) { + + if (Sabre_DAV_XMLUtil::toClarkNotation($child)!=='{DAV:}set') continue; + foreach(Sabre_DAV_XMLUtil::parseProperties($child,$this->server->propertyMap) as $k=>$prop) { + $properties[$k] = $prop; + } + + } + } + + $resourceType = array('{DAV:}collection','{urn:ietf:params:xml:ns:caldav}calendar'); + + $this->server->createCollection($uri,$resourceType,$properties); + + $this->server->httpResponse->sendStatus(201); + $this->server->httpResponse->setHeader('Content-Length',0); + } + + /** + * beforeGetProperties + * + * This method handler is invoked before any after properties for a + * resource are fetched. This allows us to add in any CalDAV specific + * properties. + * + * @param string $path + * @param Sabre_DAV_INode $node + * @param array $requestedProperties + * @param array $returnedProperties + * @return void + */ + public function beforeGetProperties($path, Sabre_DAV_INode $node, &$requestedProperties, &$returnedProperties) { + + if ($node instanceof Sabre_DAVACL_IPrincipal) { + + // calendar-home-set property + $calHome = '{' . self::NS_CALDAV . '}calendar-home-set'; + if (in_array($calHome,$requestedProperties)) { + $principalId = $node->getName(); + $calendarHomePath = self::CALENDAR_ROOT . '/' . $principalId . '/'; + unset($requestedProperties[$calHome]); + $returnedProperties[200][$calHome] = new Sabre_DAV_Property_Href($calendarHomePath); + } + + // calendar-user-address-set property + $calProp = '{' . self::NS_CALDAV . '}calendar-user-address-set'; + if (in_array($calProp,$requestedProperties)) { + + $addresses = $node->getAlternateUriSet(); + $addresses[] = $this->server->getBaseUri() . $node->getPrincipalUrl(); + unset($requestedProperties[$calProp]); + $returnedProperties[200][$calProp] = new Sabre_DAV_Property_HrefList($addresses, false); + + } + + // These two properties are shortcuts for ical to easily find + // other principals this principal has access to. + $propRead = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-read-for'; + $propWrite = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-write-for'; + if (in_array($propRead,$requestedProperties) || in_array($propWrite,$requestedProperties)) { + + $membership = $node->getGroupMembership(); + $readList = array(); + $writeList = array(); + + foreach($membership as $group) { + + $groupNode = $this->server->tree->getNodeForPath($group); + + // If the node is either ap proxy-read or proxy-write + // group, we grab the parent principal and add it to the + // list. + if ($groupNode instanceof Sabre_CalDAV_Principal_ProxyRead) { + list($readList[]) = Sabre_DAV_URLUtil::splitPath($group); + } + if ($groupNode instanceof Sabre_CalDAV_Principal_ProxyWrite) { + list($writeList[]) = Sabre_DAV_URLUtil::splitPath($group); + } + + } + if (in_array($propRead,$requestedProperties)) { + unset($requestedProperties[$propRead]); + $returnedProperties[200][$propRead] = new Sabre_DAV_Property_HrefList($readList); + } + if (in_array($propWrite,$requestedProperties)) { + unset($requestedProperties[$propWrite]); + $returnedProperties[200][$propWrite] = new Sabre_DAV_Property_HrefList($writeList); + } + + } + + } // instanceof IPrincipal + + + if ($node instanceof Sabre_CalDAV_ICalendarObject) { + // The calendar-data property is not supposed to be a 'real' + // property, but in large chunks of the spec it does act as such. + // Therefore we simply expose it as a property. + $calDataProp = '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}calendar-data'; + if (in_array($calDataProp, $requestedProperties)) { + unset($requestedProperties[$calDataProp]); + $val = $node->get(); + if (is_resource($val)) + $val = stream_get_contents($val); + + // Taking out \r to not screw up the xml output + $returnedProperties[200][$calDataProp] = str_replace("\r","", $val); + + } + } + + } + + /** + * This function handles the calendar-multiget REPORT. + * + * This report is used by the client to fetch the content of a series + * of urls. Effectively avoiding a lot of redundant requests. + * + * @param DOMNode $dom + * @return void + */ + public function calendarMultiGetReport($dom) { + + $properties = array_keys(Sabre_DAV_XMLUtil::parseProperties($dom->firstChild)); + + $hrefElems = $dom->getElementsByTagNameNS('urn:DAV','href'); + foreach($hrefElems as $elem) { + $uri = $this->server->calculateUri($elem->nodeValue); + list($objProps) = $this->server->getPropertiesForPath($uri,$properties); + $propertyList[]=$objProps; + + } + + $this->server->httpResponse->sendStatus(207); + $this->server->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8'); + $this->server->httpResponse->sendBody($this->server->generateMultiStatus($propertyList)); + + } + + /** + * This function handles the calendar-query REPORT + * + * This report is used by clients to request calendar objects based on + * complex conditions. + * + * @param DOMNode $dom + * @return void + */ + public function calendarQueryReport($dom) { + + $requestedProperties = array_keys(Sabre_DAV_XMLUtil::parseProperties($dom->firstChild)); + + $filterNode = $dom->getElementsByTagNameNS('urn:ietf:params:xml:ns:caldav','filter'); + if ($filterNode->length!==1) { + throw new Sabre_DAV_Exception_BadRequest('The calendar-query report must have a filter element'); + } + $filters = Sabre_CalDAV_XMLUtil::parseCalendarQueryFilters($filterNode->item(0)); + + $requestedCalendarData = true; + + if (!in_array('{urn:ietf:params:xml:ns:caldav}calendar-data', $requestedProperties)) { + // We always retrieve calendar-data, as we need it for filtering. + $requestedProperties[] = '{urn:ietf:params:xml:ns:caldav}calendar-data'; + + // If calendar-data wasn't explicitly requested, we need to remove + // it after processing. + $requestedCalendarData = false; + } + + // These are the list of nodes that potentially match the requirement + $candidateNodes = $this->server->getPropertiesForPath($this->server->getRequestUri(),$requestedProperties,$this->server->getHTTPDepth(0)); + + $verifiedNodes = array(); + + foreach($candidateNodes as $node) { + + // If the node didn't have a calendar-data property, it must not be a calendar object + if (!isset($node[200]['{urn:ietf:params:xml:ns:caldav}calendar-data'])) continue; + + if ($this->validateFilters($node[200]['{urn:ietf:params:xml:ns:caldav}calendar-data'],$filters)) { + + if (!$requestedCalendarData) { + unset($node[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']); + } + $verifiedNodes[] = $node; + } + + } + + $this->server->httpResponse->sendStatus(207); + $this->server->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8'); + $this->server->httpResponse->sendBody($this->server->generateMultiStatus($verifiedNodes)); + + } + + + /** + * Verify if a list of filters applies to the calendar data object + * + * The calendarData object must be a valid iCalendar blob. The list of + * filters must be formatted as parsed by Sabre_CalDAV_Plugin::parseCalendarQueryFilters + * + * @param string $calendarData + * @param array $filters + * @return bool + */ + public function validateFilters($calendarData,$filters) { + + // We are converting the calendar object to an XML structure + // This makes it far easier to parse + $xCalendarData = Sabre_CalDAV_ICalendarUtil::toXCal($calendarData); + $xml = simplexml_load_string($xCalendarData); + $xml->registerXPathNamespace('c','urn:ietf:params:xml:ns:xcal'); + + foreach($filters as $xpath=>$filter) { + + // if-not-defined comes first + if (isset($filter['is-not-defined'])) { + if (!$xml->xpath($xpath)) + continue; + else + return false; + + } + + $elem = $xml->xpath($xpath); + + if (!$elem) return false; + $elem = $elem[0]; + + if (isset($filter['time-range'])) { + + switch($elem->getName()) { + case 'vevent' : + $result = $this->validateTimeRangeFilterForEvent($xml,$xpath,$filter); + if ($result===false) return false; + break; + case 'vtodo' : + $result = $this->validateTimeRangeFilterForTodo($xml,$xpath,$filter); + if ($result===false) return false; + break; + case 'vjournal' : + case 'vfreebusy' : + case 'valarm' : + // TODO: not implemented + break; + + /* + + case 'vjournal' : + $result = $this->validateTimeRangeFilterForJournal($xml,$xpath,$filter); + if ($result===false) return false; + break; + case 'vfreebusy' : + $result = $this->validateTimeRangeFilterForFreeBusy($xml,$xpath,$filter); + if ($result===false) return false; + break; + case 'valarm' : + $result = $this->validateTimeRangeFilterForAlarm($xml,$xpath,$filter); + if ($result===false) return false; + break; + + */ + + } + + } + + if (isset($filter['text-match'])) { + $currentString = (string)$elem; + + $isMatching = Sabre_DAV_StringUtil::textMatch($currentString, $filter['text-match']['value'], $filter['text-match']['collation']); + if ($filter['text-match']['negate-condition'] && $isMatching) return false; + if (!$filter['text-match']['negate-condition'] && !$isMatching) return false; + + } + + } + return true; + + } + + /** + * Checks whether a time-range filter matches an event. + * + * @param SimpleXMLElement $xml Event as xml object + * @param string $currentXPath XPath to check + * @param array $currentFilter Filter information + * @return void + */ + private function validateTimeRangeFilterForEvent(SimpleXMLElement $xml,$currentXPath,array $currentFilter) { + + // Grabbing the DTSTART property + $xdtstart = $xml->xpath($currentXPath.'/c:dtstart'); + if (!count($xdtstart)) { + throw new Sabre_DAV_Exception_BadRequest('DTSTART property missing from calendar object'); + } + + // The dtstart can be both a date, or datetime property + if ((string)$xdtstart[0]['value']==='DATE' || strlen((string)$xdtstart[0])===8) { + $isDateTime = false; + } else { + $isDateTime = true; + } + + // Determining the timezone + if ($tzid = (string)$xdtstart[0]['tzid']) { + $tz = new DateTimeZone($tzid); + } else { + $tz = null; + } + if ($isDateTime) { + $dtstart = Sabre_CalDAV_XMLUtil::parseICalendarDateTime((string)$xdtstart[0],$tz); + } else { + $dtstart = Sabre_CalDAV_XMLUtil::parseICalendarDate((string)$xdtstart[0]); + } + + + // Grabbing the DTEND property + $xdtend = $xml->xpath($currentXPath.'/c:dtend'); + $dtend = null; + + if (count($xdtend)) { + // Determining the timezone + if ($tzid = (string)$xdtend[0]['tzid']) { + $tz = new DateTimeZone($tzid); + } else { + $tz = null; + } + + // Since the VALUE prameter of both DTSTART and DTEND must be the same + // we can assume we don't need to check the VALUE paramter of DTEND. + if ($isDateTime) { + $dtend = Sabre_CalDAV_XMLUtil::parseICalendarDateTime((string)$xdtend[0],$tz); + } else { + $dtend = Sabre_CalDAV_XMLUtil::parseICalendarDate((string)$xdtend[0],$tz); + } + + } + + if (is_null($dtend)) { + // The DTEND property was not found. We will first see if the event has a duration + // property + + $xduration = $xml->xpath($currentXPath.'/c:duration'); + if (count($xduration)) { + $duration = Sabre_CalDAV_XMLUtil::parseICalendarDuration((string)$xduration[0]); + + // Making sure that the duration is bigger than 0 seconds. + $tempDT = clone $dtstart; + $tempDT->modify($duration); + if ($tempDT > $dtstart) { + + // use DTEND = DTSTART + DURATION + $dtend = $tempDT; + } else { + // use DTEND = DTSTART + $dtend = $dtstart; + } + + } + } + + if (is_null($dtend)) { + if ($isDateTime) { + // DTEND = DTSTART + $dtend = $dtstart; + } else { + // DTEND = DTSTART + 1 DAY + $dtend = clone $dtstart; + $dtend->modify('+1 day'); + } + } + // TODO: we need to properly parse RRULE's, but it's very difficult. + // For now, we're always returning events if they have an RRULE at all. + $rrule = $xml->xpath($currentXPath.'/c:rrule'); + $hasRrule = (count($rrule))>0; + + if (!is_null($currentFilter['time-range']['start']) && $currentFilter['time-range']['start'] >= $dtend && !$hasRrule) return false; + if (!is_null($currentFilter['time-range']['end']) && $currentFilter['time-range']['end'] <= $dtstart && !$hasRrule) return false; + return true; + + } + + private function validateTimeRangeFilterForTodo(SimpleXMLElement $xml,$currentXPath,array $filter) { + + // Gathering all relevant elements + + $dtStart = null; + $duration = null; + $due = null; + $completed = null; + $created = null; + + $xdt = $xml->xpath($currentXPath.'/c:dtstart'); + if (count($xdt)) { + // The dtstart can be both a date, or datetime property + if ((string)$xdt[0]['value']==='DATE') { + $isDateTime = false; + } else { + $isDateTime = true; + } + + // Determining the timezone + if ($tzid = (string)$xdt[0]['tzid']) { + $tz = new DateTimeZone($tzid); + } else { + $tz = null; + } + if ($isDateTime) { + $dtStart = Sabre_CalDAV_XMLUtil::parseICalendarDateTime((string)$xdt[0],$tz); + } else { + $dtStart = Sabre_CalDAV_XMLUtil::parseICalendarDate((string)$xdt[0]); + } + } + + // Only need to grab duration if dtStart is set + if (!is_null($dtStart)) { + + $xduration = $xml->xpath($currentXPath.'/c:duration'); + if (count($xduration)) { + $duration = Sabre_CalDAV_XMLUtil::parseICalendarDuration((string)$xduration[0]); + } + + } + + if (!is_null($dtStart) && !is_null($duration)) { + + // Comparision from RFC 4791: + // (start <= DTSTART+DURATION) AND ((end > DTSTART) OR (end >= DTSTART+DURATION)) + + $end = clone $dtStart; + $end->modify($duration); + + if( (is_null($filter['time-range']['start']) || $filter['time-range']['start'] <= $end) && + (is_null($filter['time-range']['end']) || $filter['time-range']['end'] > $dtStart || $filter['time-range']['end'] >= $end) ) { + return true; + } else { + return false; + } + + } + + // Need to grab the DUE property + $xdt = $xml->xpath($currentXPath.'/c:due'); + if (count($xdt)) { + // The due property can be both a date, or datetime property + if ((string)$xdt[0]['value']==='DATE') { + $isDateTime = false; + } else { + $isDateTime = true; + } + // Determining the timezone + if ($tzid = (string)$xdt[0]['tzid']) { + $tz = new DateTimeZone($tzid); + } else { + $tz = null; + } + if ($isDateTime) { + $due = Sabre_CalDAV_XMLUtil::parseICalendarDateTime((string)$xdt[0],$tz); + } else { + $due = Sabre_CalDAV_XMLUtil::parseICalendarDate((string)$xdt[0]); + } + } + + if (!is_null($dtStart) && !is_null($due)) { + + // Comparision from RFC 4791: + // ((start < DUE) OR (start <= DTSTART)) AND ((end > DTSTART) OR (end >= DUE)) + + if( (is_null($filter['time-range']['start']) || $filter['time-range']['start'] < $due || $filter['time-range']['start'] < $dtstart) && + (is_null($filter['time-range']['end']) || $filter['time-range']['end'] >= $due) ) { + return true; + } else { + return false; + } + + } + + if (!is_null($dtStart)) { + + // Comparision from RFC 4791 + // (start <= DTSTART) AND (end > DTSTART) + if ( (is_null($filter['time-range']['start']) || $filter['time-range']['start'] <= $dtStart) && + (is_null($filter['time-range']['end']) || $filter['time-range']['end'] > $dtStart) ) { + return true; + } else { + return false; + } + + } + + if (!is_null($due)) { + + // Comparison from RFC 4791 + // (start < DUE) AND (end >= DUE) + if ( (is_null($filter['time-range']['start']) || $filter['time-range']['start'] < $due) && + (is_null($filter['time-range']['end']) || $filter['time-range']['end'] >= $due) ) { + return true; + } else { + return false; + } + + } + // Need to grab the COMPLETED property + $xdt = $xml->xpath($currentXPath.'/c:completed'); + if (count($xdt)) { + $completed = Sabre_CalDAV_XMLUtil::parseICalendarDateTime((string)$xdt[0]); + } + // Need to grab the CREATED property + $xdt = $xml->xpath($currentXPath.'/c:created'); + if (count($xdt)) { + $created = Sabre_CalDAV_XMLUtil::parseICalendarDateTime((string)$xdt[0]); + } + + if (!is_null($completed) && !is_null($created)) { + // Comparison from RFC 4791 + // ((start <= CREATED) OR (start <= COMPLETED)) AND ((end >= CREATED) OR (end >= COMPLETED)) + if( (is_null($filter['time-range']['start']) || $filter['time-range']['start'] <= $created || $filter['time-range']['start'] <= $completed) && + (is_null($filter['time-range']['end']) || $filter['time-range']['end'] >= $created || $filter['time-range']['end'] >= $completed)) { + return true; + } else { + return false; + } + } + + if (!is_null($completed)) { + // Comparison from RFC 4791 + // (start <= COMPLETED) AND (end >= COMPLETED) + if( (is_null($filter['time-range']['start']) || $filter['time-range']['start'] <= $completed) && + (is_null($filter['time-range']['end']) || $filter['time-range']['end'] >= $completed)) { + return true; + } else { + return false; + } + } + + if (!is_null($created)) { + // Comparison from RFC 4791 + // (end > CREATED) + if( (is_null($filter['time-range']['end']) || $filter['time-range']['end'] > $created) ) { + return true; + } else { + return false; + } + } + + // Everything else is TRUE + return true; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Principal/Collection.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Principal/Collection.php new file mode 100755 index 0000000..ef94bff --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Principal/Collection.php @@ -0,0 +1,31 @@ +principalBackend, $principalInfo); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Principal/ProxyRead.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Principal/ProxyRead.php new file mode 100755 index 0000000..d059232 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Principal/ProxyRead.php @@ -0,0 +1,178 @@ +principalInfo = $principalInfo; + $this->principalBackend = $principalBackend; + + } + + /** + * Returns this principals name. + * + * @return string + */ + public function getName() { + + return 'calendar-proxy-read'; + + } + + /** + * Returns the last modification time + * + * @return null + */ + public function getLastModified() { + + return null; + + } + + /** + * Deletes the current node + * + * @throws Sabre_DAV_Exception_Forbidden + * @return void + */ + public function delete() { + + throw new Sabre_DAV_Exception_Forbidden('Permission denied to delete node'); + + } + + /** + * Renames the node + * + * @throws Sabre_DAV_Exception_Forbidden + * @param string $name The new name + * @return void + */ + public function setName($name) { + + throw new Sabre_DAV_Exception_Forbidden('Permission denied to rename file'); + + } + + + /** + * Returns a list of altenative urls for a principal + * + * This can for example be an email address, or ldap url. + * + * @return array + */ + public function getAlternateUriSet() { + + return array(); + + } + + /** + * Returns the full principal url + * + * @return string + */ + public function getPrincipalUrl() { + + return $this->principalInfo['uri'] . '/' . $this->getName(); + + } + + /** + * Returns the list of group members + * + * If this principal is a group, this function should return + * all member principal uri's for the group. + * + * @return array + */ + public function getGroupMemberSet() { + + return $this->principalBackend->getGroupMemberSet($this->getPrincipalUrl()); + + } + + /** + * Returns the list of groups this principal is member of + * + * If this principal is a member of a (list of) groups, this function + * should return a list of principal uri's for it's members. + * + * @return array + */ + public function getGroupMembership() { + + return $this->principalBackend->getGroupMembership($this->getPrincipalUrl()); + + } + + /** + * Sets a list of group members + * + * If this principal is a group, this method sets all the group members. + * The list of members is always overwritten, never appended to. + * + * This method should throw an exception if the members could not be set. + * + * @param array $principals + * @return void + */ + public function setGroupMemberSet(array $principals) { + + $this->principalBackend->setGroupMemberSet($this->getPrincipalUrl(), $principals); + + } + + /** + * Returns the displayname + * + * This should be a human readable name for the principal. + * If none is available, return the nodename. + * + * @return string + */ + public function getDisplayName() { + + return $this->getName(); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Principal/ProxyWrite.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Principal/ProxyWrite.php new file mode 100755 index 0000000..060afd1 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Principal/ProxyWrite.php @@ -0,0 +1,178 @@ +principalInfo = $principalInfo; + $this->principalBackend = $principalBackend; + + } + + /** + * Returns this principals name. + * + * @return string + */ + public function getName() { + + return 'calendar-proxy-write'; + + } + + /** + * Returns the last modification time + * + * @return null + */ + public function getLastModified() { + + return null; + + } + + /** + * Deletes the current node + * + * @throws Sabre_DAV_Exception_Forbidden + * @return void + */ + public function delete() { + + throw new Sabre_DAV_Exception_Forbidden('Permission denied to delete node'); + + } + + /** + * Renames the node + * + * @throws Sabre_DAV_Exception_Forbidden + * @param string $name The new name + * @return void + */ + public function setName($name) { + + throw new Sabre_DAV_Exception_Forbidden('Permission denied to rename file'); + + } + + + /** + * Returns a list of altenative urls for a principal + * + * This can for example be an email address, or ldap url. + * + * @return array + */ + public function getAlternateUriSet() { + + return array(); + + } + + /** + * Returns the full principal url + * + * @return string + */ + public function getPrincipalUrl() { + + return $this->principalInfo['uri'] . '/' . $this->getName(); + + } + + /** + * Returns the list of group members + * + * If this principal is a group, this function should return + * all member principal uri's for the group. + * + * @return array + */ + public function getGroupMemberSet() { + + return $this->principalBackend->getGroupMemberSet($this->getPrincipalUrl()); + + } + + /** + * Returns the list of groups this principal is member of + * + * If this principal is a member of a (list of) groups, this function + * should return a list of principal uri's for it's members. + * + * @return array + */ + public function getGroupMembership() { + + return $this->principalBackend->getGroupMembership($this->getPrincipalUrl()); + + } + + /** + * Sets a list of group members + * + * If this principal is a group, this method sets all the group members. + * The list of members is always overwritten, never appended to. + * + * This method should throw an exception if the members could not be set. + * + * @param array $principals + * @return void + */ + public function setGroupMemberSet(array $principals) { + + $this->principalBackend->setGroupMemberSet($this->getPrincipalUrl(), $principals); + + } + + /** + * Returns the displayname + * + * This should be a human readable name for the principal. + * If none is available, return the nodename. + * + * @return string + */ + public function getDisplayName() { + + return $this->getName(); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Principal/User.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Principal/User.php new file mode 100755 index 0000000..b737518 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Principal/User.php @@ -0,0 +1,122 @@ +principalBackend, $this->principalProperties); + + if ($name === 'calendar-proxy-write') + return new Sabre_CalDAV_Principal_ProxyWrite($this->principalBackend, $this->principalProperties); + + throw new Sabre_DAV_Exception_FileNotFound('Node with name ' . $name . ' was not found'); + + } + + /** + * Returns an array with all the child nodes + * + * @return Sabre_DAV_INode[] + */ + public function getChildren() { + + return array( + new Sabre_CalDAV_Principal_ProxyRead($this->principalBackend, $this->principalProperties), + new Sabre_CalDAV_Principal_ProxyWrite($this->principalBackend, $this->principalProperties), + ); + + } + + /** + * Checks if a child-node with the specified name exists + * + * @return bool + */ + public function childExists($name) { + + return $name === 'calendar-proxy-read' || $name === 'calendar-proxy-write'; + + } + + /** + * Returns a list of ACE's for this node. + * + * Each ACE has the following properties: + * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are + * currently the only supported privileges + * * 'principal', a url to the principal who owns the node + * * 'protected' (optional), indicating that this ACE is not allowed to + * be updated. + * + * @return array + */ + public function getACL() { + + return array( + array( + 'privilege' => '{DAV:}read', + 'principal' => $this->principalProperties['uri'], + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}read', + 'principal' => $this->principalProperties['uri'] . '/calendar-proxy-read', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}read', + 'principal' => $this->principalProperties['uri'] . '/calendar-proxy-write', + 'protected' => true, + ), + ); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Property/SupportedCalendarComponentSet.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Property/SupportedCalendarComponentSet.php new file mode 100755 index 0000000..d57084c --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Property/SupportedCalendarComponentSet.php @@ -0,0 +1,85 @@ +components = $components; + + } + + /** + * Returns the list of supported components + * + * @return array + */ + public function getValue() { + + return $this->components; + + } + + /** + * Serializes the property in a DOMDocument + * + * @param Sabre_DAV_Server $server + * @param DOMElement $node + * @return void + */ + public function serialize(Sabre_DAV_Server $server,DOMElement $node) { + + $doc = $node->ownerDocument; + foreach($this->components as $component) { + + $xcomp = $doc->createElement('cal:comp'); + $xcomp->setAttribute('name',$component); + $node->appendChild($xcomp); + + } + + } + + /** + * Unserializes the DOMElement back into a Property class. + * + * @param DOMElement $node + * @return void + */ + static function unserialize(DOMElement $node) { + + $components = array(); + foreach($node->childNodes as $childNode) { + if (Sabre_DAV_XMLUtil::toClarkNotation($childNode)==='{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}comp') { + $components[] = $childNode->getAttribute('name'); + } + } + return new self($components); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Property/SupportedCalendarData.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Property/SupportedCalendarData.php new file mode 100755 index 0000000..085701b --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Property/SupportedCalendarData.php @@ -0,0 +1,38 @@ +ownerDocument; + + $prefix = isset($server->xmlNamespaces[Sabre_CalDAV_Plugin::NS_CALDAV])?$server->xmlNamespaces[Sabre_CalDAV_Plugin::NS_CALDAV]:'cal'; + + $caldata = $doc->createElement($prefix . ':calendar-data'); + $caldata->setAttribute('content-type','text/calendar'); + $caldata->setAttribute('version','2.0'); + + $node->appendChild($caldata); + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Property/SupportedCollationSet.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Property/SupportedCollationSet.php new file mode 100755 index 0000000..6f85833 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Property/SupportedCollationSet.php @@ -0,0 +1,44 @@ +ownerDocument; + + $prefix = $node->lookupPrefix('urn:ietf:params:xml:ns:caldav'); + if (!$prefix) $prefix = 'cal'; + + $node->appendChild( + $doc->createElement($prefix . ':supported-collation','i;ascii-casemap') + ); + $node->appendChild( + $doc->createElement($prefix . ':supported-collation','i;octet') + ); + $node->appendChild( + $doc->createElement($prefix . ':supported-collation','i;unicode-casemap') + ); + + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Server.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Server.php new file mode 100755 index 0000000..21d50c4 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Server.php @@ -0,0 +1,65 @@ +authRealm); + $this->addPlugin($authPlugin); + + $aclPlugin = new Sabre_DAVACL_Plugin(); + $this->addPlugin($aclPlugin); + + $caldavPlugin = new Sabre_CalDAV_Plugin(); + $this->addPlugin($caldavPlugin); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/UserCalendars.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/UserCalendars.php new file mode 100755 index 0000000..3c60971 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/UserCalendars.php @@ -0,0 +1,280 @@ +principalBackend = $principalBackend; + $this->caldavBackend = $caldavBackend; + $this->principalInfo = $principalBackend->getPrincipalByPath($userUri); + + } + + /** + * Returns the name of this object + * + * @return string + */ + public function getName() { + + list(,$name) = Sabre_DAV_URLUtil::splitPath($this->principalInfo['uri']); + return $name; + + } + + /** + * Updates the name of this object + * + * @param string $name + * @return void + */ + public function setName($name) { + + throw new Sabre_DAV_Exception_Forbidden(); + + } + + /** + * Deletes this object + * + * @return void + */ + public function delete() { + + throw new Sabre_DAV_Exception_Forbidden(); + + } + + /** + * Returns the last modification date + * + * @return int + */ + public function getLastModified() { + + return null; + + } + + /** + * Creates a new file under this object. + * + * This is currently not allowed + * + * @param string $filename + * @param resource $data + * @return void + */ + public function createFile($filename, $data=null) { + + throw new Sabre_DAV_Exception_MethodNotAllowed('Creating new files in this collection is not supported'); + + } + + /** + * Creates a new directory under this object. + * + * This is currently not allowed. + * + * @param string $filename + * @return void + */ + public function createDirectory($filename) { + + throw new Sabre_DAV_Exception_MethodNotAllowed('Creating new collections in this collection is not supported'); + + } + + /** + * Returns a single calendar, by name + * + * @param string $name + * @todo needs optimizing + * @return Sabre_CalDAV_Calendar + */ + public function getChild($name) { + + foreach($this->getChildren() as $child) { + if ($name==$child->getName()) + return $child; + + } + throw new Sabre_DAV_Exception_FileNotFound('Calendar with name \'' . $name . '\' could not be found'); + + } + + /** + * Checks if a calendar exists. + * + * @param string $name + * @todo needs optimizing + * @return bool + */ + public function childExists($name) { + + foreach($this->getChildren() as $child) { + if ($name==$child->getName()) + return true; + + } + return false; + + } + + /** + * Returns a list of calendars + * + * @return array + */ + public function getChildren() { + + $calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']); + $objs = array(); + foreach($calendars as $calendar) { + $objs[] = new Sabre_CalDAV_Calendar($this->principalBackend, $this->caldavBackend, $calendar); + } + return $objs; + + } + + /** + * Creates a new calendar + * + * @param string $name + * @param string $properties + * @return void + */ + public function createExtendedCollection($name, array $resourceType, array $properties) { + + if (!in_array('{urn:ietf:params:xml:ns:caldav}calendar',$resourceType) || count($resourceType)!==2) { + throw new Sabre_DAV_Exception_InvalidResourceType('Unknown resourceType for this collection'); + } + $this->caldavBackend->createCalendar($this->principalInfo['uri'], $name, $properties); + + } + + /** + * Returns the owner principal + * + * This must be a url to a principal, or null if there's no owner + * + * @return string|null + */ + public function getOwner() { + + return $this->principalInfo['uri']; + + } + + /** + * Returns a group principal + * + * This must be a url to a principal, or null if there's no owner + * + * @return string|null + */ + public function getGroup() { + + return null; + + } + + /** + * Returns a list of ACE's for this node. + * + * Each ACE has the following properties: + * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are + * currently the only supported privileges + * * 'principal', a url to the principal who owns the node + * * 'protected' (optional), indicating that this ACE is not allowed to + * be updated. + * + * @return array + */ + public function getACL() { + + return array( + array( + 'privilege' => '{DAV:}read', + 'principal' => $this->principalInfo['uri'], + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => $this->principalInfo['uri'], + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}read', + 'principal' => $this->principalInfo['uri'] . '/calendar-proxy-write', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => $this->principalInfo['uri'] . '/calendar-proxy-write', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}read', + 'principal' => $this->principalInfo['uri'] . '/calendar-proxy-read', + 'protected' => true, + ), + + ); + + } + + /** + * Updates the ACL + * + * This method will receive a list of new ACE's. + * + * @param array $acl + * @return void + */ + public function setACL(array $acl) { + + throw new Sabre_DAV_Exception_MethodNotAllowed('Changing ACL is not yet supported'); + + } + + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Version.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Version.php new file mode 100755 index 0000000..b894e1e --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CalDAV/Version.php @@ -0,0 +1,24 @@ +childNodes as $child) { + + switch(Sabre_DAV_XMLUtil::toClarkNotation($child)) { + + case '{urn:ietf:params:xml:ns:caldav}comp-filter' : + case '{urn:ietf:params:xml:ns:caldav}prop-filter' : + + $filterName = $basePath . '/' . 'c:' . strtolower($child->getAttribute('name')); + $filters[$filterName] = array(); + + self::parseCalendarQueryFilters($child, $filterName,$filters); + break; + + case '{urn:ietf:params:xml:ns:caldav}time-range' : + + if ($start = $child->getAttribute('start')) { + $start = self::parseICalendarDateTime($start); + } else { + $start = null; + } + if ($end = $child->getAttribute('end')) { + $end = self::parseICalendarDateTime($end); + } else { + $end = null; + } + + if (!is_null($start) && !is_null($end) && $end <= $start) { + throw new Sabre_DAV_Exception_BadRequest('The end-date must be larger than the start-date in the time-range filter'); + } + + $filters[$basePath]['time-range'] = array( + 'start' => $start, + 'end' => $end + ); + break; + + case '{urn:ietf:params:xml:ns:caldav}is-not-defined' : + $filters[$basePath]['is-not-defined'] = true; + break; + + case '{urn:ietf:params:xml:ns:caldav}param-filter' : + + $filterName = $basePath . '/@' . strtolower($child->getAttribute('name')); + $filters[$filterName] = array(); + self::parseCalendarQueryFilters($child, $filterName, $filters); + break; + + case '{urn:ietf:params:xml:ns:caldav}text-match' : + + $collation = $child->getAttribute('collation'); + if (!$collation) $collation = 'i;ascii-casemap'; + + $filters[$basePath]['text-match'] = array( + 'collation' => ($collation == 'default'?'i;ascii-casemap':$collation), + 'negate-condition' => $child->getAttribute('negate-condition')==='yes', + 'value' => $child->nodeValue, + ); + break; + + } + + } + + return $filters; + + } + + /** + * Parses an iCalendar (rfc5545) formatted datetime and returns a DateTime object + * + * Specifying a reference timezone is optional. It will only be used + * if the non-UTC format is used. The argument is used as a reference, the + * returned DateTime object will still be in the UTC timezone. + * + * @param string $dt + * @param DateTimeZone $tz + * @return DateTime + */ + static public function parseICalendarDateTime($dt,DateTimeZone $tz = null) { + + // Format is YYYYMMDD + "T" + hhmmss + $result = preg_match('/^([1-3][0-9]{3})([0-1][0-9])([0-3][0-9])T([0-2][0-9])([0-5][0-9])([0-5][0-9])([Z]?)$/',$dt,$matches); + + if (!$result) { + throw new Sabre_DAV_Exception_BadRequest('The supplied iCalendar datetime value is incorrect: ' . $dt); + } + + if ($matches[7]==='Z' || is_null($tz)) { + $tz = new DateTimeZone('UTC'); + } + $date = new DateTime($matches[1] . '-' . $matches[2] . '-' . $matches[3] . ' ' . $matches[4] . ':' . $matches[5] .':' . $matches[6], $tz); + + // Still resetting the timezone, to normalize everything to UTC + $date->setTimeZone(new DateTimeZone('UTC')); + return $date; + + } + + /** + * Parses an iCalendar (rfc5545) formatted datetime and returns a DateTime object + * + * @param string $date + * @param DateTimeZone $tz + * @return DateTime + */ + static public function parseICalendarDate($date) { + + // Format is YYYYMMDD + $result = preg_match('/^([1-3][0-9]{3})([0-1][0-9])([0-3][0-9])$/',$date,$matches); + + if (!$result) { + throw new Sabre_DAV_Exception_BadRequest('The supplied iCalendar date value is incorrect: ' . $date); + } + + $date = new DateTime($matches[1] . '-' . $matches[2] . '-' . $matches[3], new DateTimeZone('UTC')); + return $date; + + } + + /** + * Parses an iCalendar (RFC5545) formatted duration and returns a string suitable + * for strtotime or DateTime::modify. + * + * NOTE: When we require PHP 5.3 this can be replaced by the DateTimeInterval object, which + * supports ISO 8601 Intervals, which is a superset of ICalendar durations. + * + * For now though, we're just gonna live with this messy system + * + * @param string $duration + * @return string + */ + static public function parseICalendarDuration($duration) { + + $result = preg_match('/^(?P\+|-)?P((?P\d+)W)?((?P\d+)D)?(T((?P\d+)H)?((?P\d+)M)?((?P\d+)S)?)?$/', $duration, $matches); + if (!$result) { + throw new Sabre_DAV_Exception_BadRequest('The supplied iCalendar duration value is incorrect: ' . $duration); + } + + $parts = array( + 'week', + 'day', + 'hour', + 'minute', + 'second', + ); + + $newDur = ''; + foreach($parts as $part) { + if (isset($matches[$part]) && $matches[$part]) { + $newDur.=' '.$matches[$part] . ' ' . $part . 's'; + } + } + + $newDur = ($matches['plusminus']==='-'?'-':'+') . trim($newDur); + return $newDur; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/AddressBook.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/AddressBook.php new file mode 100755 index 0000000..adb4dfa --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/AddressBook.php @@ -0,0 +1,293 @@ +carddavBackend = $carddavBackend; + $this->addressBookInfo = $addressBookInfo; + + } + + /** + * Returns the name of the addressbook + * + * @return string + */ + public function getName() { + + return $this->addressBookInfo['uri']; + + } + + /** + * Returns a card + * + * @param string $name + * @return Sabre_DAV_Card + */ + public function getChild($name) { + + $obj = $this->carddavBackend->getCard($this->addressBookInfo['id'],$name); + if (!$obj) throw new Sabre_DAV_Exception_FileNotFound('Card not found'); + return new Sabre_CardDAV_Card($this->carddavBackend,$this->addressBookInfo,$obj); + + } + + /** + * Returns the full list of cards + * + * @return array + */ + public function getChildren() { + + $objs = $this->carddavBackend->getCards($this->addressBookInfo['id']); + $children = array(); + foreach($objs as $obj) { + $children[] = new Sabre_CardDAV_Card($this->carddavBackend,$this->addressBookInfo,$obj); + } + return $children; + + } + + /** + * Creates a new directory + * + * We actually block this, as subdirectories are not allowed in addressbooks. + * + * @param string $name + * @return void + */ + public function createDirectory($name) { + + throw new Sabre_DAV_Exception_MethodNotAllowed('Creating collections in addressbooks is not allowed'); + + } + + /** + * Creates a new file + * + * The contents of the new file must be a valid VCARD + * + * @param string $name + * @param resource $vcardData + * @return void + */ + public function createFile($name,$vcardData = null) { + + $vcardData = stream_get_contents($vcardData); + // Converting to UTF-8, if needed + $vcardData = Sabre_DAV_StringUtil::ensureUTF8($vcardData); + + $this->carddavBackend->createCard($this->addressBookInfo['id'],$name,$vcardData); + + } + + /** + * Deletes the entire addressbook. + * + * @return void + */ + public function delete() { + + $this->carddavBackend->deleteAddressBook($this->addressBookInfo['id']); + + } + + /** + * Renames the addressbook + * + * @param string $newName + * @return void + */ + public function setName($newName) { + + throw new Sabre_DAV_Exception_MethodNotAllowed('Renaming addressbooks is not yet supported'); + + } + + /** + * Returns the last modification date as a unix timestamp. + * + * @return void + */ + public function getLastModified() { + + return null; + + } + + /** + * Updates properties on this node, + * + * The properties array uses the propertyName in clark-notation as key, + * and the array value for the property value. In the case a property + * should be deleted, the property value will be null. + * + * This method must be atomic. If one property cannot be changed, the + * entire operation must fail. + * + * If the operation was successful, true can be returned. + * If the operation failed, false can be returned. + * + * Deletion of a non-existant property is always succesful. + * + * Lastly, it is optional to return detailed information about any + * failures. In this case an array should be returned with the following + * structure: + * + * array( + * 403 => array( + * '{DAV:}displayname' => null, + * ), + * 424 => array( + * '{DAV:}owner' => null, + * ) + * ) + * + * In this example it was forbidden to update {DAV:}displayname. + * (403 Forbidden), which in turn also caused {DAV:}owner to fail + * (424 Failed Dependency) because the request needs to be atomic. + * + * @param array $mutations + * @return bool|array + */ + public function updateProperties($mutations) { + + return $this->carddavBackend->updateAddressBook($this->addressBookInfo['id'], $mutations); + + } + + /** + * Returns a list of properties for this nodes. + * + * The properties list is a list of propertynames the client requested, + * encoded in clark-notation {xmlnamespace}tagname + * + * If the array is empty, it means 'all properties' were requested. + * + * @param array $properties + * @return void + */ + public function getProperties($properties) { + + $response = array(); + foreach($properties as $propertyName) { + + if (isset($this->addressBookInfo[$propertyName])) { + + $response[$propertyName] = $this->addressBookInfo[$propertyName]; + + } + + } + + return $response; + + } + + /** + * Returns the owner principal + * + * This must be a url to a principal, or null if there's no owner + * + * @return string|null + */ + public function getOwner() { + + return $this->addressBookInfo['principaluri']; + + } + + /** + * Returns a group principal + * + * This must be a url to a principal, or null if there's no owner + * + * @return string|null + */ + public function getGroup() { + + return null; + + } + + /** + * Returns a list of ACE's for this node. + * + * Each ACE has the following properties: + * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are + * currently the only supported privileges + * * 'principal', a url to the principal who owns the node + * * 'protected' (optional), indicating that this ACE is not allowed to + * be updated. + * + * @return array + */ + public function getACL() { + + return array( + array( + 'privilege' => '{DAV:}read', + 'principal' => $this->addressBookInfo['principaluri'], + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => $this->addressBookInfo['principaluri'], + 'protected' => true, + ), + + ); + + } + + /** + * Updates the ACL + * + * This method will receive a list of new ACE's. + * + * @param array $acl + * @return void + */ + public function setACL(array $acl) { + + throw new Sabre_DAV_Exception_MethodNotAllowed('Changing ACL is not yet supported'); + + } + + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/AddressBookQueryParser.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/AddressBookQueryParser.php new file mode 100755 index 0000000..2815ce3 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/AddressBookQueryParser.php @@ -0,0 +1,211 @@ +dom = $dom; + + $this->xpath = new DOMXPath($dom); + $this->xpath->registerNameSpace('card',Sabre_CardDAV_Plugin::NS_CARDDAV); + + } + + /** + * Parses the request. + * + * @param DOMNode $dom + * @return void + */ + public function parse() { + + $filterNode = null; + + $limit = $this->xpath->evaluate('number(/card:addressbook-query/card:limit/card:nresults)'); + if (is_nan($limit)) $limit = null; + + $filter = $this->xpath->query('/card:addressbook-query/card:filter'); + if ($filter->length !== 1) { + throw new Sabre_DAV_Exception_BadRequest('Only one filter element is allowed'); + } + + $filter = $filter->item(0); + $test = $this->xpath->evaluate('string(@test)', $filter); + if (!$test) $test = self::TEST_ANYOF; + if ($test !== self::TEST_ANYOF && $test !== self::TEST_ALLOF) { + throw new Sabre_DAV_Exception_BadRequest('The test attribute must either hold "anyof" or "allof"'); + } + + $propFilters = array(); + + $propFilterNodes = $this->xpath->query('card:prop-filter', $filter); + for($ii=0; $ii < $propFilterNodes->length; $ii++) { + + $propFilters[] = $this->parsePropFilterNode($propFilterNodes->item($ii)); + + + } + + $this->filters = $propFilters; + $this->limit = $limit; + $this->requestedProperties = array_keys(Sabre_DAV_XMLUtil::parseProperties($this->dom->firstChild)); + $this->test = $test; + + } + + /** + * Parses the prop-filter xml element + * + * @param DOMElement $propFilterNode + * @return array + */ + protected function parsePropFilterNode(DOMElement $propFilterNode) { + + $propFilter = array(); + $propFilter['name'] = $propFilterNode->getAttribute('name'); + $propFilter['test'] = $propFilterNode->getAttribute('test'); + if (!$propFilter['test']) $propFilter['test'] = 'anyof'; + + $propFilter['is-not-defined'] = $this->xpath->query('card:is-not-defined', $propFilterNode)->length>0; + + $paramFilterNodes = $this->xpath->query('card:param-filter', $propFilterNode); + + $propFilter['param-filters'] = array(); + + + for($ii=0;$ii<$paramFilterNodes->length;$ii++) { + + $propFilter['param-filters'][] = $this->parseParamFilterNode($paramFilterNodes->item($ii)); + + } + $propFilter['text-matches'] = array(); + $textMatchNodes = $this->xpath->query('card:text-match', $propFilterNode); + + for($ii=0;$ii<$textMatchNodes->length;$ii++) { + + $propFilter['text-matches'][] = $this->parseTextMatchNode($textMatchNodes->item($ii)); + + } + + return $propFilter; + + } + + /** + * Parses the param-filter element + * + * @param DOMElement $paramFilterNode + * @return array + */ + public function parseParamFilterNode(DOMElement $paramFilterNode) { + + $paramFilter = array(); + $paramFilter['name'] = $paramFilterNode->getAttribute('name'); + $paramFilter['is-not-defined'] = $this->xpath->query('card:is-not-defined', $paramFilterNode)->length>0; + $paramFilter['text-match'] = null; + + $textMatch = $this->xpath->query('card:text-match', $paramFilterNode); + if ($textMatch->length>0) { + $paramFilter['text-match'] = $this->parseTextMatchNode($textMatch->item(0)); + } + + return $paramFilter; + + } + + /** + * Text match + * + * @param DOMElement $textMatchNode + * @return void + */ + public function parseTextMatchNode(DOMElement $textMatchNode) { + + $matchType = $textMatchNode->getAttribute('match-type'); + if (!$matchType) $matchType = 'contains'; + + if (!in_array($matchType, array('contains', 'equals', 'starts-with', 'ends-with'))) { + throw new Sabre_DAV_Exception_BadRequest('Unknown match-type: ' . $matchType); + } + + $negateCondition = $textMatchNode->getAttribute('negate-condition'); + $negateCondition = $negateCondition==='yes'; + $collation = $textMatchNode->getAttribute('collation'); + if (!$collation) $collation = 'i;unicode-casemap'; + + return array( + 'negate-condition' => $negateCondition, + 'collation' => $collation, + 'match-type' => $matchType, + 'value' => $textMatchNode->nodeValue + ); + + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/AddressBookRoot.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/AddressBookRoot.php new file mode 100755 index 0000000..d51f352 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/AddressBookRoot.php @@ -0,0 +1,78 @@ +carddavBackend = $carddavBackend; + parent::__construct($principalBackend, $principalPrefix); + + } + + /** + * Returns the name of the node + * + * @return string + */ + public function getName() { + + return Sabre_CardDAV_Plugin::ADDRESSBOOK_ROOT; + + } + + /** + * This method returns a node for a principal. + * + * The passed array contains principal information, and is guaranteed to + * at least contain a uri item. Other properties may or may not be + * supplied by the authentication backend. + * + * @param array $principal + * @return Sabre_DAV_INode + */ + public function getChildForPrincipal(array $principal) { + + return new Sabre_CardDAV_UserAddressBooks($this->carddavBackend, $principal['uri']); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/Backend/Abstract.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/Backend/Abstract.php new file mode 100755 index 0000000..8cbb11c --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/Backend/Abstract.php @@ -0,0 +1,121 @@ +pdo = $pdo; + $this->addressBooksTableName = $addressBooksTableName; + $this->cardsTableName = $cardsTableName; + + } + + /** + * Returns the list of addressbooks for a specific user. + * + * @param string $principalUri + * @return array + */ + public function getAddressBooksForUser($principalUri) { + + $stmt = $this->pdo->prepare('SELECT id, uri, displayname, principaluri, description, ctag FROM `'.$this->addressBooksTableName.'` WHERE principaluri = ?'); + $result = $stmt->execute(array($principalUri)); + + $addressBooks = array(); + + foreach($stmt->fetchAll() as $row) { + + $addressBooks[] = array( + 'id' => $row['id'], + 'uri' => $row['uri'], + 'principaluri' => $row['principaluri'], + '{DAV:}displayname' => $row['displayname'], + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], + '{http://calendarserver.org/ns/}getctag' => $row['ctag'], + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}supported-address-data' => + new Sabre_CardDAV_Property_SupportedAddressData(), + ); + + } + + return $addressBooks; + + } + + + /** + * Updates an addressbook's properties + * + * See Sabre_DAV_IProperties for a description of the mutations array, as + * well as the return value. + * + * @param mixed $addressBookId + * @param array $mutations + * @see Sabre_DAV_IProperties::updateProperties + * @return bool|array + */ + public function updateAddressBook($addressBookId, array $mutations) { + + $updates = array(); + + foreach($mutations as $property=>$newValue) { + + switch($property) { + case '{DAV:}displayname' : + $updates['displayname'] = $newValue; + break; + case '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' : + $updates['description'] = $newValue; + break; + default : + // If any unsupported values were being updated, we must + // let the entire request fail. + return false; + } + + } + + // No values are being updated? + if (!$updates) { + return false; + } + + $query = 'UPDATE `' . $this->addressBooksTableName . '` SET ctag = ctag + 1 '; + foreach($updates as $key=>$value) { + $query.=', `' . $key . '` = :' . $key . ' '; + } + $query.=' WHERE id = :addressbookid'; + + $stmt = $this->pdo->prepare($query); + $updates['addressbookid'] = $addressBookId; + + $stmt->execute($updates); + + return true; + + } + + /** + * Creates a new address book + * + * @param string $principalUri + * @param string $url Just the 'basename' of the url. + * @param array $properties + * @return void + */ + public function createAddressBook($principalUri, $url, array $properties) { + + $values = array( + 'displayname' => null, + 'description' => null, + 'principaluri' => $principalUri, + 'uri' => $url, + ); + + foreach($properties as $property=>$newValue) { + + switch($property) { + case '{DAV:}displayname' : + $values['displayname'] = $newValue; + break; + case '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' : + $values['description'] = $newValue; + break; + default : + throw new Sabre_DAV_Exception_BadRequest('Unknown property: ' . $property); + } + + } + + $query = 'INSERT INTO `' . $this->addressBooksTableName . '` (uri, displayname, description, principaluri, ctag) VALUES (:uri, :displayname, :description, :principaluri, 1)'; + $stmt = $this->pdo->prepare($query); + $stmt->execute($values); + + } + + /** + * Deletes an entire addressbook and all its contents + * + * @param int $addressBookId + * @return void + */ + public function deleteAddressBook($addressBookId) { + + $stmt = $this->pdo->prepare('DELETE FROM `' . $this->cardsTableName . '` WHERE addressbookid = ?'); + $stmt->execute(array($addressBookId)); + + $stmt = $this->pdo->prepare('DELETE FROM `' . $this->addressBooksTableName . '` WHERE id = ?'); + $stmt->execute(array($addressBookId)); + + } + + /** + * Returns all cards for a specific addressbook id. + * + * @param mixed $addressbookId + * @return array + */ + public function getCards($addressbookId) { + + $stmt = $this->pdo->prepare('SELECT id, carddata, uri, lastmodified FROM `' . $this->cardsTableName . '` WHERE addressbookid = ?'); + $stmt->execute(array($addressbookId)); + + return $stmt->fetchAll(PDO::FETCH_ASSOC); + + + } + /** + * Returns a specfic card + * + * @param mixed $addressBookId + * @param string $cardUri + * @return array + */ + public function getCard($addressBookId, $cardUri) { + + $stmt = $this->pdo->prepare('SELECT id, carddata, uri, lastmodified FROM `' . $this->cardsTableName . '` WHERE addressbookid = ? AND uri = ? LIMIT 1'); + $stmt->execute(array($addressBookId, $cardUri)); + + $result = $stmt->fetchAll(PDO::FETCH_ASSOC); + + return (count($result)>0?$result[0]:false); + + } + + /** + * Creates a new card + * + * @param mixed $addressBookId + * @param string $cardUri + * @param string $cardData + * @return bool + */ + public function createCard($addressBookId, $cardUri, $cardData) { + + $stmt = $this->pdo->prepare('INSERT INTO `' . $this->cardsTableName . '` (carddata, uri, lastmodified, addressbookid) VALUES (?, ?, ?, ?)'); + + $result = $stmt->execute(array($cardData, $cardUri, time(), $addressBookId)); + + $stmt2 = $this->pdo->prepare('UPDATE `' . $this->addressBooksTableName . '` SET ctag = ctag + 1 WHERE id = ?'); + $stmt2->execute(array($addressBookId)); + + return $result; + + } + + /** + * Updates a card + * + * @param mixed $addressBookId + * @param string $cardUri + * @param string $cardData + * @return bool + */ + public function updateCard($addressBookId, $cardUri, $cardData) { + + $stmt = $this->pdo->prepare('UPDATE `' . $this->cardsTableName . '` SET carddata = ?, lastmodified = ? WHERE uri = ? AND addressbookid =?'); + $result = $stmt->execute(array($cardData, time(), $cardUri, $addressBookId)); + + $stmt2 = $this->pdo->prepare('UPDATE `' . $this->addressBooksTableName . '` SET ctag = ctag + 1 WHERE id = ?'); + $stmt2->execute(array($addressBookId)); + + return $stmt->rowCount()===1; + + } + + /** + * Deletes a card + * + * @param mixed $addressBookId + * @param string $cardUri + * @return bool + */ + public function deleteCard($addressBookId, $cardUri) { + + $stmt = $this->pdo->prepare('DELETE FROM `' . $this->cardsTableName . '` WHERE addressbookid = ? AND uri = ?'); + $stmt->execute(array($addressBookId, $cardUri)); + + $stmt2 = $this->pdo->prepare('UPDATE `' . $this->addressBooksTableName . '` SET ctag = ctag + 1 WHERE id = ?'); + $stmt2->execute(array($addressBookId)); + + return $stmt->rowCount()===1; + + } +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/Card.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/Card.php new file mode 100755 index 0000000..f4b91f9 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/Card.php @@ -0,0 +1,225 @@ +carddavBackend = $carddavBackend; + $this->addressBookInfo = $addressBookInfo; + $this->cardData = $cardData; + + } + + /** + * Returns the uri for this object + * + * @return string + */ + public function getName() { + + return $this->cardData['uri']; + + } + + /** + * Returns the VCard-formatted object + * + * @return string + */ + public function get() { + + // Pre-populating 'carddata' is optional. If we don't yet have it + // already, we fetch it from the backend. + if (!isset($this->cardData['carddata'])) { + $this->cardData = $this->carddavBackend->getCard($this->addressBookInfo['id'], $this->cardData['uri']); + } + return $this->cardData['carddata']; + + } + + /** + * Updates the VCard-formatted object + * + * @param string $cardData + * @return void + */ + public function put($cardData) { + + if (is_resource($cardData)) + $cardData = stream_get_contents($cardData); + + // Converting to UTF-8, if needed + $cardData = Sabre_DAV_StringUtil::ensureUTF8($cardData); + + $this->carddavBackend->updateCard($this->addressBookInfo['id'],$this->cardData['uri'],$cardData); + $this->cardData['carddata'] = $cardData; + + } + + /** + * Deletes the card + * + * @return void + */ + public function delete() { + + $this->carddavBackend->deleteCard($this->addressBookInfo['id'],$this->cardData['uri']); + + } + + /** + * Returns the mime content-type + * + * @return string + */ + public function getContentType() { + + return 'text/x-vcard'; + + } + + /** + * Returns an ETag for this object + * + * @return string + */ + public function getETag() { + + if (isset($this->cardData['etag'])) { + return $this->cardData['etag']; + } else { + return '"' . md5($this->get()) . '"'; + } + + } + + /** + * Returns the last modification date as a unix timestamp + * + * @return time + */ + public function getLastModified() { + + return isset($this->cardData['lastmodified'])?$this->cardData['lastmodified']:null; + + } + + /** + * Returns the size of this object in bytes + * + * @return int + */ + public function getSize() { + + return strlen($this->get()); + + } + + /** + * Returns the owner principal + * + * This must be a url to a principal, or null if there's no owner + * + * @return string|null + */ + public function getOwner() { + + return $this->addressBookInfo['principaluri']; + + } + + /** + * Returns a group principal + * + * This must be a url to a principal, or null if there's no owner + * + * @return string|null + */ + public function getGroup() { + + return null; + + } + + /** + * Returns a list of ACE's for this node. + * + * Each ACE has the following properties: + * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are + * currently the only supported privileges + * * 'principal', a url to the principal who owns the node + * * 'protected' (optional), indicating that this ACE is not allowed to + * be updated. + * + * @return array + */ + public function getACL() { + + return array( + array( + 'privilege' => '{DAV:}read', + 'principal' => $this->addressBookInfo['principaluri'], + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => $this->addressBookInfo['principaluri'], + 'protected' => true, + ), + ); + + } + + /** + * Updates the ACL + * + * This method will receive a list of new ACE's. + * + * @param array $acl + * @return void + */ + public function setACL(array $acl) { + + throw new Sabre_DAV_Exception_MethodNotAllowed('Changing ACL is not yet supported'); + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/IAddressBook.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/IAddressBook.php new file mode 100755 index 0000000..977c016 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/IAddressBook.php @@ -0,0 +1,18 @@ +subscribeEvent('beforeGetProperties', array($this, 'beforeGetProperties')); + $server->subscribeEvent('report', array($this,'report')); + + /* Namespaces */ + $server->xmlNamespaces[self::NS_CARDDAV] = 'card'; + + /* Mapping Interfaces to {DAV:}resourcetype values */ + $server->resourceTypeMapping['Sabre_CardDAV_IAddressBook'] = '{' . self::NS_CARDDAV . '}addressbook'; + $server->resourceTypeMapping['Sabre_CardDAV_IDirectory'] = '{' . self::NS_CARDDAV . '}directory'; + + /* Adding properties that may never be changed */ + $server->protectedProperties[] = '{' . self::NS_CARDDAV . '}supported-address-data'; + $server->protectedProperties[] = '{' . self::NS_CARDDAV . '}max-resource-size'; + + + $this->server = $server; + + } + + /** + * Returns a list of supported features. + * + * This is used in the DAV: header in the OPTIONS and PROPFIND requests. + * + * @return array + */ + public function getFeatures() { + + return array('addressbook'); + + } + + /** + * Returns a list of reports this plugin supports. + * + * This will be used in the {DAV:}supported-report-set property. + * Note that you still need to subscribe to the 'report' event to actually + * implement them + * + * @param string $uri + * @return array + */ + public function getSupportedReportSet($uri) { + + $node = $this->server->tree->getNodeForPath($uri); + if ($node instanceof Sabre_CardDAV_IAddressBook || $node instanceof Sabre_CardDAV_ICard) { + return array( + '{' . self::NS_CARDDAV . '}addressbook-multiget', + '{' . self::NS_CARDDAV . '}addressbook-query', + ); + } + return array(); + + } + + + /** + * Adds all CardDAV-specific properties + * + * @param string $path + * @param Sabre_DAV_INode $node + * @param array $requestedProperties + * @param array $returnedProperties + * @return void + */ + public function beforeGetProperties($path, Sabre_DAV_INode $node, array &$requestedProperties, array &$returnedProperties) { + + if ($node instanceof Sabre_DAVACL_IPrincipal) { + + // calendar-home-set property + $addHome = '{' . self::NS_CARDDAV . '}addressbook-home-set'; + if (in_array($addHome,$requestedProperties)) { + $principalId = $node->getName(); + $addressbookHomePath = self::ADDRESSBOOK_ROOT . '/' . $principalId . '/'; + unset($requestedProperties[array_search($addHome, $requestedProperties)]); + $returnedProperties[200][$addHome] = new Sabre_DAV_Property_Href($addressbookHomePath); + } + + $directories = '{' . self::NS_CARDDAV . '}directory-gateway'; + if ($this->directories && in_array($directories, $requestedProperties)) { + unset($requestedProperties[array_search($directories, $requestedProperties)]); + $returnedProperties[200][$directories] = new Sabre_DAV_Property_HrefList($this->directories); + } + + } + + if ($node instanceof Sabre_CardDAV_ICard) { + + // The address-data property is not supposed to be a 'real' + // property, but in large chunks of the spec it does act as such. + // Therefore we simply expose it as a property. + $addressDataProp = '{' . self::NS_CARDDAV . '}address-data'; + if (in_array($addressDataProp, $requestedProperties)) { + unset($requestedProperties[$addressDataProp]); + $val = $node->get(); + if (is_resource($val)) + $val = stream_get_contents($val); + + // Taking out \r to not screw up the xml output + $returnedProperties[200][$addressDataProp] = str_replace("\r","", $val); + + } + } + + } + + /** + * This functions handles REPORT requests specific to CardDAV + * + * @param string $reportName + * @param DOMNode $dom + * @return bool + */ + public function report($reportName,$dom) { + + switch($reportName) { + case '{'.self::NS_CARDDAV.'}addressbook-multiget' : + $this->addressbookMultiGetReport($dom); + return false; + case '{'.self::NS_CARDDAV.'}addressbook-query' : + $this->addressBookQueryReport($dom); + return false; + default : + return; + + } + + + } + + /** + * This function handles the addressbook-multiget REPORT. + * + * This report is used by the client to fetch the content of a series + * of urls. Effectively avoiding a lot of redundant requests. + * + * @param DOMNode $dom + * @return void + */ + public function addressbookMultiGetReport($dom) { + + $properties = array_keys(Sabre_DAV_XMLUtil::parseProperties($dom->firstChild)); + + $hrefElems = $dom->getElementsByTagNameNS('urn:DAV','href'); + $propertyList = array(); + + foreach($hrefElems as $elem) { + + $uri = $this->server->calculateUri($elem->nodeValue); + list($propertyList[]) = $this->server->getPropertiesForPath($uri,$properties); + + } + + $this->server->httpResponse->sendStatus(207); + $this->server->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8'); + $this->server->httpResponse->sendBody($this->server->generateMultiStatus($propertyList)); + + } + + /** + * This function handles the addressbook-query REPORT + * + * This report is used by the client to filter an addressbook based on a + * complex query. + * + * @param DOMNode $dom + * @return void + */ + protected function addressbookQueryReport($dom) { + + $query = new Sabre_CardDAV_AddressBookQueryParser($dom); + $query->parse(); + + $depth = $this->server->getHTTPDepth(0); + + if ($depth==0) { + $candidateNodes = array( + $this->server->tree->getNodeForPath($this->server->getRequestUri()) + ); + } else { + $candidateNodes = $this->server->tree->getChildren($this->server->getRequestUri()); + } + + $validNodes = array(); + foreach($candidateNodes as $node) { + + if (!$node instanceof Sabre_CardDAV_ICard) + continue; + + $blob = $node->get(); + if (is_resource($blob)) { + $blob = stream_get_contents($blob); + } + + if (!$this->validateFilters($blob, $query->filters, $query->test)) { + continue; + } + + $validNodes[] = $node; + + if ($query->limit && $query->limit <= count($validNodes)) { + // We hit the maximum number of items, we can stop now. + break; + } + + } + + $result = array(); + foreach($validNodes as $validNode) { + if ($depth==0) { + $href = $this->server->getRequestUri(); + } else { + $href = $this->server->getRequestUri() . '/' . $validNode->getName(); + } + + list($result[]) = $this->server->getPropertiesForPath($href, $query->requestedProperties, 0); + + } + + $this->server->httpResponse->sendStatus(207); + $this->server->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8'); + $this->server->httpResponse->sendBody($this->server->generateMultiStatus($result)); + + } + + /** + * Validates if a vcard makes it throught a list of filters. + * + * @param string $vcardData + * @param array $filters + * @param string $test anyof or allof (which means OR or AND) + * @return bool + */ + public function validateFilters($vcardData, array $filters, $test) { + + $vcard = Sabre_VObject_Reader::read($vcardData); + + $success = true; + + foreach($filters as $filter) { + + $isDefined = isset($vcard->{$filter['name']}); + if ($filter['is-not-defined']) { + if ($isDefined) { + $success = false; + } else { + $success = true; + } + } elseif ((!$filter['param-filters'] && !$filter['text-matches']) || !$isDefined) { + + // We only need to check for existence + $success = $isDefined; + + } else { + + $vProperties = $vcard->select($filter['name']); + + $results = array(); + if ($filter['param-filters']) { + $results[] = $this->validateParamFilters($vProperties, $filter['param-filters'], $filter['test']); + } + if ($filter['text-matches']) { + $texts = array(); + foreach($vProperties as $vProperty) + $texts[] = $vProperty->value; + + $results[] = $this->validateTextMatches($texts, $filter['text-matches'], $filter['test']); + } + + if (count($results)===1) { + $success = $results[0]; + } else { + if ($filter['test'] === 'anyof') { + $success = $results[0] || $results[1]; + } else { + $success = $results[0] && $results[1]; + } + } + + } // else + + // There are two conditions where we can already determine wether + // or not this filter succeeds. + if ($test==='anyof' && $success) { + return true; + } + if ($test==='allof' && !$success) { + return false; + } + + } // foreach + + // If we got all the way here, it means we haven't been able to + // determine early if the test failed or not. + // + // This implies for 'anyof' that the test failed, and for 'allof' that + // we succeeded. Sounds weird, but makes sense. + return $test==='allof'; + + } + + /** + * Validates if a param-filter can be applied to a specific property. + * + * @todo currently we're only validating the first parameter of the passed + * property. Any subsequence parameters with the same name are + * ignored. + * @param Sabre_VObject_Property $vProperty + * @param array $filters + * @param string $test + * @return bool + */ + protected function validateParamFilters(array $vProperties, array $filters, $test) { + + $success = false; + foreach($filters as $filter) { + + $isDefined = false; + foreach($vProperties as $vProperty) { + $isDefined = isset($vProperty[$filter['name']]); + if ($isDefined) break; + } + + if ($filter['is-not-defined']) { + if ($isDefined) { + $success = false; + } else { + $success = true; + } + + // If there's no text-match, we can just check for existence + } elseif (!$filter['text-match'] || !$isDefined) { + + $success = $isDefined; + + } else { + + $texts = array(); + $success = false; + foreach($vProperties as $vProperty) { + // If we got all the way here, we'll need to validate the + // text-match filter. + $success = Sabre_DAV_StringUtil::textMatch($vProperty[$filter['name']]->value, $filter['text-match']['value'], $filter['text-match']['collation'], $filter['text-match']['match-type']); + if ($success) break; + } + if ($filter['text-match']['negate-condition']) { + $success = !$success; + } + + } // else + + // There are two conditions where we can already determine wether + // or not this filter succeeds. + if ($test==='anyof' && $success) { + return true; + } + if ($test==='allof' && !$success) { + return false; + } + + } + + // If we got all the way here, it means we haven't been able to + // determine early if the test failed or not. + // + // This implies for 'anyof' that the test failed, and for 'allof' that + // we succeeded. Sounds weird, but makes sense. + return $test==='allof'; + + } + + /** + * Validates if a text-filter can be applied to a specific property. + * + * @param array $texts + * @param array $filters + * @param string $test + * @return bool + */ + protected function validateTextMatches(array $texts, array $filters, $test) { + + foreach($filters as $filter) { + + $success = false; + foreach($texts as $haystack) { + $success = Sabre_DAV_StringUtil::textMatch($haystack, $filter['value'], $filter['collation'], $filter['match-type']); + + // Breaking on the first match + if ($success) break; + } + if ($filter['negate-condition']) { + $success = !$success; + } + + if ($success && $test==='anyof') + return true; + + if (!$success && $test=='allof') + return false; + + + } + + // If we got all the way here, it means we haven't been able to + // determine early if the test failed or not. + // + // This implies for 'anyof' that the test failed, and for 'allof' that + // we succeeded. Sounds weird, but makes sense. + return $test==='allof'; + + } + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/Property/SupportedAddressData.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/Property/SupportedAddressData.php new file mode 100755 index 0000000..7853233 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/Property/SupportedAddressData.php @@ -0,0 +1,69 @@ + 'text/vcard', 'version' => '3.0'), + array('contentType' => 'text/vcard', 'version' => '4.0'), + ); + } + + $this->supportedData = $supportedData; + + } + + /** + * Serializes the property in a DOMDocument + * + * @param Sabre_DAV_Server $server + * @param DOMElement $node + * @return void + */ + public function serialize(Sabre_DAV_Server $server,DOMElement $node) { + + $doc = $node->ownerDocument; + + $prefix = + isset($server->xmlNamespaces[Sabre_CardDAV_Plugin::NS_CARDDAV]) ? + $server->xmlNamespaces[Sabre_CardDAV_Plugin::NS_CARDDAV] : + 'card'; + + foreach($this->supportedData as $supported) { + + $caldata = $doc->createElementNS(Sabre_CardDAV_Plugin::NS_CARDDAV, $prefix . ':address-data-type'); + $caldata->setAttribute('content-type',$supported['contentType']); + $caldata->setAttribute('version',$supported['version']); + $node->appendChild($caldata); + + } + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/UserAddressBooks.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/UserAddressBooks.php new file mode 100755 index 0000000..5bdf58b --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/UserAddressBooks.php @@ -0,0 +1,240 @@ +carddavBackend = $carddavBackend; + $this->principalUri = $principalUri; + + } + + /** + * Returns the name of this object + * + * @return string + */ + public function getName() { + + list(,$name) = Sabre_DAV_URLUtil::splitPath($this->principalUri); + return $name; + + } + + /** + * Updates the name of this object + * + * @param string $name + * @return void + */ + public function setName($name) { + + throw new Sabre_DAV_Exception_MethodNotAllowed(); + + } + + /** + * Deletes this object + * + * @return void + */ + public function delete() { + + throw new Sabre_DAV_Exception_MethodNotAllowed(); + + } + + /** + * Returns the last modification date + * + * @return int + */ + public function getLastModified() { + + return null; + + } + + /** + * Creates a new file under this object. + * + * This is currently not allowed + * + * @param string $filename + * @param resource $data + * @return void + */ + public function createFile($filename, $data=null) { + + throw new Sabre_DAV_Exception_MethodNotAllowed('Creating new files in this collection is not supported'); + + } + + /** + * Creates a new directory under this object. + * + * This is currently not allowed. + * + * @param string $filename + * @return void + */ + public function createDirectory($filename) { + + throw new Sabre_DAV_Exception_MethodNotAllowed('Creating new collections in this collection is not supported'); + + } + + /** + * Returns a single calendar, by name + * + * @param string $name + * @todo needs optimizing + * @return Sabre_CardDAV_AddressBook + */ + public function getChild($name) { + + foreach($this->getChildren() as $child) { + if ($name==$child->getName()) + return $child; + + } + throw new Sabre_DAV_Exception_FileNotFound('Addressbook with name \'' . $name . '\' could not be found'); + + } + + /** + * Returns a list of addressbooks + * + * @return array + */ + public function getChildren() { + + $addressbooks = $this->carddavBackend->getAddressbooksForUser($this->principalUri); + $objs = array(); + foreach($addressbooks as $addressbook) { + $objs[] = new Sabre_CardDAV_AddressBook($this->carddavBackend, $addressbook); + } + return $objs; + + } + + /** + * Creates a new addressbook + * + * @param string $name + * @param array $resourceType + * @param array $properties + * @return void + */ + public function createExtendedCollection($name, array $resourceType, array $properties) { + + if (!in_array('{'.Sabre_CardDAV_Plugin::NS_CARDDAV.'}addressbook',$resourceType) || count($resourceType)!==2) { + throw new Sabre_DAV_Exception_InvalidResourceType('Unknown resourceType for this collection'); + } + $this->carddavBackend->createAddressBook($this->principalUri, $name, $properties); + + } + + /** + * Returns the owner principal + * + * This must be a url to a principal, or null if there's no owner + * + * @return string|null + */ + public function getOwner() { + + return $this->principalUri; + + } + + /** + * Returns a group principal + * + * This must be a url to a principal, or null if there's no owner + * + * @return string|null + */ + public function getGroup() { + + return null; + + } + + /** + * Returns a list of ACE's for this node. + * + * Each ACE has the following properties: + * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are + * currently the only supported privileges + * * 'principal', a url to the principal who owns the node + * * 'protected' (optional), indicating that this ACE is not allowed to + * be updated. + * + * @return array + */ + public function getACL() { + + return array( + array( + 'privilege' => '{DAV:}read', + 'principal' => $this->principalUri, + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => $this->principalUri, + 'protected' => true, + ), + + ); + + } + + /** + * Updates the ACL + * + * This method will receive a list of new ACE's. + * + * @param array $acl + * @return void + */ + public function setACL(array $acl) { + + throw new Sabre_DAV_Exception_MethodNotAllowed('Changing ACL is not yet supported'); + + } + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/Version.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/Version.php new file mode 100755 index 0000000..7d24fff --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/CardDAV/Version.php @@ -0,0 +1,26 @@ +currentUser; + } + + + /** + * Authenticates the user based on the current request. + * + * If authentication is succesful, true must be returned. + * If authentication fails, an exception must be thrown. + * + * @throws Sabre_DAV_Exception_NotAuthenticated + * @return bool + */ + public function authenticate(Sabre_DAV_Server $server,$realm) { + + $auth = new Sabre_HTTP_BasicAuth(); + $auth->setHTTPRequest($server->httpRequest); + $auth->setHTTPResponse($server->httpResponse); + $auth->setRealm($realm); + $userpass = $auth->getUserPass(); + if (!$userpass) { + $auth->requireLogin(); + throw new Sabre_DAV_Exception_NotAuthenticated('No basic authentication headers were found'); + } + + // Authenticates the user + if (!$this->validateUserPass($userpass[0],$userpass[1])) { + $auth->requireLogin(); + throw new Sabre_DAV_Exception_NotAuthenticated('Username or password does not match'); + } + $this->currentUser = $userpass[0]; + return true; + } + + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/Backend/AbstractDigest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/Backend/AbstractDigest.php new file mode 100755 index 0000000..c5d20fa --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/Backend/AbstractDigest.php @@ -0,0 +1,96 @@ +setHTTPRequest($server->httpRequest); + $digest->setHTTPResponse($server->httpResponse); + + $digest->setRealm($realm); + $digest->init(); + + $username = $digest->getUsername(); + + // No username was given + if (!$username) { + $digest->requireLogin(); + throw new Sabre_DAV_Exception_NotAuthenticated('No digest authentication headers were found'); + } + + $hash = $this->getDigestHash($realm, $username); + // If this was false, the user account didn't exist + if ($hash===false || is_null($hash)) { + $digest->requireLogin(); + throw new Sabre_DAV_Exception_NotAuthenticated('The supplied username was not on file'); + } + if (!is_string($hash)) { + throw new Sabre_DAV_Exception('The returned value from getDigestHash must be a string or null'); + } + + // If this was false, the password or part of the hash was incorrect. + if (!$digest->validateA1($hash)) { + $digest->requireLogin(); + throw new Sabre_DAV_Exception_NotAuthenticated('Incorrect username'); + } + + $this->currentUser = $username; + return true; + + } + + /** + * Returns the currently logged in username. + * + * @return string|null + */ + public function getCurrentUser() { + + return $this->currentUser; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/Backend/Apache.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/Backend/Apache.php new file mode 100755 index 0000000..a008e5d --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/Backend/Apache.php @@ -0,0 +1,60 @@ +httpRequest->getRawServerValue('REMOTE_USER'); + if (is_null($remoteUser)) { + throw new Sabre_DAV_Exception('We did not receive the $_SERVER[REMOTE_USER] property. This means that apache might have been misconfigured'); + } + + $this->remoteUser = $remoteUser; + return true; + + } + + /** + * Returns information about the currently logged in user. + * + * If nobody is currently logged in, this method should return null. + * + * @return array|null + */ + public function getCurrentUser() { + + return $this->remoteUser; + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/Backend/File.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/Backend/File.php new file mode 100755 index 0000000..3eb740c --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/Backend/File.php @@ -0,0 +1,76 @@ +loadFile($filename); + + } + + /** + * Loads an htdigest-formatted file. This method can be called multiple times if + * more than 1 file is used. + * + * @param string $filename + * @return void + */ + public function loadFile($filename) { + + foreach(file($filename,FILE_IGNORE_NEW_LINES) as $line) { + + if (substr_count($line, ":") !== 2) + throw new Sabre_DAV_Exception('Malformed htdigest file. Every line should contain 2 colons'); + + list($username,$realm,$A1) = explode(':',$line); + + if (!preg_match('/^[a-zA-Z0-9]{32}$/', $A1)) + throw new Sabre_DAV_Exception('Malformed htdigest file. Invalid md5 hash'); + + $this->users[$realm . ':' . $username] = $A1; + + } + + } + + /** + * Returns a users' information + * + * @param string $realm + * @param string $username + * @return string + */ + public function getDigestHash($realm, $username) { + + return isset($this->users[$realm . ':' . $username])?$this->users[$realm . ':' . $username]:false; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/Backend/PDO.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/Backend/PDO.php new file mode 100755 index 0000000..7ac6f08 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/Backend/PDO.php @@ -0,0 +1,66 @@ +pdo = $pdo; + $this->tableName = $tableName; + + } + + /** + * Returns the digest hash for a user. + * + * @param string $realm + * @param string $username + * @return string|null + */ + public function getDigestHash($realm,$username) { + + $stmt = $this->pdo->prepare('SELECT username, digesta1 FROM `'.$this->tableName.'` WHERE username = ?'); + $stmt->execute(array($username)); + $result = $stmt->fetchAll(); + + if (!count($result)) return; + + return $result[0]['digesta1']; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/IBackend.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/IBackend.php new file mode 100755 index 0000000..4a83095 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Auth/IBackend.php @@ -0,0 +1,34 @@ +authBackend = $authBackend; + $this->realm = $realm; + + } + + /** + * Initializes the plugin. This function is automatically called by the server + * + * @param Sabre_DAV_Server $server + * @return void + */ + public function initialize(Sabre_DAV_Server $server) { + + $this->server = $server; + $this->server->subscribeEvent('beforeMethod',array($this,'beforeMethod'),10); + + } + + /** + * Returns a plugin name. + * + * Using this name other plugins will be able to access other plugins + * using Sabre_DAV_Server::getPlugin + * + * @return string + */ + public function getPluginName() { + + return 'auth'; + + } + + /** + * Returns the current users' principal uri. + * + * If nobody is logged in, this will return null. + * + * @return string|null + */ + public function getCurrentUser() { + + $userInfo = $this->authBackend->getCurrentUser(); + if (!$userInfo) return null; + + return $userInfo; + + } + + /** + * This method is called before any HTTP method and forces users to be authenticated + * + * @param string $method + * @throws Sabre_DAV_Exception_NotAuthenticated + * @return bool + */ + public function beforeMethod($method, $uri) { + + $this->authBackend->authenticate($this->server,$this->realm); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Browser/GuessContentType.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Browser/GuessContentType.php new file mode 100755 index 0000000..f1fa404 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Browser/GuessContentType.php @@ -0,0 +1,97 @@ + 'image/jpeg', + 'gif' => 'image/gif', + 'png' => 'image/png', + + // groupware + 'ics' => 'text/calendar', + 'vcf' => 'text/x-vcard', + + // text + 'txt' => 'text/plain', + + ); + + /** + * Initializes the plugin + * + * @param Sabre_DAV_Server $server + * @return void + */ + public function initialize(Sabre_DAV_Server $server) { + + // Using a relatively low priority (200) to allow other extensions + // to set the content-type first. + $server->subscribeEvent('afterGetProperties',array($this,'afterGetProperties'),200); + + } + + /** + * Handler for teh afterGetProperties event + * + * @param string $path + * @param array $properties + * @return void + */ + public function afterGetProperties($path, &$properties) { + + if (array_key_exists('{DAV:}getcontenttype', $properties[404])) { + + list(, $fileName) = Sabre_DAV_URLUtil::splitPath($path); + $contentType = $this->getContentType($fileName); + + if ($contentType) { + $properties[200]['{DAV:}getcontenttype'] = $contentType; + unset($properties[404]['{DAV:}getcontenttype']); + } + + } + + } + + /** + * Simple method to return the contenttype + * + * @param string $fileName + * @return string + */ + protected function getContentType($fileName) { + + // Just grabbing the extension + $extension = strtolower(substr($fileName,strrpos($fileName,'.')+1)); + if (isset($this->extensionMap[$extension])) + return $this->extensionMap[$extension]; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Browser/MapGetToPropFind.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Browser/MapGetToPropFind.php new file mode 100755 index 0000000..1e0c3ba --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Browser/MapGetToPropFind.php @@ -0,0 +1,54 @@ +server = $server; + $this->server->subscribeEvent('beforeMethod',array($this,'httpGetInterceptor')); + } + + /** + * This method intercepts GET requests to non-files, and changes it into an HTTP PROPFIND request + * + * @param string $method + * @return bool + */ + public function httpGetInterceptor($method, $uri) { + + if ($method!='GET') return true; + + $node = $this->server->tree->getNodeForPath($uri); + if ($node instanceof Sabre_DAV_IFile) return; + + $this->server->invokeMethod('PROPFIND',$uri); + return false; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Browser/Plugin.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Browser/Plugin.php new file mode 100755 index 0000000..168051f --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Browser/Plugin.php @@ -0,0 +1,283 @@ +enablePost = $enablePost; + + } + + /** + * Initializes the plugin and subscribes to events + * + * @param Sabre_DAV_Server $server + * @return void + */ + public function initialize(Sabre_DAV_Server $server) { + + $this->server = $server; + $this->server->subscribeEvent('beforeMethod',array($this,'httpGetInterceptor')); + if ($this->enablePost) $this->server->subscribeEvent('unknownMethod',array($this,'httpPOSTHandler')); + } + + /** + * This method intercepts GET requests to collections and returns the html + * + * @param string $method + * @return bool + */ + public function httpGetInterceptor($method, $uri) { + + if ($method!='GET') return true; + + try { + $node = $this->server->tree->getNodeForPath($uri); + } catch (Sabre_DAV_Exception_FileNotFound $e) { + // We're simply stopping when the file isn't found to not interfere + // with other plugins. + return; + } + if ($node instanceof Sabre_DAV_IFile) + return; + + $this->server->httpResponse->sendStatus(200); + $this->server->httpResponse->setHeader('Content-Type','text/html; charset=utf-8'); + + $this->server->httpResponse->sendBody( + $this->generateDirectoryIndex($uri) + ); + + return false; + + } + + /** + * Handles POST requests for tree operations + * + * This method is not yet used. + * + * @param string $method + * @return bool + */ + public function httpPOSTHandler($method, $uri) { + + if ($method!='POST') return true; + if (isset($_POST['sabreAction'])) switch($_POST['sabreAction']) { + + case 'mkcol' : + if (isset($_POST['name']) && trim($_POST['name'])) { + // Using basename() because we won't allow slashes + list(, $folderName) = Sabre_DAV_URLUtil::splitPath(trim($_POST['name'])); + $this->server->createDirectory($uri . '/' . $folderName); + } + break; + case 'put' : + if ($_FILES) $file = current($_FILES); + else break; + $newName = trim($file['name']); + list(, $newName) = Sabre_DAV_URLUtil::splitPath(trim($file['name'])); + if (isset($_POST['name']) && trim($_POST['name'])) + $newName = trim($_POST['name']); + + // Making sure we only have a 'basename' component + list(, $newName) = Sabre_DAV_URLUtil::splitPath($newName); + + if (is_uploaded_file($file['tmp_name'])) { + $this->server->createFile($uri . '/' . $newName, fopen($file['tmp_name'],'r')); + } + + } + $this->server->httpResponse->setHeader('Location',$this->server->httpRequest->getUri()); + return false; + + } + + /** + * Escapes a string for html. + * + * @param string $value + * @return void + */ + public function escapeHTML($value) { + + return htmlspecialchars($value,ENT_QUOTES,'UTF-8'); + + } + + /** + * Generates the html directory index for a given url + * + * @param string $path + * @return string + */ + public function generateDirectoryIndex($path) { + + $html = " + + Index for " . $this->escapeHTML($path) . "/ - SabreDAV " . Sabre_DAV_Version::VERSION . " + + + +

Index for " . $this->escapeHTML($path) . "/

+ + + "; + + $files = $this->server->getPropertiesForPath($path,array( + '{DAV:}displayname', + '{DAV:}resourcetype', + '{DAV:}getcontenttype', + '{DAV:}getcontentlength', + '{DAV:}getlastmodified', + ),1); + + $parent = $this->server->tree->getNodeForPath($path); + + + if ($path) { + + list($parentUri) = Sabre_DAV_URLUtil::splitPath($path); + $fullPath = Sabre_DAV_URLUtil::encodePath($this->server->getBaseUri() . $parentUri); + + $html.= " + + + + +"; + + } + + foreach($files as $k=>$file) { + + // This is the current directory, we can skip it + if (rtrim($file['href'],'/')==$path) continue; + + list(, $name) = Sabre_DAV_URLUtil::splitPath($file['href']); + + $type = null; + + + if (isset($file[200]['{DAV:}resourcetype'])) { + $type = $file[200]['{DAV:}resourcetype']->getValue(); + + // resourcetype can have multiple values + if (!is_array($type)) $type = array($type); + + foreach($type as $k=>$v) { + + // Some name mapping is preferred + switch($v) { + case '{DAV:}collection' : + $type[$k] = 'Collection'; + break; + case '{DAV:}principal' : + $type[$k] = 'Principal'; + break; + case '{urn:ietf:params:xml:ns:carddav}addressbook' : + $type[$k] = 'Addressbook'; + break; + case '{urn:ietf:params:xml:ns:caldav}calendar' : + $type[$k] = 'Calendar'; + break; + } + + } + $type = implode(', ', $type); + } + + // If no resourcetype was found, we attempt to use + // the contenttype property + if (!$type && isset($file[200]['{DAV:}getcontenttype'])) { + $type = $file[200]['{DAV:}getcontenttype']; + } + if (!$type) $type = 'Unknown'; + + $size = isset($file[200]['{DAV:}getcontentlength'])?(int)$file[200]['{DAV:}getcontentlength']:''; + $lastmodified = isset($file[200]['{DAV:}getlastmodified'])?$file[200]['{DAV:}getlastmodified']->getTime()->format(DateTime::ATOM):''; + + $fullPath = Sabre_DAV_URLUtil::encodePath('/' . trim($this->server->getBaseUri() . ($path?$path . '/':'') . $name,'/')); + + $displayName = isset($file[200]['{DAV:}displayname'])?$file[200]['{DAV:}displayname']:$name; + + $name = $this->escapeHTML($name); + $displayName = $this->escapeHTML($displayName); + $type = $this->escapeHTML($type); + + $html.= " + + + + +"; + + } + + $html.= ""; + + if ($this->enablePost && $parent instanceof Sabre_DAV_ICollection) { + $html.= ''; + } + + $html.= "
NameTypeSizeLast modified

..[parent]
{$displayName}{$type}{$size}{$lastmodified}

+

Create new folder

+ + Name:
+ +
+
+

Upload file

+ + Name (optional):
+ File:
+ +
+
+
Generated by SabreDAV " . Sabre_DAV_Version::VERSION ."-". Sabre_DAV_Version::STABILITY . " (c)2007-2012 http://code.google.com/p/sabredav/
+ +"; + + return $html; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Client.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Client.php new file mode 100755 index 0000000..f300233 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Client.php @@ -0,0 +1,431 @@ +$validSetting = $settings[$validSetting]; + } + } + + $this->propertyMap['{DAV:}resourcetype'] = 'Sabre_DAV_Property_ResourceType'; + + } + + /** + * Does a PROPFIND request + * + * The list of requested properties must be specified as an array, in clark + * notation. + * + * The returned array will contain a list of filenames as keys, and + * properties as values. + * + * The properties array will contain the list of properties. Only properties + * that are actually returned from the server (without error) will be + * returned, anything else is discarded. + * + * Depth should be either 0 or 1. A depth of 1 will cause a request to be + * made to the server to also return all child resources. + * + * @param string $url + * @param array $properties + * @param int $depth + * @return array + */ + public function propFind($url, array $properties, $depth = 0) { + + $body = '' . "\n"; + $body.= '' . "\n"; + $body.= ' ' . "\n"; + + foreach($properties as $property) { + + list( + $namespace, + $elementName + ) = Sabre_DAV_XMLUtil::parseClarkNotation($property); + + if ($namespace === 'DAV:') { + $body.=' ' . "\n"; + } else { + $body.=" \n"; + } + + } + + $body.= ' ' . "\n"; + $body.= ''; + + $response = $this->request('PROPFIND', $url, $body, array( + 'Depth' => $depth, + 'Content-Type' => 'application/xml' + )); + + $result = $this->parseMultiStatus($response['body']); + + // If depth was 0, we only return the top item + if ($depth===0) { + reset($result); + $result = current($result); + return $result[200]; + } + + $newResult = array(); + foreach($result as $href => $statusList) { + + $newResult[$href] = $statusList[200]; + + } + + return $newResult; + + } + + /** + * Updates a list of properties on the server + * + * The list of properties must have clark-notation properties for the keys, + * and the actual (string) value for the value. If the value is null, an + * attempt is made to delete the property. + * + * @todo Must be building the request using the DOM, and does not yet + * support complex properties. + * @param string $url + * @param array $properties + * @return void + */ + public function propPatch($url, array $properties) { + + $body = '' . "\n"; + $body.= '' . "\n"; + + foreach($properties as $propName => $propValue) { + + list( + $namespace, + $elementName + ) = Sabre_DAV_XMLUtil::parseClarkNotation($propName); + + if ($propValue === null) { + + $body.="\n"; + + if ($namespace === 'DAV:') { + $body.=' ' . "\n"; + } else { + $body.=" \n"; + } + + $body.="\n"; + + } else { + + $body.="\n"; + if ($namespace === 'DAV:') { + $body.=' '; + } else { + $body.=" "; + } + // Shitty.. i know + $body.=htmlspecialchars($propValue, ENT_NOQUOTES, 'UTF-8'); + if ($namespace === 'DAV:') { + $body.='' . "\n"; + } else { + $body.="\n"; + } + $body.="\n"; + + } + + } + + $body.= ''; + + $response = $this->request('PROPPATCH', $url, $body, array( + 'Content-Type' => 'application/xml' + )); + + } + + /** + * Performs an HTTP options request + * + * This method returns all the features from the 'DAV:' header as an array. + * If there was no DAV header, or no contents this method will return an + * empty array. + * + * @return array + */ + public function options() { + + $result = $this->request('OPTIONS'); + if (!isset($result['headers']['dav'])) { + return array(); + } + + $features = explode(',', $result['headers']['dav']); + foreach($features as &$v) { + $v = trim($v); + } + return $features; + + } + + /** + * Performs an actual HTTP request, and returns the result. + * + * If the specified url is relative, it will be expanded based on the base + * url. + * + * The returned array contains 3 keys: + * * body - the response body + * * httpCode - a HTTP code (200, 404, etc) + * * headers - a list of response http headers. The header names have + * been lowercased. + * + * @param string $method + * @param string $url + * @param string $body + * @param array $headers + * @return array + */ + public function request($method, $url = '', $body = null, $headers = array()) { + + $url = $this->getAbsoluteUrl($url); + + $curlSettings = array( + CURLOPT_RETURNTRANSFER => true, + CURLOPT_CUSTOMREQUEST => $method, + CURLOPT_POSTFIELDS => $body, + // Return headers as part of the response + CURLOPT_HEADER => true + ); + + // Adding HTTP headers + $nHeaders = array(); + foreach($headers as $key=>$value) { + + $nHeaders[] = $key . ': ' . $value; + + } + $curlSettings[CURLOPT_HTTPHEADER] = $nHeaders; + + if ($this->proxy) { + $curlSettings[CURLOPT_PROXY] = $this->proxy; + } + + if ($this->userName) { + $curlSettings[CURLOPT_HTTPAUTH] = CURLAUTH_BASIC | CURLAUTH_DIGEST; + $curlSettings[CURLOPT_USERPWD] = $this->userName . ':' . $this->password; + } + + list( + $response, + $curlInfo, + $curlErrNo, + $curlError + ) = $this->curlRequest($url, $curlSettings); + + $headerBlob = substr($response, 0, $curlInfo['header_size']); + $response = substr($response, $curlInfo['header_size']); + + // In the case of 100 Continue, or redirects we'll have multiple lists + // of headers for each separate HTTP response. We can easily split this + // because they are separated by \r\n\r\n + $headerBlob = explode("\r\n\r\n", trim($headerBlob, "\r\n")); + + // We only care about the last set of headers + $headerBlob = $headerBlob[count($headerBlob)-1]; + + // Splitting headers + $headerBlob = explode("\r\n", $headerBlob); + + $headers = array(); + foreach($headerBlob as $header) { + $parts = explode(':', $header, 2); + if (count($parts)==2) { + $headers[strtolower(trim($parts[0]))] = trim($parts[1]); + } + } + + $response = array( + 'body' => $response, + 'statusCode' => $curlInfo['http_code'], + 'headers' => $headers + ); + + if ($curlErrNo) { + throw new Sabre_DAV_Exception('[CURL] Error while making request: ' . $curlError . ' (error code: ' . $curlErrNo . ')'); + } + + if ($response['statusCode']>=400) { + throw new Sabre_DAV_Exception('HTTP error response. (errorcode ' . $response['statusCode'] . ')'); + } + + return $response; + + } + + /** + * Wrapper for all curl functions. + * + * The only reason this was split out in a separate method, is so it + * becomes easier to unittest. + * + * @param string $url + * @param array $settings + * @return + */ + protected function curlRequest($url, $settings) { + + $curl = curl_init($url); + curl_setopt_array($curl, $settings); + + return array( + curl_exec($curl), + curl_getinfo($curl), + curl_errno($curl), + curl_error($curl) + ); + + } + + /** + * Returns the full url based on the given url (which may be relative). All + * urls are expanded based on the base url as given by the server. + * + * @param string $url + * @return string + */ + protected function getAbsoluteUrl($url) { + + // If the url starts with http:// or https://, the url is already absolute. + if (preg_match('/^http(s?):\/\//', $url)) { + return $url; + } + + // If the url starts with a slash, we must calculate the url based off + // the root of the base url. + if (strpos($url,'/') === 0) { + $parts = parse_url($this->baseUri); + return $parts['scheme'] . '://' . $parts['host'] . (isset($parts['port'])?':' . $parts['port']:'') . $url; + } + + // Otherwise... + return $this->baseUri . $url; + + } + + /** + * Parses a WebDAV multistatus response body + * + * This method returns an array with the following structure + * + * array( + * 'url/to/resource' => array( + * '200' => array( + * '{DAV:}property1' => 'value1', + * '{DAV:}property2' => 'value2', + * ), + * '404' => array( + * '{DAV:}property1' => null, + * '{DAV:}property2' => null, + * ), + * ) + * 'url/to/resource2' => array( + * .. etc .. + * ) + * ) + * + * + * @param string $body xml body + * @return array + */ + public function parseMultiStatus($body) { + + $body = Sabre_DAV_XMLUtil::convertDAVNamespace($body); + + $responseXML = simplexml_load_string($body, null, LIBXML_NOBLANKS | LIBXML_NOCDATA); + if ($responseXML===false) { + throw new InvalidArgumentException('The passed data is not valid XML'); + } + + $responseXML->registerXPathNamespace('d','DAV:'); + + $propResult = array(); + + foreach($responseXML->xpath('d:response') as $response) { + + $response->registerXPathNamespace('d','DAV:'); + $href = $response->xpath('d:href'); + $href = (string)$href[0]; + + $properties = array(); + + foreach($response->xpath('d:propstat') as $propStat) { + + $propStat->registerXPathNamespace('d','DAV:'); + $status = $propStat->xpath('d:status'); + list($httpVersion, $statusCode, $message) = explode(' ', (string)$status[0],3); + + $properties[$statusCode] = Sabre_DAV_XMLUtil::parseProperties(dom_import_simplexml($propStat), $this->propertyMap); + + } + + $propResult[$href] = $properties; + + } + + return $propResult; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Collection.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Collection.php new file mode 100755 index 0000000..dc6cacf --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Collection.php @@ -0,0 +1,90 @@ +getChildren() as $child) { + + if ($child->getName()==$name) return $child; + + } + throw new Sabre_DAV_Exception_FileNotFound('File not found: ' . $name); + + } + + /** + * Checks is a child-node exists. + * + * It is generally a good idea to try and override this. Usually it can be optimized. + * + * @param string $name + * @return bool + */ + public function childExists($name) { + + try { + + $this->getChild($name); + return true; + + } catch(Sabre_DAV_Exception_FileNotFound $e) { + + return false; + + } + + } + + /** + * Creates a new file in the directory + * + * @param string $name Name of the file + * @param resource $data Initial payload, passed as a readable stream resource. + * @throws Sabre_DAV_Exception_Forbidden + * @return void + */ + public function createFile($name, $data = null) { + + throw new Sabre_DAV_Exception_Forbidden('Permission denied to create file (filename ' . $name . ')'); + + } + + /** + * Creates a new subdirectory + * + * @param string $name + * @throws Sabre_DAV_Exception_Forbidden + * @return void + */ + public function createDirectory($name) { + + throw new Sabre_DAV_Exception_Forbidden('Permission denied to create directory'); + + } + + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Directory.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Directory.php new file mode 100755 index 0000000..6db8feb --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Directory.php @@ -0,0 +1,17 @@ +lock) { + $error = $errorNode->ownerDocument->createElementNS('DAV:','d:no-conflicting-lock'); + $errorNode->appendChild($error); + if (!is_object($this->lock)) var_dump($this->lock); + $error->appendChild($errorNode->ownerDocument->createElementNS('DAV:','d:href',$this->lock->uri)); + } + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/FileNotFound.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/FileNotFound.php new file mode 100755 index 0000000..26fb95f --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/FileNotFound.php @@ -0,0 +1,28 @@ +ownerDocument->createElementNS('DAV:','d:valid-resourcetype'); + $errorNode->appendChild($error); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/LockTokenMatchesRequestUri.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/LockTokenMatchesRequestUri.php new file mode 100755 index 0000000..1ece1af --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/LockTokenMatchesRequestUri.php @@ -0,0 +1,39 @@ +message = 'The locktoken supplied does not match any locks on this entity'; + + } + + /** + * This method allows the exception to include additonal information into the WebDAV error response + * + * @param Sabre_DAV_Server $server + * @param DOMElement $errorNode + * @return void + */ + public function serialize(Sabre_DAV_Server $server,DOMElement $errorNode) { + + $error = $errorNode->ownerDocument->createElementNS('DAV:','d:lock-token-matches-request-uri'); + $errorNode->appendChild($error); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/Locked.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/Locked.php new file mode 100755 index 0000000..99a5d81 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/Locked.php @@ -0,0 +1,67 @@ +lock = $lock; + + } + + /** + * Returns the HTTP statuscode for this exception + * + * @return int + */ + public function getHTTPCode() { + + return 423; + + } + + /** + * This method allows the exception to include additonal information into the WebDAV error response + * + * @param Sabre_DAV_Server $server + * @param DOMElement $errorNode + * @return void + */ + public function serialize(Sabre_DAV_Server $server,DOMElement $errorNode) { + + if ($this->lock) { + $error = $errorNode->ownerDocument->createElementNS('DAV:','d:lock-token-submitted'); + $errorNode->appendChild($error); + if (!is_object($this->lock)) var_dump($this->lock); + $error->appendChild($errorNode->ownerDocument->createElementNS('DAV:','d:href',$this->lock->uri)); + } + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/MethodNotAllowed.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/MethodNotAllowed.php new file mode 100755 index 0000000..71c8899 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/MethodNotAllowed.php @@ -0,0 +1,44 @@ +getAllowedMethods($server->getRequestUri()); + + return array( + 'Allow' => strtoupper(implode(', ',$methods)), + ); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/NotAuthenticated.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/NotAuthenticated.php new file mode 100755 index 0000000..b426855 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/NotAuthenticated.php @@ -0,0 +1,28 @@ +header = $header; + + } + + /** + * Returns the HTTP statuscode for this exception + * + * @return int + */ + public function getHTTPCode() { + + return 412; + + } + + /** + * This method allows the exception to include additonal information into the WebDAV error response + * + * @param Sabre_DAV_Server $server + * @param DOMElement $errorNode + * @return void + */ + public function serialize(Sabre_DAV_Server $server,DOMElement $errorNode) { + + if ($this->header) { + $prop = $errorNode->ownerDocument->createElement('s:header'); + $prop->nodeValue = $this->header; + $errorNode->appendChild($prop); + } + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/ReportNotImplemented.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/ReportNotImplemented.php new file mode 100755 index 0000000..023cbb6 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/ReportNotImplemented.php @@ -0,0 +1,30 @@ +ownerDocument->createElementNS('DAV:','d:supported-report'); + $errorNode->appendChild($error); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/RequestedRangeNotSatisfiable.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/RequestedRangeNotSatisfiable.php new file mode 100755 index 0000000..3f84ef9 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Exception/RequestedRangeNotSatisfiable.php @@ -0,0 +1,29 @@ +path . '/' . $name; + file_put_contents($newPath,$data); + + } + + /** + * Creates a new subdirectory + * + * @param string $name + * @return void + */ + public function createDirectory($name) { + + $newPath = $this->path . '/' . $name; + mkdir($newPath); + + } + + /** + * Returns a specific child node, referenced by its name + * + * @param string $name + * @throws Sabre_DAV_Exception_FileNotFound + * @return Sabre_DAV_INode + */ + public function getChild($name) { + + $path = $this->path . '/' . $name; + + if (!file_exists($path)) throw new Sabre_DAV_Exception_FileNotFound('File with name ' . $path . ' could not be located'); + + if (is_dir($path)) { + + return new Sabre_DAV_FS_Directory($path); + + } else { + + return new Sabre_DAV_FS_File($path); + + } + + } + + /** + * Returns an array with all the child nodes + * + * @return Sabre_DAV_INode[] + */ + public function getChildren() { + + $nodes = array(); + foreach(scandir($this->path) as $node) if($node!='.' && $node!='..') $nodes[] = $this->getChild($node); + return $nodes; + + } + + /** + * Checks if a child exists. + * + * @param string $name + * @return bool + */ + public function childExists($name) { + + $path = $this->path . '/' . $name; + return file_exists($path); + + } + + /** + * Deletes all files in this directory, and then itself + * + * @return void + */ + public function delete() { + + foreach($this->getChildren() as $child) $child->delete(); + rmdir($this->path); + + } + + /** + * Returns available diskspace information + * + * @return array + */ + public function getQuotaInfo() { + + return array( + disk_total_space($this->path)-disk_free_space($this->path), + disk_free_space($this->path) + ); + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FS/File.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FS/File.php new file mode 100755 index 0000000..e5c9983 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FS/File.php @@ -0,0 +1,89 @@ +path,$data); + + } + + /** + * Returns the data + * + * @return string + */ + public function get() { + + return fopen($this->path,'r'); + + } + + /** + * Delete the current file + * + * @return void + */ + public function delete() { + + unlink($this->path); + + } + + /** + * Returns the size of the node, in bytes + * + * @return int + */ + public function getSize() { + + return filesize($this->path); + + } + + /** + * Returns the ETag for a file + * + * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. + * The ETag is an arbritrary string, but MUST be surrounded by double-quotes. + * + * Return null if the ETag can not effectively be determined + * + * @return mixed + */ + public function getETag() { + + return null; + + } + + /** + * Returns the mime-type for a file + * + * If null is returned, we'll assume application/octet-stream + * + * @return mixed + */ + public function getContentType() { + + return null; + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FS/Node.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FS/Node.php new file mode 100755 index 0000000..3232773 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FS/Node.php @@ -0,0 +1,81 @@ +path = $path; + + } + + + + /** + * Returns the name of the node + * + * @return string + */ + public function getName() { + + list(, $name) = Sabre_DAV_URLUtil::splitPath($this->path); + return $name; + + } + + /** + * Renames the node + * + * @param string $name The new name + * @return void + */ + public function setName($name) { + + list($parentPath, ) = Sabre_DAV_URLUtil::splitPath($this->path); + list(, $newName) = Sabre_DAV_URLUtil::splitPath($name); + + $newPath = $parentPath . '/' . $newName; + rename($this->path,$newPath); + + $this->path = $newPath; + + } + + + + /** + * Returns the last modification time, as a unix timestamp + * + * @return int + */ + public function getLastModified() { + + return filemtime($this->path); + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FSExt/Directory.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FSExt/Directory.php new file mode 100755 index 0000000..87ead24 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FSExt/Directory.php @@ -0,0 +1,135 @@ +path . '/' . $name; + file_put_contents($newPath,$data); + + } + + /** + * Creates a new subdirectory + * + * @param string $name + * @return void + */ + public function createDirectory($name) { + + // We're not allowing dots + if ($name=='.' || $name=='..') throw new Sabre_DAV_Exception_Forbidden('Permission denied to . and ..'); + $newPath = $this->path . '/' . $name; + mkdir($newPath); + + } + + /** + * Returns a specific child node, referenced by its name + * + * @param string $name + * @throws Sabre_DAV_Exception_FileNotFound + * @return Sabre_DAV_INode + */ + public function getChild($name) { + + $path = $this->path . '/' . $name; + + if (!file_exists($path)) throw new Sabre_DAV_Exception_FileNotFound('File could not be located'); + if ($name=='.' || $name=='..') throw new Sabre_DAV_Exception_Forbidden('Permission denied to . and ..'); + + if (is_dir($path)) { + + return new Sabre_DAV_FSExt_Directory($path); + + } else { + + return new Sabre_DAV_FSExt_File($path); + + } + + } + + /** + * Checks if a child exists. + * + * @param string $name + * @return bool + */ + public function childExists($name) { + + if ($name=='.' || $name=='..') + throw new Sabre_DAV_Exception_Forbidden('Permission denied to . and ..'); + + $path = $this->path . '/' . $name; + return file_exists($path); + + } + + /** + * Returns an array with all the child nodes + * + * @return Sabre_DAV_INode[] + */ + public function getChildren() { + + $nodes = array(); + foreach(scandir($this->path) as $node) if($node!='.' && $node!='..' && $node!='.sabredav') $nodes[] = $this->getChild($node); + return $nodes; + + } + + /** + * Deletes all files in this directory, and then itself + * + * @return void + */ + public function delete() { + + // Deleting all children + foreach($this->getChildren() as $child) $child->delete(); + + // Removing resource info, if its still around + if (file_exists($this->path . '/.sabredav')) unlink($this->path . '/.sabredav'); + + // Removing the directory itself + rmdir($this->path); + + return parent::delete(); + + } + + /** + * Returns available diskspace information + * + * @return array + */ + public function getQuotaInfo() { + + return array( + disk_total_space($this->path)-disk_free_space($this->path), + disk_free_space($this->path) + ); + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FSExt/File.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FSExt/File.php new file mode 100755 index 0000000..a000890 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FSExt/File.php @@ -0,0 +1,88 @@ +path,$data); + + } + + /** + * Returns the data + * + * @return string + */ + public function get() { + + return fopen($this->path,'r'); + + } + + /** + * Delete the current file + * + * @return void + */ + public function delete() { + + unlink($this->path); + return parent::delete(); + + } + + /** + * Returns the ETag for a file + * + * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. + * The ETag is an arbritrary string, but MUST be surrounded by double-quotes. + * + * Return null if the ETag can not effectively be determined + */ + public function getETag() { + + return '"' . md5_file($this->path). '"'; + + } + + /** + * Returns the mime-type for a file + * + * If null is returned, we'll assume application/octet-stream + */ + public function getContentType() { + + return null; + + } + + /** + * Returns the size of the file, in bytes + * + * @return int + */ + public function getSize() { + + return filesize($this->path); + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FSExt/Node.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FSExt/Node.php new file mode 100755 index 0000000..5d28faf --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/FSExt/Node.php @@ -0,0 +1,276 @@ +getResourceData(); + $locks = $resourceData['locks']; + foreach($locks as $k=>$lock) { + if (time() > $lock->timeout + $lock->created) unset($locks[$k]); + } + return $locks; + + } + + /** + * Locks this node + * + * @param Sabre_DAV_Locks_LockInfo $lockInfo + * @return void + */ + function lock(Sabre_DAV_Locks_LockInfo $lockInfo) { + + // We're making the lock timeout 30 minutes + $lockInfo->timeout = 1800; + $lockInfo->created = time(); + + $resourceData = $this->getResourceData(); + if (!isset($resourceData['locks'])) $resourceData['locks'] = array(); + $current = null; + foreach($resourceData['locks'] as $k=>$lock) { + if ($lock->token === $lockInfo->token) $current = $k; + } + if (!is_null($current)) $resourceData['locks'][$current] = $lockInfo; + else $resourceData['locks'][] = $lockInfo; + + $this->putResourceData($resourceData); + + } + + /** + * Removes a lock from this node + * + * @param Sabre_DAV_Locks_LockInfo $lockInfo + * @return bool + */ + function unlock(Sabre_DAV_Locks_LockInfo $lockInfo) { + + //throw new Sabre_DAV_Exception('bla'); + $resourceData = $this->getResourceData(); + foreach($resourceData['locks'] as $k=>$lock) { + + if ($lock->token === $lockInfo->token) { + + unset($resourceData['locks'][$k]); + $this->putResourceData($resourceData); + return true; + + } + } + return false; + + } + + /** + * Updates properties on this node, + * + * @param array $mutations + * @see Sabre_DAV_IProperties::updateProperties + * @return bool|array + */ + public function updateProperties($properties) { + + $resourceData = $this->getResourceData(); + + $result = array(); + + foreach($properties as $propertyName=>$propertyValue) { + + // If it was null, we need to delete the property + if (is_null($propertyValue)) { + if (isset($resourceData['properties'][$propertyName])) { + unset($resourceData['properties'][$propertyName]); + } + } else { + $resourceData['properties'][$propertyName] = $propertyValue; + } + + } + + $this->putResourceData($resourceData); + return true; + } + + /** + * Returns a list of properties for this nodes.; + * + * The properties list is a list of propertynames the client requested, encoded as xmlnamespace#tagName, for example: http://www.example.org/namespace#author + * If the array is empty, all properties should be returned + * + * @param array $properties + * @return void + */ + function getProperties($properties) { + + $resourceData = $this->getResourceData(); + + // if the array was empty, we need to return everything + if (!$properties) return $resourceData['properties']; + + $props = array(); + foreach($properties as $property) { + if (isset($resourceData['properties'][$property])) $props[$property] = $resourceData['properties'][$property]; + } + + return $props; + + } + + /** + * Returns the path to the resource file + * + * @return string + */ + protected function getResourceInfoPath() { + + list($parentDir) = Sabre_DAV_URLUtil::splitPath($this->path); + return $parentDir . '/.sabredav'; + + } + + /** + * Returns all the stored resource information + * + * @return array + */ + protected function getResourceData() { + + $path = $this->getResourceInfoPath(); + if (!file_exists($path)) return array('locks'=>array(), 'properties' => array()); + + // opening up the file, and creating a shared lock + $handle = fopen($path,'r'); + flock($handle,LOCK_SH); + $data = ''; + + // Reading data until the eof + while(!feof($handle)) { + $data.=fread($handle,8192); + } + + // We're all good + fclose($handle); + + // Unserializing and checking if the resource file contains data for this file + $data = unserialize($data); + if (!isset($data[$this->getName()])) { + return array('locks'=>array(), 'properties' => array()); + } + + $data = $data[$this->getName()]; + if (!isset($data['locks'])) $data['locks'] = array(); + if (!isset($data['properties'])) $data['properties'] = array(); + return $data; + + } + + /** + * Updates the resource information + * + * @param array $newData + * @return void + */ + protected function putResourceData(array $newData) { + + $path = $this->getResourceInfoPath(); + + // opening up the file, and creating a shared lock + $handle = fopen($path,'a+'); + flock($handle,LOCK_EX); + $data = ''; + + rewind($handle); + + // Reading data until the eof + while(!feof($handle)) { + $data.=fread($handle,8192); + } + + // Unserializing and checking if the resource file contains data for this file + $data = unserialize($data); + $data[$this->getName()] = $newData; + ftruncate($handle,0); + rewind($handle); + + fwrite($handle,serialize($data)); + fclose($handle); + + } + + /** + * Renames the node + * + * @param string $name The new name + * @return void + */ + public function setName($name) { + + list($parentPath, ) = Sabre_DAV_URLUtil::splitPath($this->path); + list(, $newName) = Sabre_DAV_URLUtil::splitPath($name); + $newPath = $parentPath . '/' . $newName; + + // We're deleting the existing resourcedata, and recreating it + // for the new path. + $resourceData = $this->getResourceData(); + $this->deleteResourceData(); + + rename($this->path,$newPath); + $this->path = $newPath; + $this->putResourceData($resourceData); + + + } + + public function deleteResourceData() { + + // When we're deleting this node, we also need to delete any resource information + $path = $this->getResourceInfoPath(); + if (!file_exists($path)) return true; + + // opening up the file, and creating a shared lock + $handle = fopen($path,'a+'); + flock($handle,LOCK_EX); + $data = ''; + + rewind($handle); + + // Reading data until the eof + while(!feof($handle)) { + $data.=fread($handle,8192); + } + + // Unserializing and checking if the resource file contains data for this file + $data = unserialize($data); + if (isset($data[$this->getName()])) unset($data[$this->getName()]); + ftruncate($handle,0); + rewind($handle); + fwrite($handle,serialize($data)); + fclose($handle); + + } + + public function delete() { + + return $this->deleteResourceData(); + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/File.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/File.php new file mode 100755 index 0000000..70693ee --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/File.php @@ -0,0 +1,81 @@ + array( + * '{DAV:}displayname' => null, + * ), + * 424 => array( + * '{DAV:}owner' => null, + * ) + * ) + * + * In this example it was forbidden to update {DAV:}displayname. + * (403 Forbidden), which in turn also caused {DAV:}owner to fail + * (424 Failed Dependency) because the request needs to be atomic. + * + * @param array $mutations + * @return bool|array + */ + function updateProperties($mutations); + + /** + * Returns a list of properties for this nodes. + * + * The properties list is a list of propertynames the client requested, + * encoded in clark-notation {xmlnamespace}tagname + * + * If the array is empty, it means 'all properties' were requested. + * + * @param array $properties + * @return void + */ + function getProperties($properties); + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/IQuota.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/IQuota.php new file mode 100755 index 0000000..b7659dc --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/IQuota.php @@ -0,0 +1,27 @@ +dataDir = $dataDir; + + } + + protected function getFileNameForUri($uri) { + + return $this->dataDir . '/sabredav_' . md5($uri) . '.locks'; + + } + + + /** + * Returns a list of Sabre_DAV_Locks_LockInfo objects + * + * This method should return all the locks for a particular uri, including + * locks that might be set on a parent uri. + * + * If returnChildLocks is set to true, this method should also look for + * any locks in the subtree of the uri for locks. + * + * @param string $uri + * @param bool $returnChildLocks + * @return array + */ + public function getLocks($uri, $returnChildLocks) { + + $lockList = array(); + $currentPath = ''; + + foreach(explode('/',$uri) as $uriPart) { + + // weird algorithm that can probably be improved, but we're traversing the path top down + if ($currentPath) $currentPath.='/'; + $currentPath.=$uriPart; + + $uriLocks = $this->getData($currentPath); + + foreach($uriLocks as $uriLock) { + + // Unless we're on the leaf of the uri-tree we should ingore locks with depth 0 + if($uri==$currentPath || $uriLock->depth!=0) { + $uriLock->uri = $currentPath; + $lockList[] = $uriLock; + } + + } + + } + + // Checking if we can remove any of these locks + foreach($lockList as $k=>$lock) { + if (time() > $lock->timeout + $lock->created) unset($lockList[$k]); + } + return $lockList; + + } + + /** + * Locks a uri + * + * @param string $uri + * @param Sabre_DAV_Locks_LockInfo $lockInfo + * @return bool + */ + public function lock($uri,Sabre_DAV_Locks_LockInfo $lockInfo) { + + // We're making the lock timeout 30 minutes + $lockInfo->timeout = 1800; + $lockInfo->created = time(); + + $locks = $this->getLocks($uri,false); + foreach($locks as $k=>$lock) { + if ($lock->token == $lockInfo->token) unset($locks[$k]); + } + $locks[] = $lockInfo; + $this->putData($uri,$locks); + return true; + + } + + /** + * Removes a lock from a uri + * + * @param string $uri + * @param Sabre_DAV_Locks_LockInfo $lockInfo + * @return bool + */ + public function unlock($uri,Sabre_DAV_Locks_LockInfo $lockInfo) { + + $locks = $this->getLocks($uri,false); + foreach($locks as $k=>$lock) { + + if ($lock->token == $lockInfo->token) { + + unset($locks[$k]); + $this->putData($uri,$locks); + return true; + + } + } + return false; + + } + + /** + * Returns the stored data for a uri + * + * @param string $uri + * @return array + */ + protected function getData($uri) { + + $path = $this->getFilenameForUri($uri); + if (!file_exists($path)) return array(); + + // opening up the file, and creating a shared lock + $handle = fopen($path,'r'); + flock($handle,LOCK_SH); + $data = ''; + + // Reading data until the eof + while(!feof($handle)) { + $data.=fread($handle,8192); + } + + // We're all good + fclose($handle); + + // Unserializing and checking if the resource file contains data for this file + $data = unserialize($data); + if (!$data) return array(); + return $data; + + } + + /** + * Updates the lock information + * + * @param string $uri + * @param array $newData + * @return void + */ + protected function putData($uri,array $newData) { + + $path = $this->getFileNameForUri($uri); + + // opening up the file, and creating a shared lock + $handle = fopen($path,'a+'); + flock($handle,LOCK_EX); + ftruncate($handle,0); + rewind($handle); + + fwrite($handle,serialize($newData)); + fclose($handle); + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Locks/Backend/File.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Locks/Backend/File.php new file mode 100755 index 0000000..2be4602 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Locks/Backend/File.php @@ -0,0 +1,182 @@ +locksFile = $locksFile; + + } + + /** + * Returns a list of Sabre_DAV_Locks_LockInfo objects + * + * This method should return all the locks for a particular uri, including + * locks that might be set on a parent uri. + * + * If returnChildLocks is set to true, this method should also look for + * any locks in the subtree of the uri for locks. + * + * @param string $uri + * @param bool $returnChildLocks + * @return array + */ + public function getLocks($uri, $returnChildLocks) { + + $newLocks = array(); + $currentPath = ''; + + $locks = $this->getData(); + + foreach($locks as $lock) { + + if ($lock->uri === $uri || + //deep locks on parents + ($lock->depth!=0 && strpos($uri, $lock->uri . '/')===0) || + + // locks on children + ($returnChildLocks && (strpos($lock->uri, $uri . '/')===0)) ) { + + $newLocks[] = $lock; + + } + + } + + // Checking if we can remove any of these locks + foreach($newLocks as $k=>$lock) { + if (time() > $lock->timeout + $lock->created) unset($newLocks[$k]); + } + return $newLocks; + + } + + /** + * Locks a uri + * + * @param string $uri + * @param Sabre_DAV_Locks_LockInfo $lockInfo + * @return bool + */ + public function lock($uri,Sabre_DAV_Locks_LockInfo $lockInfo) { + + // We're making the lock timeout 30 minutes + $lockInfo->timeout = 1800; + $lockInfo->created = time(); + $lockInfo->uri = $uri; + + $locks = $this->getData(); + + foreach($locks as $k=>$lock) { + if ( + ($lock->token == $lockInfo->token) || + (time() > $lock->timeout + $lock->created) + ) { + unset($locks[$k]); + } + } + $locks[] = $lockInfo; + $this->putData($locks); + return true; + + } + + /** + * Removes a lock from a uri + * + * @param string $uri + * @param Sabre_DAV_Locks_LockInfo $lockInfo + * @return bool + */ + public function unlock($uri,Sabre_DAV_Locks_LockInfo $lockInfo) { + + $locks = $this->getData(); + foreach($locks as $k=>$lock) { + + if ($lock->token == $lockInfo->token) { + + unset($locks[$k]); + $this->putData($locks); + return true; + + } + } + return false; + + } + + /** + * Loads the lockdata from the filesystem. + * + * @return array + */ + protected function getData() { + + if (!file_exists($this->locksFile)) return array(); + + // opening up the file, and creating a shared lock + $handle = fopen($this->locksFile,'r'); + flock($handle,LOCK_SH); + + // Reading data until the eof + $data = stream_get_contents($handle); + + // We're all good + fclose($handle); + + // Unserializing and checking if the resource file contains data for this file + $data = unserialize($data); + if (!$data) return array(); + return $data; + + } + + /** + * Saves the lockdata + * + * @param array $newData + * @return void + */ + protected function putData(array $newData) { + + // opening up the file, and creating an exclusive lock + $handle = fopen($this->locksFile,'a+'); + flock($handle,LOCK_EX); + + // We can only truncate and rewind once the lock is acquired. + ftruncate($handle,0); + rewind($handle); + + fwrite($handle,serialize($newData)); + fclose($handle); + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Locks/Backend/PDO.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Locks/Backend/PDO.php new file mode 100755 index 0000000..8a1c305 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Locks/Backend/PDO.php @@ -0,0 +1,165 @@ +pdo = $pdo; + $this->tableName = $tableName; + + } + + /** + * Returns a list of Sabre_DAV_Locks_LockInfo objects + * + * This method should return all the locks for a particular uri, including + * locks that might be set on a parent uri. + * + * If returnChildLocks is set to true, this method should also look for + * any locks in the subtree of the uri for locks. + * + * @param string $uri + * @param bool $returnChildLocks + * @return array + */ + public function getLocks($uri, $returnChildLocks) { + + // NOTE: the following 10 lines or so could be easily replaced by + // pure sql. MySQL's non-standard string concatination prevents us + // from doing this though. + $query = 'SELECT owner, token, timeout, created, scope, depth, uri FROM `'.$this->tableName.'` WHERE ((created + timeout) > CAST(? AS UNSIGNED INTEGER)) AND ((uri = ?)'; + $params = array(time(),$uri); + + // We need to check locks for every part in the uri. + $uriParts = explode('/',$uri); + + // We already covered the last part of the uri + array_pop($uriParts); + + $currentPath=''; + + foreach($uriParts as $part) { + + if ($currentPath) $currentPath.='/'; + $currentPath.=$part; + + $query.=' OR (depth!=0 AND uri = ?)'; + $params[] = $currentPath; + + } + + if ($returnChildLocks) { + + $query.=' OR (uri LIKE ?)'; + $params[] = $uri . '/%'; + + } + $query.=')'; + + $stmt = $this->pdo->prepare($query); + $stmt->execute($params); + $result = $stmt->fetchAll(); + + $lockList = array(); + foreach($result as $row) { + + $lockInfo = new Sabre_DAV_Locks_LockInfo(); + $lockInfo->owner = $row['owner']; + $lockInfo->token = $row['token']; + $lockInfo->timeout = $row['timeout']; + $lockInfo->created = $row['created']; + $lockInfo->scope = $row['scope']; + $lockInfo->depth = $row['depth']; + $lockInfo->uri = $row['uri']; + $lockList[] = $lockInfo; + + } + + return $lockList; + + } + + /** + * Locks a uri + * + * @param string $uri + * @param Sabre_DAV_Locks_LockInfo $lockInfo + * @return bool + */ + public function lock($uri,Sabre_DAV_Locks_LockInfo $lockInfo) { + + // We're making the lock timeout 30 minutes + $lockInfo->timeout = 30*60; + $lockInfo->created = time(); + $lockInfo->uri = $uri; + + $locks = $this->getLocks($uri,false); + $exists = false; + foreach($locks as $k=>$lock) { + if ($lock->token == $lockInfo->token) $exists = true; + } + + if ($exists) { + $stmt = $this->pdo->prepare('UPDATE `'.$this->tableName.'` SET owner = ?, timeout = ?, scope = ?, depth = ?, uri = ?, created = ? WHERE token = ?'); + $stmt->execute(array($lockInfo->owner,$lockInfo->timeout,$lockInfo->scope,$lockInfo->depth,$uri,$lockInfo->created,$lockInfo->token)); + } else { + $stmt = $this->pdo->prepare('INSERT INTO `'.$this->tableName.'` (owner,timeout,scope,depth,uri,created,token) VALUES (?,?,?,?,?,?,?)'); + $stmt->execute(array($lockInfo->owner,$lockInfo->timeout,$lockInfo->scope,$lockInfo->depth,$uri,$lockInfo->created,$lockInfo->token)); + } + + return true; + + } + + + + /** + * Removes a lock from a uri + * + * @param string $uri + * @param Sabre_DAV_Locks_LockInfo $lockInfo + * @return bool + */ + public function unlock($uri,Sabre_DAV_Locks_LockInfo $lockInfo) { + + $stmt = $this->pdo->prepare('DELETE FROM `'.$this->tableName.'` WHERE uri = ? AND token = ?'); + $stmt->execute(array($uri,$lockInfo->token)); + + return $stmt->rowCount()===1; + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Locks/LockInfo.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Locks/LockInfo.php new file mode 100755 index 0000000..02f774a --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Locks/LockInfo.php @@ -0,0 +1,81 @@ +addPlugin($lockPlugin); + * + * @package Sabre + * @subpackage DAV + * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ +class Sabre_DAV_Locks_Plugin extends Sabre_DAV_ServerPlugin { + + /** + * locksBackend + * + * @var Sabre_DAV_Locks_Backend_Abstract + */ + private $locksBackend; + + /** + * server + * + * @var Sabre_DAV_Server + */ + private $server; + + /** + * __construct + * + * @param Sabre_DAV_Locks_Backend_Abstract $locksBackend + * @return void + */ + public function __construct(Sabre_DAV_Locks_Backend_Abstract $locksBackend = null) { + + $this->locksBackend = $locksBackend; + + } + + /** + * Initializes the plugin + * + * This method is automatically called by the Server class after addPlugin. + * + * @param Sabre_DAV_Server $server + * @return void + */ + public function initialize(Sabre_DAV_Server $server) { + + $this->server = $server; + $server->subscribeEvent('unknownMethod',array($this,'unknownMethod')); + $server->subscribeEvent('beforeMethod',array($this,'beforeMethod'),50); + $server->subscribeEvent('afterGetProperties',array($this,'afterGetProperties')); + + } + + /** + * Returns a plugin name. + * + * Using this name other plugins will be able to access other plugins + * using Sabre_DAV_Server::getPlugin + * + * @return string + */ + public function getPluginName() { + + return 'locks'; + + } + + /** + * This method is called by the Server if the user used an HTTP method + * the server didn't recognize. + * + * This plugin intercepts the LOCK and UNLOCK methods. + * + * @param string $method + * @return bool + */ + public function unknownMethod($method, $uri) { + + switch($method) { + + case 'LOCK' : $this->httpLock($uri); return false; + case 'UNLOCK' : $this->httpUnlock($uri); return false; + + } + + } + + /** + * This method is called after most properties have been found + * it allows us to add in any Lock-related properties + * + * @param string $path + * @param array $properties + * @return bool + */ + public function afterGetProperties($path,&$newProperties) { + + foreach($newProperties[404] as $propName=>$discard) { + + $node = null; + + switch($propName) { + + case '{DAV:}supportedlock' : + $val = false; + if ($this->locksBackend) $val = true; + else { + if (!$node) $node = $this->server->tree->getNodeForPath($path); + if ($node instanceof Sabre_DAV_ILockable) $val = true; + } + $newProperties[200][$propName] = new Sabre_DAV_Property_SupportedLock($val); + unset($newProperties[404][$propName]); + break; + + case '{DAV:}lockdiscovery' : + $newProperties[200][$propName] = new Sabre_DAV_Property_LockDiscovery($this->getLocks($path)); + unset($newProperties[404][$propName]); + break; + + } + + + } + return true; + + } + + + /** + * This method is called before the logic for any HTTP method is + * handled. + * + * This plugin uses that feature to intercept access to locked resources. + * + * @param string $method + * @param string $uri + * @return bool + */ + public function beforeMethod($method, $uri) { + + switch($method) { + + case 'DELETE' : + $lastLock = null; + if (!$this->validateLock($uri,$lastLock, true)) + throw new Sabre_DAV_Exception_Locked($lastLock); + break; + case 'MKCOL' : + case 'PROPPATCH' : + case 'PUT' : + $lastLock = null; + if (!$this->validateLock($uri,$lastLock)) + throw new Sabre_DAV_Exception_Locked($lastLock); + break; + case 'MOVE' : + $lastLock = null; + if (!$this->validateLock(array( + $uri, + $this->server->calculateUri($this->server->httpRequest->getHeader('Destination')), + ),$lastLock, true)) + throw new Sabre_DAV_Exception_Locked($lastLock); + break; + case 'COPY' : + $lastLock = null; + if (!$this->validateLock( + $this->server->calculateUri($this->server->httpRequest->getHeader('Destination')), + $lastLock, true)) + throw new Sabre_DAV_Exception_Locked($lastLock); + break; + } + + return true; + + } + + /** + * Use this method to tell the server this plugin defines additional + * HTTP methods. + * + * This method is passed a uri. It should only return HTTP methods that are + * available for the specified uri. + * + * @param string $uri + * @return array + */ + public function getHTTPMethods($uri) { + + if ($this->locksBackend || + $this->server->tree->getNodeForPath($uri) instanceof Sabre_DAV_ILocks) { + return array('LOCK','UNLOCK'); + } + return array(); + + } + + /** + * Returns a list of features for the HTTP OPTIONS Dav: header. + * + * In this case this is only the number 2. The 2 in the Dav: header + * indicates the server supports locks. + * + * @return array + */ + public function getFeatures() { + + return array(2); + + } + + /** + * Returns all lock information on a particular uri + * + * This function should return an array with Sabre_DAV_Locks_LockInfo objects. If there are no locks on a file, return an empty array. + * + * Additionally there is also the possibility of locks on parent nodes, so we'll need to traverse every part of the tree + * If the $returnChildLocks argument is set to true, we'll also traverse all the children of the object + * for any possible locks and return those as well. + * + * @param string $uri + * @param bool $returnChildLocks + * @return array + */ + public function getLocks($uri, $returnChildLocks = false) { + + $lockList = array(); + $currentPath = ''; + foreach(explode('/',$uri) as $uriPart) { + + $uriLocks = array(); + if ($currentPath) $currentPath.='/'; + $currentPath.=$uriPart; + + try { + + $node = $this->server->tree->getNodeForPath($currentPath); + if ($node instanceof Sabre_DAV_ILockable) $uriLocks = $node->getLocks(); + + } catch (Sabre_DAV_Exception_FileNotFound $e){ + // In case the node didn't exist, this could be a lock-null request + } + + foreach($uriLocks as $uriLock) { + + // Unless we're on the leaf of the uri-tree we should ignore locks with depth 0 + if($uri==$currentPath || $uriLock->depth!=0) { + $uriLock->uri = $currentPath; + $lockList[] = $uriLock; + } + + } + + } + if ($this->locksBackend) + $lockList = array_merge($lockList,$this->locksBackend->getLocks($uri, $returnChildLocks)); + + return $lockList; + + } + + /** + * Locks an uri + * + * The WebDAV lock request can be operated to either create a new lock on a file, or to refresh an existing lock + * If a new lock is created, a full XML body should be supplied, containing information about the lock such as the type + * of lock (shared or exclusive) and the owner of the lock + * + * If a lock is to be refreshed, no body should be supplied and there should be a valid If header containing the lock + * + * Additionally, a lock can be requested for a non-existant file. In these case we're obligated to create an empty file as per RFC4918:S7.3 + * + * @param string $uri + * @return void + */ + protected function httpLock($uri) { + + $lastLock = null; + if (!$this->validateLock($uri,$lastLock)) { + + // If the existing lock was an exclusive lock, we need to fail + if (!$lastLock || $lastLock->scope == Sabre_DAV_Locks_LockInfo::EXCLUSIVE) { + //var_dump($lastLock); + throw new Sabre_DAV_Exception_ConflictingLock($lastLock); + } + + } + + if ($body = $this->server->httpRequest->getBody(true)) { + // This is a new lock request + $lockInfo = $this->parseLockRequest($body); + $lockInfo->depth = $this->server->getHTTPDepth(); + $lockInfo->uri = $uri; + if($lastLock && $lockInfo->scope != Sabre_DAV_Locks_LockInfo::SHARED) throw new Sabre_DAV_Exception_ConflictingLock($lastLock); + + } elseif ($lastLock) { + + // This must have been a lock refresh + $lockInfo = $lastLock; + + // The resource could have been locked through another uri. + if ($uri!=$lockInfo->uri) $uri = $lockInfo->uri; + + } else { + + // There was neither a lock refresh nor a new lock request + throw new Sabre_DAV_Exception_BadRequest('An xml body is required for lock requests'); + + } + + if ($timeout = $this->getTimeoutHeader()) $lockInfo->timeout = $timeout; + + $newFile = false; + + // If we got this far.. we should go check if this node actually exists. If this is not the case, we need to create it first + try { + $node = $this->server->tree->getNodeForPath($uri); + + // We need to call the beforeWriteContent event for RFC3744 + $this->server->broadcastEvent('beforeWriteContent',array($uri)); + + } catch (Sabre_DAV_Exception_FileNotFound $e) { + + // It didn't, lets create it + $this->server->createFile($uri,fopen('php://memory','r')); + $newFile = true; + + } + + $this->lockNode($uri,$lockInfo); + + $this->server->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8'); + $this->server->httpResponse->setHeader('Lock-Token','token . '>'); + $this->server->httpResponse->sendStatus($newFile?201:200); + $this->server->httpResponse->sendBody($this->generateLockResponse($lockInfo)); + + } + + /** + * Unlocks a uri + * + * This WebDAV method allows you to remove a lock from a node. The client should provide a valid locktoken through the Lock-token http header + * The server should return 204 (No content) on success + * + * @param string $uri + * @return void + */ + protected function httpUnlock($uri) { + + $lockToken = $this->server->httpRequest->getHeader('Lock-Token'); + + // If the locktoken header is not supplied, we need to throw a bad request exception + if (!$lockToken) throw new Sabre_DAV_Exception_BadRequest('No lock token was supplied'); + + $locks = $this->getLocks($uri); + + // Windows sometimes forgets to include < and > in the Lock-Token + // header + if ($lockToken[0]!=='<') $lockToken = '<' . $lockToken . '>'; + + foreach($locks as $lock) { + + if ('token . '>' == $lockToken) { + + $this->unlockNode($uri,$lock); + $this->server->httpResponse->setHeader('Content-Length','0'); + $this->server->httpResponse->sendStatus(204); + return; + + } + + } + + // If we got here, it means the locktoken was invalid + throw new Sabre_DAV_Exception_LockTokenMatchesRequestUri(); + + } + + /** + * Locks a uri + * + * All the locking information is supplied in the lockInfo object. The object has a suggested timeout, but this can be safely ignored + * It is important that if the existing timeout is ignored, the property is overwritten, as this needs to be sent back to the client + * + * @param string $uri + * @param Sabre_DAV_Locks_LockInfo $lockInfo + * @return void + */ + public function lockNode($uri,Sabre_DAV_Locks_LockInfo $lockInfo) { + + if (!$this->server->broadcastEvent('beforeLock',array($uri,$lockInfo))) return; + + try { + $node = $this->server->tree->getNodeForPath($uri); + if ($node instanceof Sabre_DAV_ILockable) return $node->lock($lockInfo); + } catch (Sabre_DAV_Exception_FileNotFound $e) { + // In case the node didn't exist, this could be a lock-null request + } + if ($this->locksBackend) return $this->locksBackend->lock($uri,$lockInfo); + throw new Sabre_DAV_Exception_MethodNotAllowed('Locking support is not enabled for this resource. No Locking backend was found so if you didn\'t expect this error, please check your configuration.'); + + } + + /** + * Unlocks a uri + * + * This method removes a lock from a uri. It is assumed all the supplied information is correct and verified + * + * @param string $uri + * @param Sabre_DAV_Locks_LockInfo $lockInfo + * @return void + */ + public function unlockNode($uri,Sabre_DAV_Locks_LockInfo $lockInfo) { + + if (!$this->server->broadcastEvent('beforeUnlock',array($uri,$lockInfo))) return; + try { + $node = $this->server->tree->getNodeForPath($uri); + if ($node instanceof Sabre_DAV_ILockable) return $node->unlock($lockInfo); + } catch (Sabre_DAV_Exception_FileNotFound $e) { + // In case the node didn't exist, this could be a lock-null request + } + + if ($this->locksBackend) return $this->locksBackend->unlock($uri,$lockInfo); + + } + + + /** + * Returns the contents of the HTTP Timeout header. + * + * The method formats the header into an integer. + * + * @return int + */ + public function getTimeoutHeader() { + + $header = $this->server->httpRequest->getHeader('Timeout'); + + if ($header) { + + if (stripos($header,'second-')===0) $header = (int)(substr($header,7)); + else if (strtolower($header)=='infinite') $header=Sabre_DAV_Locks_LockInfo::TIMEOUT_INFINITE; + else throw new Sabre_DAV_Exception_BadRequest('Invalid HTTP timeout header'); + + } else { + + $header = 0; + + } + + return $header; + + } + + /** + * Generates the response for successfull LOCK requests + * + * @param Sabre_DAV_Locks_LockInfo $lockInfo + * @return string + */ + protected function generateLockResponse(Sabre_DAV_Locks_LockInfo $lockInfo) { + + $dom = new DOMDocument('1.0','utf-8'); + $dom->formatOutput = true; + + $prop = $dom->createElementNS('DAV:','d:prop'); + $dom->appendChild($prop); + + $lockDiscovery = $dom->createElementNS('DAV:','d:lockdiscovery'); + $prop->appendChild($lockDiscovery); + + $lockObj = new Sabre_DAV_Property_LockDiscovery(array($lockInfo),true); + $lockObj->serialize($this->server,$lockDiscovery); + + return $dom->saveXML(); + + } + + /** + * validateLock should be called when a write operation is about to happen + * It will check if the requested url is locked, and see if the correct lock tokens are passed + * + * @param mixed $urls List of relevant urls. Can be an array, a string or nothing at all for the current request uri + * @param mixed $lastLock This variable will be populated with the last checked lock object (Sabre_DAV_Locks_LockInfo) + * @param bool $checkChildLocks If set to true, this function will also look for any locks set on child resources of the supplied urls. This is needed for for example deletion of entire trees. + * @return bool + */ + protected function validateLock($urls = null,&$lastLock = null, $checkChildLocks = false) { + + if (is_null($urls)) { + $urls = array($this->server->getRequestUri()); + } elseif (is_string($urls)) { + $urls = array($urls); + } elseif (!is_array($urls)) { + throw new Sabre_DAV_Exception('The urls parameter should either be null, a string or an array'); + } + + $conditions = $this->getIfConditions(); + + // We're going to loop through the urls and make sure all lock conditions are satisfied + foreach($urls as $url) { + + $locks = $this->getLocks($url, $checkChildLocks); + + // If there were no conditions, but there were locks, we fail + if (!$conditions && $locks) { + reset($locks); + $lastLock = current($locks); + return false; + } + + // If there were no locks or conditions, we go to the next url + if (!$locks && !$conditions) continue; + + foreach($conditions as $condition) { + + if (!$condition['uri']) { + $conditionUri = $this->server->getRequestUri(); + } else { + $conditionUri = $this->server->calculateUri($condition['uri']); + } + + // If the condition has a url, and it isn't part of the affected url at all, check the next condition + if ($conditionUri && strpos($url,$conditionUri)!==0) continue; + + // The tokens array contians arrays with 2 elements. 0=true/false for normal/not condition, 1=locktoken + // At least 1 condition has to be satisfied + foreach($condition['tokens'] as $conditionToken) { + + $etagValid = true; + $lockValid = true; + + // key 2 can contain an etag + if ($conditionToken[2]) { + + $uri = $conditionUri?$conditionUri:$this->server->getRequestUri(); + $node = $this->server->tree->getNodeForPath($uri); + $etagValid = $node->getETag()==$conditionToken[2]; + + } + + // key 1 can contain a lock token + if ($conditionToken[1]) { + + $lockValid = false; + // Match all the locks + foreach($locks as $lockIndex=>$lock) { + + $lockToken = 'opaquelocktoken:' . $lock->token; + + // Checking NOT + if (!$conditionToken[0] && $lockToken != $conditionToken[1]) { + + // Condition valid, onto the next + $lockValid = true; + break; + } + if ($conditionToken[0] && $lockToken == $conditionToken[1]) { + + $lastLock = $lock; + // Condition valid and lock matched + unset($locks[$lockIndex]); + $lockValid = true; + break; + + } + + } + + } + + // If, after checking both etags and locks they are stil valid, + // we can continue with the next condition. + if ($etagValid && $lockValid) continue 2; + } + // No conditions matched, so we fail + throw new Sabre_DAV_Exception_PreconditionFailed('The tokens provided in the if header did not match','If'); + } + + // Conditions were met, we'll also need to check if all the locks are gone + if (count($locks)) { + + reset($locks); + + // There's still locks, we fail + $lastLock = current($locks); + return false; + + } + + + } + + // We got here, this means every condition was satisfied + return true; + + } + + /** + * This method is created to extract information from the WebDAV HTTP 'If:' header + * + * The If header can be quite complex, and has a bunch of features. We're using a regex to extract all relevant information + * The function will return an array, containg structs with the following keys + * + * * uri - the uri the condition applies to. If this is returned as an + * empty string, this implies it's referring to the request url. + * * tokens - The lock token. another 2 dimensional array containg 2 elements (0 = true/false.. If this is a negative condition its set to false, 1 = the actual token) + * * etag - an etag, if supplied + * + * @return void + */ + public function getIfConditions() { + + $header = $this->server->httpRequest->getHeader('If'); + if (!$header) return array(); + + $matches = array(); + + $regex = '/(?:\<(?P.*?)\>\s)?\((?PNot\s)?(?:\<(?P[^\>]*)\>)?(?:\s?)(?:\[(?P[^\]]*)\])?\)/im'; + preg_match_all($regex,$header,$matches,PREG_SET_ORDER); + + $conditions = array(); + + foreach($matches as $match) { + + $condition = array( + 'uri' => $match['uri'], + 'tokens' => array( + array($match['not']?0:1,$match['token'],isset($match['etag'])?$match['etag']:'') + ), + ); + + if (!$condition['uri'] && count($conditions)) $conditions[count($conditions)-1]['tokens'][] = array( + $match['not']?0:1, + $match['token'], + isset($match['etag'])?$match['etag']:'' + ); + else { + $conditions[] = $condition; + } + + } + + return $conditions; + + } + + /** + * Parses a webdav lock xml body, and returns a new Sabre_DAV_Locks_LockInfo object + * + * @param string $body + * @return Sabre_DAV_Locks_LockInfo + */ + protected function parseLockRequest($body) { + + $xml = simplexml_load_string($body,null,LIBXML_NOWARNING); + $xml->registerXPathNamespace('d','DAV:'); + $lockInfo = new Sabre_DAV_Locks_LockInfo(); + + $children = $xml->children("DAV:"); + $lockInfo->owner = (string)$children->owner; + + $lockInfo->token = Sabre_DAV_UUIDUtil::getUUID(); + $lockInfo->scope = count($xml->xpath('d:lockscope/d:exclusive'))>0?Sabre_DAV_Locks_LockInfo::EXCLUSIVE:Sabre_DAV_Locks_LockInfo::SHARED; + + return $lockInfo; + + } + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Mount/Plugin.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Mount/Plugin.php new file mode 100755 index 0000000..75c1bff --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Mount/Plugin.php @@ -0,0 +1,79 @@ +server = $server; + $this->server->subscribeEvent('beforeMethod',array($this,'beforeMethod'), 90); + + } + + /** + * 'beforeMethod' event handles. This event handles intercepts GET requests ending + * with ?mount + * + * @param string $method + * @return void + */ + public function beforeMethod($method, $uri) { + + if ($method!='GET') return; + if ($this->server->httpRequest->getQueryString()!='mount') return; + + $currentUri = $this->server->httpRequest->getAbsoluteUri(); + + // Stripping off everything after the ? + list($currentUri) = explode('?',$currentUri); + + $this->davMount($currentUri); + + // Returning false to break the event chain + return false; + + } + + /** + * Generates the davmount response + * + * @param string $uri absolute uri + * @return void + */ + public function davMount($uri) { + + $this->server->httpResponse->sendStatus(200); + $this->server->httpResponse->setHeader('Content-Type','application/davmount+xml'); + ob_start(); + echo '', "\n"; + echo "\n"; + echo " ", htmlspecialchars($uri, ENT_NOQUOTES, 'UTF-8'), "\n"; + echo ""; + $this->server->httpResponse->sendBody(ob_get_clean()); + + } + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Node.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Node.php new file mode 100755 index 0000000..ab429af --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Node.php @@ -0,0 +1,55 @@ +rootNode = $rootNode; + + } + + /** + * Returns the INode object for the requested path + * + * @param string $path + * @return Sabre_DAV_INode + */ + public function getNodeForPath($path) { + + $path = trim($path,'/'); + if (isset($this->cache[$path])) return $this->cache[$path]; + + //if (!$path || $path=='.') return $this->rootNode; + $currentNode = $this->rootNode; + $i=0; + // We're splitting up the path variable into folder/subfolder components and traverse to the correct node.. + foreach(explode('/',$path) as $pathPart) { + + // If this part of the path is just a dot, it actually means we can skip it + if ($pathPart=='.' || $pathPart=='') continue; + + if (!($currentNode instanceof Sabre_DAV_ICollection)) + throw new Sabre_DAV_Exception_FileNotFound('Could not find node at path: ' . $path); + + $currentNode = $currentNode->getChild($pathPart); + + } + + $this->cache[$path] = $currentNode; + return $currentNode; + + } + + /** + * This function allows you to check if a node exists. + * + * @param string $path + * @return bool + */ + public function nodeExists($path) { + + try { + + // The root always exists + if ($path==='') return true; + + list($parent, $base) = Sabre_DAV_URLUtil::splitPath($path); + + $parentNode = $this->getNodeForPath($parent); + if (!$parentNode instanceof Sabre_DAV_ICollection) return false; + return $parentNode->childExists($base); + + } catch (Sabre_DAV_Exception_FileNotFound $e) { + + return false; + + } + + } + + /** + * Returns a list of childnodes for a given path. + * + * @param string $path + * @return array + */ + public function getChildren($path) { + + $node = $this->getNodeForPath($path); + $children = $node->getChildren(); + foreach($children as $child) { + + $this->cache[trim($path,'/') . '/' . $child->getName()] = $child; + + } + return $children; + + } + + /** + * This method is called with every tree update + * + * Examples of tree updates are: + * * node deletions + * * node creations + * * copy + * * move + * * renaming nodes + * + * If Tree classes implement a form of caching, this will allow + * them to make sure caches will be expired. + * + * If a path is passed, it is assumed that the entire subtree is dirty + * + * @param string $path + * @return void + */ + public function markDirty($path) { + + // We don't care enough about sub-paths + // flushing the entire cache + $path = trim($path,'/'); + foreach($this->cache as $nodePath=>$node) { + if ($nodePath == $path || strpos($nodePath,$path.'/')===0) + unset($this->cache[$nodePath]); + + } + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property.php new file mode 100755 index 0000000..3ad9d88 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property.php @@ -0,0 +1,25 @@ +time = $time; + } elseif (is_int($time) || ctype_digit($time)) { + $this->time = new DateTime('@' . $time); + } else { + $this->time = new DateTime($time); + } + + // Setting timezone to UTC + $this->time->setTimezone(new DateTimeZone('UTC')); + + } + + /** + * serialize + * + * @param DOMElement $prop + * @return void + */ + public function serialize(Sabre_DAV_Server $server, DOMElement $prop) { + + $doc = $prop->ownerDocument; + $prop->setAttribute('xmlns:b','urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/'); + $prop->setAttribute('b:dt','dateTime.rfc1123'); + $prop->nodeValue = $this->time->format(DateTime::RFC1123); + + } + + /** + * getTime + * + * @return DateTime + */ + public function getTime() { + + return $this->time; + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/Href.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/Href.php new file mode 100755 index 0000000..e87cf75 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/Href.php @@ -0,0 +1,91 @@ +href = $href; + $this->autoPrefix = $autoPrefix; + + } + + /** + * Returns the uri + * + * @return string + */ + public function getHref() { + + return $this->href; + + } + + /** + * Serializes this property. + * + * It will additionally prepend the href property with the server's base uri. + * + * @param Sabre_DAV_Server $server + * @param DOMElement $dom + * @return void + */ + public function serialize(Sabre_DAV_Server $server,DOMElement $dom) { + + $prefix = $server->xmlNamespaces['DAV:']; + + $elem = $dom->ownerDocument->createElement($prefix . ':href'); + $elem->nodeValue = ($this->autoPrefix?$server->getBaseUri():'') . $this->href; + $dom->appendChild($elem); + + } + + /** + * Unserializes this property from a DOM Element + * + * This method returns an instance of this class. + * It will only decode {DAV:}href values. For non-compatible elements null will be returned. + * + * @param DOMElement $dom + * @return Sabre_DAV_Property_Href + */ + static function unserialize(DOMElement $dom) { + + if (Sabre_DAV_XMLUtil::toClarkNotation($dom->firstChild)==='{DAV:}href') { + return new self($dom->firstChild->textContent,false); + } + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/HrefList.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/HrefList.php new file mode 100755 index 0000000..6e16d25 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/HrefList.php @@ -0,0 +1,96 @@ +hrefs = $hrefs; + $this->autoPrefix = $autoPrefix; + + } + + /** + * Returns the uris + * + * @return array + */ + public function getHrefs() { + + return $this->hrefs; + + } + + /** + * Serializes this property. + * + * It will additionally prepend the href property with the server's base uri. + * + * @param Sabre_DAV_Server $server + * @param DOMElement $dom + * @return void + */ + public function serialize(Sabre_DAV_Server $server,DOMElement $dom) { + + $prefix = $server->xmlNamespaces['DAV:']; + + foreach($this->hrefs as $href) { + $elem = $dom->ownerDocument->createElement($prefix . ':href'); + $elem->nodeValue = ($this->autoPrefix?$server->getBaseUri():'') . $href; + $dom->appendChild($elem); + } + + } + + /** + * Unserializes this property from a DOM Element + * + * This method returns an instance of this class. + * It will only decode {DAV:}href values. + * + * @param DOMElement $dom + * @return Sabre_DAV_Property_Href + */ + static function unserialize(DOMElement $dom) { + + $hrefs = array(); + foreach($dom->childNodes as $child) { + if (Sabre_DAV_XMLUtil::toClarkNotation($child)==='{DAV:}href') { + $hrefs[] = $child->textContent; + } + } + return new self($hrefs, false); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/IHref.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/IHref.php new file mode 100755 index 0000000..4bf4095 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/IHref.php @@ -0,0 +1,25 @@ +locks = $locks; + $this->revealLockToken = $revealLockToken; + + } + + /** + * serialize + * + * @param DOMElement $prop + * @return void + */ + public function serialize(Sabre_DAV_Server $server,DOMElement $prop) { + + $doc = $prop->ownerDocument; + + foreach($this->locks as $lock) { + + $activeLock = $doc->createElementNS('DAV:','d:activelock'); + $prop->appendChild($activeLock); + + $lockScope = $doc->createElementNS('DAV:','d:lockscope'); + $activeLock->appendChild($lockScope); + + $lockScope->appendChild($doc->createElementNS('DAV:','d:' . ($lock->scope==Sabre_DAV_Locks_LockInfo::EXCLUSIVE?'exclusive':'shared'))); + + $lockType = $doc->createElementNS('DAV:','d:locktype'); + $activeLock->appendChild($lockType); + + $lockType->appendChild($doc->createElementNS('DAV:','d:write')); + + /* {DAV:}lockroot */ + if (!self::$hideLockRoot) { + $lockRoot = $doc->createElementNS('DAV:','d:lockroot'); + $activeLock->appendChild($lockRoot); + $href = $doc->createElementNS('DAV:','d:href'); + $href->appendChild($doc->createTextNode($server->getBaseUri() . $lock->uri)); + $lockRoot->appendChild($href); + } + + $activeLock->appendChild($doc->createElementNS('DAV:','d:depth',($lock->depth == Sabre_DAV_Server::DEPTH_INFINITY?'infinity':$lock->depth))); + $activeLock->appendChild($doc->createElementNS('DAV:','d:timeout','Second-' . $lock->timeout)); + + if ($this->revealLockToken) { + $lockToken = $doc->createElementNS('DAV:','d:locktoken'); + $activeLock->appendChild($lockToken); + $lockToken->appendChild($doc->createElementNS('DAV:','d:href','opaquelocktoken:' . $lock->token)); + } + + $activeLock->appendChild($doc->createElementNS('DAV:','d:owner',$lock->owner)); + + } + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/ResourceType.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/ResourceType.php new file mode 100755 index 0000000..54b4ea6 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/ResourceType.php @@ -0,0 +1,125 @@ +resourceType = array(); + elseif ($resourceType === Sabre_DAV_Server::NODE_DIRECTORY) + $this->resourceType = array('{DAV:}collection'); + elseif (is_array($resourceType)) + $this->resourceType = $resourceType; + else + $this->resourceType = array($resourceType); + + } + + /** + * serialize + * + * @param DOMElement $prop + * @return void + */ + public function serialize(Sabre_DAV_Server $server,DOMElement $prop) { + + $propName = null; + $rt = $this->resourceType; + + foreach($rt as $resourceType) { + if (preg_match('/^{([^}]*)}(.*)$/',$resourceType,$propName)) { + + if (isset($server->xmlNamespaces[$propName[1]])) { + $prop->appendChild($prop->ownerDocument->createElement($server->xmlNamespaces[$propName[1]] . ':' . $propName[2])); + } else { + $prop->appendChild($prop->ownerDocument->createElementNS($propName[1],'custom:' . $propName[2])); + } + + } + } + + } + + /** + * Returns the values in clark-notation + * + * For example array('{DAV:}collection') + * + * @return array + */ + public function getValue() { + + return $this->resourceType; + + } + + /** + * Checks if the principal contains a certain value + * + * @param string $type + * @return bool + */ + public function is($type) { + + return in_array($type, $this->resourceType); + + } + + /** + * Adds a resourcetype value to this property + * + * @param string $type + * @return void + */ + public function add($type) { + + $this->resourceType[] = $type; + $this->resourceType = array_unique($this->resourceType); + + } + + /** + * Unserializes a DOM element into a ResourceType property. + * + * @param DOMElement $dom + * @return void + */ + static public function unserialize(DOMElement $dom) { + + $value = array(); + foreach($dom->childNodes as $child) { + + $value[] = Sabre_DAV_XMLUtil::toClarkNotation($child); + + } + + return new self($value); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/Response.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/Response.php new file mode 100755 index 0000000..f7d15f0 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/Response.php @@ -0,0 +1,156 @@ +href = $href; + $this->responseProperties = $responseProperties; + + } + + /** + * Returns the url + * + * @return string + */ + public function getHref() { + + return $this->href; + + } + + /** + * Returns the property list + * + * @return array + */ + public function getResponseProperties() { + + return $this->responseProperties; + + } + + /** + * serialize + * + * @param Sabre_DAV_Server $server + * @param DOMElement $dom + * @return void + */ + public function serialize(Sabre_DAV_Server $server,DOMElement $dom) { + + $document = $dom->ownerDocument; + $properties = $this->responseProperties; + + $xresponse = $document->createElement('d:response'); + $dom->appendChild($xresponse); + + $uri = Sabre_DAV_URLUtil::encodePath($this->href); + + // Adding the baseurl to the beginning of the url + $uri = $server->getBaseUri() . $uri; + + $xresponse->appendChild($document->createElement('d:href',$uri)); + + // The properties variable is an array containing properties, grouped by + // HTTP status + foreach($properties as $httpStatus=>$propertyGroup) { + + // The 'href' is also in this array, and it's special cased. + // We will ignore it + if ($httpStatus=='href') continue; + + // If there are no properties in this group, we can also just carry on + if (!count($propertyGroup)) continue; + + $xpropstat = $document->createElement('d:propstat'); + $xresponse->appendChild($xpropstat); + + $xprop = $document->createElement('d:prop'); + $xpropstat->appendChild($xprop); + + $nsList = $server->xmlNamespaces; + + foreach($propertyGroup as $propertyName=>$propertyValue) { + + $propName = null; + preg_match('/^{([^}]*)}(.*)$/',$propertyName,$propName); + + // special case for empty namespaces + if ($propName[1]=='') { + + $currentProperty = $document->createElement($propName[2]); + $xprop->appendChild($currentProperty); + $currentProperty->setAttribute('xmlns',''); + + } else { + + if (!isset($nsList[$propName[1]])) { + $nsList[$propName[1]] = 'x' . count($nsList); + } + + // If the namespace was defined in the top-level xml namespaces, it means + // there was already a namespace declaration, and we don't have to worry about it. + if (isset($server->xmlNamespaces[$propName[1]])) { + $currentProperty = $document->createElement($nsList[$propName[1]] . ':' . $propName[2]); + } else { + $currentProperty = $document->createElementNS($propName[1],$nsList[$propName[1]].':' . $propName[2]); + } + $xprop->appendChild($currentProperty); + + } + + if (is_scalar($propertyValue)) { + $text = $document->createTextNode($propertyValue); + $currentProperty->appendChild($text); + } elseif ($propertyValue instanceof Sabre_DAV_Property) { + $propertyValue->serialize($server,$currentProperty); + } elseif (!is_null($propertyValue)) { + throw new Sabre_DAV_Exception('Unknown property value type: ' . gettype($propertyValue) . ' for property: ' . $propertyName); + } + + } + + $xpropstat->appendChild($document->createElement('d:status',$server->httpResponse->getStatusMessage($httpStatus))); + + } + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/ResponseList.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/ResponseList.php new file mode 100755 index 0000000..13d52df --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/ResponseList.php @@ -0,0 +1,58 @@ +responses = $responses; + + } + + /** + * serialize + * + * @param Sabre_DAV_Server $server + * @param DOMElement $dom + * @return void + */ + public function serialize(Sabre_DAV_Server $server,DOMElement $dom) { + + foreach($this->responses as $response) { + $response->serialize($server, $dom); + } + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/SupportedLock.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/SupportedLock.php new file mode 100755 index 0000000..7be9047 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/SupportedLock.php @@ -0,0 +1,76 @@ +supportsLocks = $supportsLocks; + + } + + /** + * serialize + * + * @param DOMElement $prop + * @return void + */ + public function serialize(Sabre_DAV_Server $server,DOMElement $prop) { + + $doc = $prop->ownerDocument; + + if (!$this->supportsLocks) return null; + + $lockEntry1 = $doc->createElementNS('DAV:','d:lockentry'); + $lockEntry2 = $doc->createElementNS('DAV:','d:lockentry'); + + $prop->appendChild($lockEntry1); + $prop->appendChild($lockEntry2); + + $lockScope1 = $doc->createElementNS('DAV:','d:lockscope'); + $lockScope2 = $doc->createElementNS('DAV:','d:lockscope'); + $lockType1 = $doc->createElementNS('DAV:','d:locktype'); + $lockType2 = $doc->createElementNS('DAV:','d:locktype'); + + $lockEntry1->appendChild($lockScope1); + $lockEntry1->appendChild($lockType1); + $lockEntry2->appendChild($lockScope2); + $lockEntry2->appendChild($lockType2); + + $lockScope1->appendChild($doc->createElementNS('DAV:','d:exclusive')); + $lockScope2->appendChild($doc->createElementNS('DAV:','d:shared')); + + $lockType1->appendChild($doc->createElementNS('DAV:','d:write')); + $lockType2->appendChild($doc->createElementNS('DAV:','d:write')); + + //$frag->appendXML(''); + //$frag->appendXML(''); + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/SupportedReportSet.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/SupportedReportSet.php new file mode 100755 index 0000000..577260b --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Property/SupportedReportSet.php @@ -0,0 +1,110 @@ +addReport($reports); + + } + + /** + * Adds a report to this property + * + * The report must be a string in clark-notation. + * Multiple reports can be specified as an array. + * + * @param mixed $report + * @return void + */ + public function addReport($report) { + + if (!is_array($report)) $report = array($report); + + foreach($report as $r) { + + if (!preg_match('/^{([^}]*)}(.*)$/',$r)) + throw new Sabre_DAV_Exception('Reportname must be in clark-notation'); + + $this->reports[] = $r; + + } + + } + + /** + * Returns the list of supported reports + * + * @return array + */ + public function getValue() { + + return $this->reports; + + } + + /** + * Serializes the node + * + * @param Sabre_DAV_Server $server + * @param DOMElement $prop + * @return void + */ + public function serialize(Sabre_DAV_Server $server,DOMElement $prop) { + + foreach($this->reports as $reportName) { + + $supportedReport = $prop->ownerDocument->createElement('d:supported-report'); + $prop->appendChild($supportedReport); + + $report = $prop->ownerDocument->createElement('d:report'); + $supportedReport->appendChild($report); + + preg_match('/^{([^}]*)}(.*)$/',$reportName,$matches); + + list(, $namespace, $element) = $matches; + + $prefix = isset($server->xmlNamespaces[$namespace])?$server->xmlNamespaces[$namespace]:null; + + if ($prefix) { + $report->appendChild($prop->ownerDocument->createElement($prefix . ':' . $element)); + } else { + $report->appendChild($prop->ownerDocument->createElementNS($namespace, 'x:' . $element)); + } + + } + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Server.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Server.php new file mode 100755 index 0000000..85be9d2 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Server.php @@ -0,0 +1,1941 @@ + 'd', + 'http://sabredav.org/ns' => 's', + ); + + /** + * The propertymap can be used to map properties from + * requests to property classes. + * + * @var array + */ + public $propertyMap = array( + '{DAV:}resourcetype' => 'Sabre_DAV_Property_ResourceType', + ); + + public $protectedProperties = array( + // RFC4918 + '{DAV:}getcontentlength', + '{DAV:}getetag', + '{DAV:}getlastmodified', + '{DAV:}lockdiscovery', + '{DAV:}resourcetype', + '{DAV:}supportedlock', + + // RFC4331 + '{DAV:}quota-available-bytes', + '{DAV:}quota-used-bytes', + + // RFC3744 + '{DAV:}supported-privilege-set', + '{DAV:}current-user-privilege-set', + '{DAV:}acl', + '{DAV:}acl-restrictions', + '{DAV:}inherited-acl-set', + + ); + + /** + * This is a flag that allow or not showing file, line and code + * of the exception in the returned XML + * + * @var bool + */ + public $debugExceptions = false; + + /** + * This property allows you to automatically add the 'resourcetype' value + * based on a node's classname or interface. + * + * The preset ensures that {DAV:}collection is automaticlly added for nodes + * implementing Sabre_DAV_ICollection. + * + * @var array + */ + public $resourceTypeMapping = array( + 'Sabre_DAV_ICollection' => '{DAV:}collection', + ); + + + /** + * Sets up the server + * + * If a Sabre_DAV_Tree object is passed as an argument, it will + * use it as the directory tree. If a Sabre_DAV_INode is passed, it + * will create a Sabre_DAV_ObjectTree and use the node as the root. + * + * If nothing is passed, a Sabre_DAV_SimpleCollection is created in + * a Sabre_DAV_ObjectTree. + * + * If an array is passed, we automatically create a root node, and use + * the nodes in the array as top-level children. + * + * @param Sabre_DAV_Tree $tree The tree object + * @return void + */ + public function __construct($treeOrNode = null) { + + if ($treeOrNode instanceof Sabre_DAV_Tree) { + $this->tree = $treeOrNode; + } elseif ($treeOrNode instanceof Sabre_DAV_INode) { + $this->tree = new Sabre_DAV_ObjectTree($treeOrNode); + } elseif (is_array($treeOrNode)) { + + // If it's an array, a list of nodes was passed, and we need to + // create the root node. + foreach($treeOrNode as $node) { + if (!($node instanceof Sabre_DAV_INode)) { + throw new Sabre_DAV_Exception('Invalid argument passed to constructor. If you\'re passing an array, all the values must implement Sabre_DAV_INode'); + } + } + + $root = new Sabre_DAV_SimpleCollection('root', $treeOrNode); + $this->tree = new Sabre_DAV_ObjectTree($root); + + } elseif (is_null($treeOrNode)) { + $root = new Sabre_DAV_SimpleCollection('root'); + $this->tree = new Sabre_DAV_ObjectTree($root); + } else { + throw new Sabre_DAV_Exception('Invalid argument passed to constructor. Argument must either be an instance of Sabre_DAV_Tree, Sabre_DAV_INode, an array or null'); + } + $this->httpResponse = new Sabre_HTTP_Response(); + $this->httpRequest = new Sabre_HTTP_Request(); + + } + + /** + * Starts the DAV Server + * + * @return void + */ + public function exec() { + + try { + + $this->invokeMethod($this->httpRequest->getMethod(), $this->getRequestUri()); + + } catch (Exception $e) { + + $DOM = new DOMDocument('1.0','utf-8'); + $DOM->formatOutput = true; + + $error = $DOM->createElementNS('DAV:','d:error'); + $error->setAttribute('xmlns:s',self::NS_SABREDAV); + $DOM->appendChild($error); + + $error->appendChild($DOM->createElement('s:exception',get_class($e))); + $error->appendChild($DOM->createElement('s:message',$e->getMessage())); + if ($this->debugExceptions) { + $error->appendChild($DOM->createElement('s:file',$e->getFile())); + $error->appendChild($DOM->createElement('s:line',$e->getLine())); + $error->appendChild($DOM->createElement('s:code',$e->getCode())); + $error->appendChild($DOM->createElement('s:stacktrace',$e->getTraceAsString())); + + } + $error->appendChild($DOM->createElement('s:sabredav-version',Sabre_DAV_Version::VERSION)); + + if($e instanceof Sabre_DAV_Exception) { + + $httpCode = $e->getHTTPCode(); + $e->serialize($this,$error); + $headers = $e->getHTTPHeaders($this); + + } else { + + $httpCode = 500; + $headers = array(); + + } + $headers['Content-Type'] = 'application/xml; charset=utf-8'; + + $this->httpResponse->sendStatus($httpCode); + $this->httpResponse->setHeaders($headers); + $this->httpResponse->sendBody($DOM->saveXML()); + + } + + } + + /** + * Sets the base server uri + * + * @param string $uri + * @return void + */ + public function setBaseUri($uri) { + + // If the baseUri does not end with a slash, we must add it + if ($uri[strlen($uri)-1]!=='/') + $uri.='/'; + + $this->baseUri = $uri; + + } + + /** + * Returns the base responding uri + * + * @return string + */ + public function getBaseUri() { + + if (is_null($this->baseUri)) $this->baseUri = $this->guessBaseUri(); + return $this->baseUri; + + } + + /** + * This method attempts to detect the base uri. + * Only the PATH_INFO variable is considered. + * + * If this variable is not set, the root (/) is assumed. + * + * @return void + */ + public function guessBaseUri() { + + $pathInfo = $this->httpRequest->getRawServerValue('PATH_INFO'); + $uri = $this->httpRequest->getRawServerValue('REQUEST_URI'); + + // If PATH_INFO is found, we can assume it's accurate. + if (!empty($pathInfo)) { + + // We need to make sure we ignore the QUERY_STRING part + if ($pos = strpos($uri,'?')) + $uri = substr($uri,0,$pos); + + // PATH_INFO is only set for urls, such as: /example.php/path + // in that case PATH_INFO contains '/path'. + // Note that REQUEST_URI is percent encoded, while PATH_INFO is + // not, Therefore they are only comparable if we first decode + // REQUEST_INFO as well. + $decodedUri = Sabre_DAV_URLUtil::decodePath($uri); + + // A simple sanity check: + if(substr($decodedUri,strlen($decodedUri)-strlen($pathInfo))===$pathInfo) { + $baseUri = substr($decodedUri,0,strlen($decodedUri)-strlen($pathInfo)); + return rtrim($baseUri,'/') . '/'; + } + + throw new Sabre_DAV_Exception('The REQUEST_URI ('. $uri . ') did not end with the contents of PATH_INFO (' . $pathInfo . '). This server might be misconfigured.'); + + } + + // The last fallback is that we're just going to assume the server root. + return '/'; + + } + + /** + * Adds a plugin to the server + * + * For more information, console the documentation of Sabre_DAV_ServerPlugin + * + * @param Sabre_DAV_ServerPlugin $plugin + * @return void + */ + public function addPlugin(Sabre_DAV_ServerPlugin $plugin) { + + $this->plugins[$plugin->getPluginName()] = $plugin; + $plugin->initialize($this); + + } + + /** + * Returns an initialized plugin by it's name. + * + * This function returns null if the plugin was not found. + * + * @param string $name + * @return Sabre_DAV_ServerPlugin + */ + public function getPlugin($name) { + + if (isset($this->plugins[$name])) + return $this->plugins[$name]; + + // This is a fallback and deprecated. + foreach($this->plugins as $plugin) { + if (get_class($plugin)===$name) return $plugin; + } + + return null; + + } + + /** + * Returns all plugins + * + * @return array + */ + public function getPlugins() { + + return $this->plugins; + + } + + + + /** + * Subscribe to an event. + * + * When the event is triggered, we'll call all the specified callbacks. + * It is possible to control the order of the callbacks through the + * priority argument. + * + * This is for example used to make sure that the authentication plugin + * is triggered before anything else. If it's not needed to change this + * number, it is recommended to ommit. + * + * @param string $event + * @param callback $callback + * @param int $priority + * @return void + */ + public function subscribeEvent($event, $callback, $priority = 100) { + + if (!isset($this->eventSubscriptions[$event])) { + $this->eventSubscriptions[$event] = array(); + } + while(isset($this->eventSubscriptions[$event][$priority])) $priority++; + $this->eventSubscriptions[$event][$priority] = $callback; + ksort($this->eventSubscriptions[$event]); + + } + + /** + * Broadcasts an event + * + * This method will call all subscribers. If one of the subscribers returns false, the process stops. + * + * The arguments parameter will be sent to all subscribers + * + * @param string $eventName + * @param array $arguments + * @return bool + */ + public function broadcastEvent($eventName,$arguments = array()) { + + if (isset($this->eventSubscriptions[$eventName])) { + + foreach($this->eventSubscriptions[$eventName] as $subscriber) { + + $result = call_user_func_array($subscriber,$arguments); + if ($result===false) return false; + + } + + } + + return true; + + } + + /** + * Handles a http request, and execute a method based on its name + * + * @param string $method + * @param string $uri + * @return void + */ + public function invokeMethod($method, $uri) { + + $method = strtoupper($method); + + if (!$this->broadcastEvent('beforeMethod',array($method, $uri))) return; + + // Make sure this is a HTTP method we support + $internalMethods = array( + 'OPTIONS', + 'GET', + 'HEAD', + 'DELETE', + 'PROPFIND', + 'MKCOL', + 'PUT', + 'PROPPATCH', + 'COPY', + 'MOVE', + 'REPORT' + ); + + if (in_array($method,$internalMethods)) { + + call_user_func(array($this,'http' . $method), $uri); + + } else { + + if ($this->broadcastEvent('unknownMethod',array($method, $uri))) { + // Unsupported method + throw new Sabre_DAV_Exception_NotImplemented(); + } + + } + + } + + // {{{ HTTP Method implementations + + /** + * HTTP OPTIONS + * + * @param string $uri + * @return void + */ + protected function httpOptions($uri) { + + $methods = $this->getAllowedMethods($uri); + + $this->httpResponse->setHeader('Allow',strtoupper(implode(', ',$methods))); + $features = array('1','3', 'extended-mkcol'); + + foreach($this->plugins as $plugin) $features = array_merge($features,$plugin->getFeatures()); + + $this->httpResponse->setHeader('DAV',implode(', ',$features)); + $this->httpResponse->setHeader('MS-Author-Via','DAV'); + $this->httpResponse->setHeader('Accept-Ranges','bytes'); + $this->httpResponse->setHeader('X-Sabre-Version',Sabre_DAV_Version::VERSION); + $this->httpResponse->setHeader('Content-Length',0); + $this->httpResponse->sendStatus(200); + + } + + /** + * HTTP GET + * + * This method simply fetches the contents of a uri, like normal + * + * @param string $uri + * @return void + */ + protected function httpGet($uri) { + + $node = $this->tree->getNodeForPath($uri,0); + + if (!$this->checkPreconditions(true)) return false; + + if (!($node instanceof Sabre_DAV_IFile)) throw new Sabre_DAV_Exception_NotImplemented('GET is only implemented on File objects'); + $body = $node->get(); + + // Converting string into stream, if needed. + if (is_string($body)) { + $stream = fopen('php://temp','r+'); + fwrite($stream,$body); + rewind($stream); + $body = $stream; + } + + /* + * TODO: getetag, getlastmodified, getsize should also be used using + * this method + */ + $httpHeaders = $this->getHTTPHeaders($uri); + + /* ContentType needs to get a default, because many webservers will otherwise + * default to text/html, and we don't want this for security reasons. + */ + if (!isset($httpHeaders['Content-Type'])) { + $httpHeaders['Content-Type'] = 'application/octet-stream'; + } + + + if (isset($httpHeaders['Content-Length'])) { + + $nodeSize = $httpHeaders['Content-Length']; + + // Need to unset Content-Length, because we'll handle that during figuring out the range + unset($httpHeaders['Content-Length']); + + } else { + $nodeSize = null; + } + + $this->httpResponse->setHeaders($httpHeaders); + + $range = $this->getHTTPRange(); + $ifRange = $this->httpRequest->getHeader('If-Range'); + $ignoreRangeHeader = false; + + // If ifRange is set, and range is specified, we first need to check + // the precondition. + if ($nodeSize && $range && $ifRange) { + + // if IfRange is parsable as a date we'll treat it as a DateTime + // otherwise, we must treat it as an etag. + try { + $ifRangeDate = new DateTime($ifRange); + + // It's a date. We must check if the entity is modified since + // the specified date. + if (!isset($httpHeaders['Last-Modified'])) $ignoreRangeHeader = true; + else { + $modified = new DateTime($httpHeaders['Last-Modified']); + if($modified > $ifRangeDate) $ignoreRangeHeader = true; + } + + } catch (Exception $e) { + + // It's an entity. We can do a simple comparison. + if (!isset($httpHeaders['ETag'])) $ignoreRangeHeader = true; + elseif ($httpHeaders['ETag']!==$ifRange) $ignoreRangeHeader = true; + } + } + + // We're only going to support HTTP ranges if the backend provided a filesize + if (!$ignoreRangeHeader && $nodeSize && $range) { + + // Determining the exact byte offsets + if (!is_null($range[0])) { + + $start = $range[0]; + $end = $range[1]?$range[1]:$nodeSize-1; + if($start >= $nodeSize) + throw new Sabre_DAV_Exception_RequestedRangeNotSatisfiable('The start offset (' . $range[0] . ') exceeded the size of the entity (' . $nodeSize . ')'); + + if($end < $start) throw new Sabre_DAV_Exception_RequestedRangeNotSatisfiable('The end offset (' . $range[1] . ') is lower than the start offset (' . $range[0] . ')'); + if($end >= $nodeSize) $end = $nodeSize-1; + + } else { + + $start = $nodeSize-$range[1]; + $end = $nodeSize-1; + + if ($start<0) $start = 0; + + } + + // New read/write stream + $newStream = fopen('php://temp','r+'); + + stream_copy_to_stream($body, $newStream, $end-$start+1, $start); + rewind($newStream); + + $this->httpResponse->setHeader('Content-Length', $end-$start+1); + $this->httpResponse->setHeader('Content-Range','bytes ' . $start . '-' . $end . '/' . $nodeSize); + $this->httpResponse->sendStatus(206); + $this->httpResponse->sendBody($newStream); + + + } else { + + if ($nodeSize) $this->httpResponse->setHeader('Content-Length',$nodeSize); + $this->httpResponse->sendStatus(200); + $this->httpResponse->sendBody($body); + + } + + } + + /** + * HTTP HEAD + * + * This method is normally used to take a peak at a url, and only get the HTTP response headers, without the body + * This is used by clients to determine if a remote file was changed, so they can use a local cached version, instead of downloading it again + * + * @param string $uri + * @return void + */ + protected function httpHead($uri) { + + $node = $this->tree->getNodeForPath($uri); + /* This information is only collection for File objects. + * Ideally we want to throw 405 Method Not Allowed for every + * non-file, but MS Office does not like this + */ + if ($node instanceof Sabre_DAV_IFile) { + $headers = $this->getHTTPHeaders($this->getRequestUri()); + if (!isset($headers['Content-Type'])) { + $headers['Content-Type'] = 'application/octet-stream'; + } + $this->httpResponse->setHeaders($headers); + } + $this->httpResponse->sendStatus(200); + + } + + /** + * HTTP Delete + * + * The HTTP delete method, deletes a given uri + * + * @param string $uri + * @return void + */ + protected function httpDelete($uri) { + + if (!$this->broadcastEvent('beforeUnbind',array($uri))) return; + $this->tree->delete($uri); + + $this->httpResponse->sendStatus(204); + $this->httpResponse->setHeader('Content-Length','0'); + + } + + + /** + * WebDAV PROPFIND + * + * This WebDAV method requests information about an uri resource, or a list of resources + * If a client wants to receive the properties for a single resource it will add an HTTP Depth: header with a 0 value + * If the value is 1, it means that it also expects a list of sub-resources (e.g.: files in a directory) + * + * The request body contains an XML data structure that has a list of properties the client understands + * The response body is also an xml document, containing information about every uri resource and the requested properties + * + * It has to return a HTTP 207 Multi-status status code + * + * @param string $uri + * @return void + */ + protected function httpPropfind($uri) { + + // $xml = new Sabre_DAV_XMLReader(file_get_contents('php://input')); + $requestedProperties = $this->parsePropfindRequest($this->httpRequest->getBody(true)); + + $depth = $this->getHTTPDepth(1); + // The only two options for the depth of a propfind is 0 or 1 + if ($depth!=0) $depth = 1; + + $newProperties = $this->getPropertiesForPath($uri,$requestedProperties,$depth); + + // This is a multi-status response + $this->httpResponse->sendStatus(207); + $this->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8'); + + // Normally this header is only needed for OPTIONS responses, however.. + // iCal seems to also depend on these being set for PROPFIND. Since + // this is not harmful, we'll add it. + $features = array('1','3', 'extended-mkcol'); + foreach($this->plugins as $plugin) $features = array_merge($features,$plugin->getFeatures()); + $this->httpResponse->setHeader('DAV',implode(', ',$features)); + + $data = $this->generateMultiStatus($newProperties); + $this->httpResponse->sendBody($data); + + } + + /** + * WebDAV PROPPATCH + * + * This method is called to update properties on a Node. The request is an XML body with all the mutations. + * In this XML body it is specified which properties should be set/updated and/or deleted + * + * @param string $uri + * @return void + */ + protected function httpPropPatch($uri) { + + $newProperties = $this->parsePropPatchRequest($this->httpRequest->getBody(true)); + + $result = $this->updateProperties($uri, $newProperties); + + $this->httpResponse->sendStatus(207); + $this->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8'); + + $this->httpResponse->sendBody( + $this->generateMultiStatus(array($result)) + ); + + } + + /** + * HTTP PUT method + * + * This HTTP method updates a file, or creates a new one. + * + * If a new resource was created, a 201 Created status code should be returned. If an existing resource is updated, it's a 200 Ok + * + * @param string $uri + * @return void + */ + protected function httpPut($uri) { + + $body = $this->httpRequest->getBody(); + + // Intercepting Content-Range + if ($this->httpRequest->getHeader('Content-Range')) { + /** + Content-Range is dangerous for PUT requests: PUT per definition + stores a full resource. draft-ietf-httpbis-p2-semantics-15 says + in section 7.6: + An origin server SHOULD reject any PUT request that contains a + Content-Range header field, since it might be misinterpreted as + partial content (or might be partial content that is being mistakenly + PUT as a full representation). Partial content updates are possible + by targeting a separately identified resource with state that + overlaps a portion of the larger resource, or by using a different + method that has been specifically defined for partial updates (for + example, the PATCH method defined in [RFC5789]). + This clarifies RFC2616 section 9.6: + The recipient of the entity MUST NOT ignore any Content-* + (e.g. Content-Range) headers that it does not understand or implement + and MUST return a 501 (Not Implemented) response in such cases. + OTOH is a PUT request with a Content-Range currently the only way to + continue an aborted upload request and is supported by curl, mod_dav, + Tomcat and others. Since some clients do use this feature which results + in unexpected behaviour (cf PEAR::HTTP_WebDAV_Client 1.0.1), we reject + all PUT requests with a Content-Range for now. + */ + + throw new Sabre_DAV_Exception_NotImplemented('PUT with Content-Range is not allowed.'); + } + + // Intercepting the Finder problem + if (($expected = $this->httpRequest->getHeader('X-Expected-Entity-Length')) && $expected > 0) { + + /** + Many webservers will not cooperate well with Finder PUT requests, + because it uses 'Chunked' transfer encoding for the request body. + + The symptom of this problem is that Finder sends files to the + server, but they arrive as 0-lenght files in PHP. + + If we don't do anything, the user might think they are uploading + files successfully, but they end up empty on the server. Instead, + we throw back an error if we detect this. + + The reason Finder uses Chunked, is because it thinks the files + might change as it's being uploaded, and therefore the + Content-Length can vary. + + Instead it sends the X-Expected-Entity-Length header with the size + of the file at the very start of the request. If this header is set, + but we don't get a request body we will fail the request to + protect the end-user. + */ + + // Only reading first byte + $firstByte = fread($body,1); + if (strlen($firstByte)!==1) { + throw new Sabre_DAV_Exception_Forbidden('This server is not compatible with OS/X finder. Consider using a different WebDAV client or webserver.'); + } + + // The body needs to stay intact, so we copy everything to a + // temporary stream. + + $newBody = fopen('php://temp','r+'); + fwrite($newBody,$firstByte); + stream_copy_to_stream($body, $newBody); + rewind($newBody); + + $body = $newBody; + + } + + if ($this->tree->nodeExists($uri)) { + + $node = $this->tree->getNodeForPath($uri); + + // Checking If-None-Match and related headers. + if (!$this->checkPreconditions()) return; + + // If the node is a collection, we'll deny it + if (!($node instanceof Sabre_DAV_IFile)) throw new Sabre_DAV_Exception_Conflict('PUT is not allowed on non-files.'); + if (!$this->broadcastEvent('beforeWriteContent',array($this->getRequestUri()))) return false; + + $node->put($body); + $this->httpResponse->setHeader('Content-Length','0'); + $this->httpResponse->sendStatus(204); + + } else { + + // If we got here, the resource didn't exist yet. + if (!$this->createFile($this->getRequestUri(),$body)) { + // For one reason or another the file was not created. + return; + } + $this->httpResponse->setHeader('Content-Length','0'); + $this->httpResponse->sendStatus(201); + + } + + } + + + /** + * WebDAV MKCOL + * + * The MKCOL method is used to create a new collection (directory) on the server + * + * @param string $uri + * @return void + */ + protected function httpMkcol($uri) { + + $requestBody = $this->httpRequest->getBody(true); + + if ($requestBody) { + + $contentType = $this->httpRequest->getHeader('Content-Type'); + if (strpos($contentType,'application/xml')!==0 && strpos($contentType,'text/xml')!==0) { + + // We must throw 415 for unsupport mkcol bodies + throw new Sabre_DAV_Exception_UnsupportedMediaType('The request body for the MKCOL request must have an xml Content-Type'); + + } + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($requestBody); + if (Sabre_DAV_XMLUtil::toClarkNotation($dom->firstChild)!=='{DAV:}mkcol') { + + // We must throw 415 for unsupport mkcol bodies + throw new Sabre_DAV_Exception_UnsupportedMediaType('The request body for the MKCOL request must be a {DAV:}mkcol request construct.'); + + } + + $properties = array(); + foreach($dom->firstChild->childNodes as $childNode) { + + if (Sabre_DAV_XMLUtil::toClarkNotation($childNode)!=='{DAV:}set') continue; + $properties = array_merge($properties, Sabre_DAV_XMLUtil::parseProperties($childNode, $this->propertyMap)); + + } + if (!isset($properties['{DAV:}resourcetype'])) + throw new Sabre_DAV_Exception_BadRequest('The mkcol request must include a {DAV:}resourcetype property'); + + $resourceType = $properties['{DAV:}resourcetype']->getValue(); + unset($properties['{DAV:}resourcetype']); + + } else { + + $properties = array(); + $resourceType = array('{DAV:}collection'); + + } + + $result = $this->createCollection($uri, $resourceType, $properties); + + if (is_array($result)) { + $this->httpResponse->sendStatus(207); + $this->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8'); + + $this->httpResponse->sendBody( + $this->generateMultiStatus(array($result)) + ); + + } else { + $this->httpResponse->setHeader('Content-Length','0'); + $this->httpResponse->sendStatus(201); + } + + } + + /** + * WebDAV HTTP MOVE method + * + * This method moves one uri to a different uri. A lot of the actual request processing is done in getCopyMoveInfo + * + * @param string $uri + * @return void + */ + protected function httpMove($uri) { + + $moveInfo = $this->getCopyAndMoveInfo(); + + // If the destination is part of the source tree, we must fail + if ($moveInfo['destination']==$uri) + throw new Sabre_DAV_Exception_Forbidden('Source and destination uri are identical.'); + + if ($moveInfo['destinationExists']) { + + if (!$this->broadcastEvent('beforeUnbind',array($moveInfo['destination']))) return false; + $this->tree->delete($moveInfo['destination']); + + } + + if (!$this->broadcastEvent('beforeUnbind',array($uri))) return false; + if (!$this->broadcastEvent('beforeBind',array($moveInfo['destination']))) return false; + $this->tree->move($uri,$moveInfo['destination']); + $this->broadcastEvent('afterBind',array($moveInfo['destination'])); + + // If a resource was overwritten we should send a 204, otherwise a 201 + $this->httpResponse->setHeader('Content-Length','0'); + $this->httpResponse->sendStatus($moveInfo['destinationExists']?204:201); + + } + + /** + * WebDAV HTTP COPY method + * + * This method copies one uri to a different uri, and works much like the MOVE request + * A lot of the actual request processing is done in getCopyMoveInfo + * + * @param string $uri + * @return void + */ + protected function httpCopy($uri) { + + $copyInfo = $this->getCopyAndMoveInfo(); + // If the destination is part of the source tree, we must fail + if ($copyInfo['destination']==$uri) + throw new Sabre_DAV_Exception_Forbidden('Source and destination uri are identical.'); + + if ($copyInfo['destinationExists']) { + if (!$this->broadcastEvent('beforeUnbind',array($copyInfo['destination']))) return false; + $this->tree->delete($copyInfo['destination']); + + } + if (!$this->broadcastEvent('beforeBind',array($copyInfo['destination']))) return false; + $this->tree->copy($uri,$copyInfo['destination']); + $this->broadcastEvent('afterBind',array($copyInfo['destination'])); + + // If a resource was overwritten we should send a 204, otherwise a 201 + $this->httpResponse->setHeader('Content-Length','0'); + $this->httpResponse->sendStatus($copyInfo['destinationExists']?204:201); + + } + + + + /** + * HTTP REPORT method implementation + * + * Although the REPORT method is not part of the standard WebDAV spec (it's from rfc3253) + * It's used in a lot of extensions, so it made sense to implement it into the core. + * + * @param string $uri + * @return void + */ + protected function httpReport($uri) { + + $body = $this->httpRequest->getBody(true); + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($body); + + $reportName = Sabre_DAV_XMLUtil::toClarkNotation($dom->firstChild); + + if ($this->broadcastEvent('report',array($reportName,$dom, $uri))) { + + // If broadcastEvent returned true, it means the report was not supported + throw new Sabre_DAV_Exception_ReportNotImplemented(); + + } + + } + + // }}} + // {{{ HTTP/WebDAV protocol helpers + + /** + * Returns an array with all the supported HTTP methods for a specific uri. + * + * @param string $uri + * @return array + */ + public function getAllowedMethods($uri) { + + $methods = array( + 'OPTIONS', + 'GET', + 'HEAD', + 'DELETE', + 'PROPFIND', + 'PUT', + 'PROPPATCH', + 'COPY', + 'MOVE', + 'REPORT' + ); + + // The MKCOL is only allowed on an unmapped uri + try { + $node = $this->tree->getNodeForPath($uri); + } catch (Sabre_DAV_Exception_FileNotFound $e) { + $methods[] = 'MKCOL'; + } + + // We're also checking if any of the plugins register any new methods + foreach($this->plugins as $plugin) $methods = array_merge($methods,$plugin->getHTTPMethods($uri)); + array_unique($methods); + + return $methods; + + } + + /** + * Gets the uri for the request, keeping the base uri into consideration + * + * @return string + */ + public function getRequestUri() { + + return $this->calculateUri($this->httpRequest->getUri()); + + } + + /** + * Calculates the uri for a request, making sure that the base uri is stripped out + * + * @param string $uri + * @throws Sabre_DAV_Exception_Forbidden A permission denied exception is thrown whenever there was an attempt to supply a uri outside of the base uri + * @return string + */ + public function calculateUri($uri) { + + if ($uri[0]!='/' && strpos($uri,'://')) { + + $uri = parse_url($uri,PHP_URL_PATH); + + } + + $uri = str_replace('//','/',$uri); + + if (strpos($uri,$this->getBaseUri())===0) { + + return trim(Sabre_DAV_URLUtil::decodePath(substr($uri,strlen($this->getBaseUri()))),'/'); + + // A special case, if the baseUri was accessed without a trailing + // slash, we'll accept it as well. + } elseif ($uri.'/' === $this->getBaseUri()) { + + return ''; + + } else { + + throw new Sabre_DAV_Exception_Forbidden('Requested uri (' . $uri . ') is out of base uri (' . $this->getBaseUri() . ')'); + + } + + } + + /** + * Returns the HTTP depth header + * + * This method returns the contents of the HTTP depth request header. If the depth header was 'infinity' it will return the Sabre_DAV_Server::DEPTH_INFINITY object + * It is possible to supply a default depth value, which is used when the depth header has invalid content, or is completely non-existant + * + * @param mixed $default + * @return int + */ + public function getHTTPDepth($default = self::DEPTH_INFINITY) { + + // If its not set, we'll grab the default + $depth = $this->httpRequest->getHeader('Depth'); + + if (is_null($depth)) return $default; + + if ($depth == 'infinity') return self::DEPTH_INFINITY; + + + // If its an unknown value. we'll grab the default + if (!ctype_digit($depth)) return $default; + + return (int)$depth; + + } + + /** + * Returns the HTTP range header + * + * This method returns null if there is no well-formed HTTP range request + * header or array($start, $end). + * + * The first number is the offset of the first byte in the range. + * The second number is the offset of the last byte in the range. + * + * If the second offset is null, it should be treated as the offset of the last byte of the entity + * If the first offset is null, the second offset should be used to retrieve the last x bytes of the entity + * + * return $mixed + */ + public function getHTTPRange() { + + $range = $this->httpRequest->getHeader('range'); + if (is_null($range)) return null; + + // Matching "Range: bytes=1234-5678: both numbers are optional + + if (!preg_match('/^bytes=([0-9]*)-([0-9]*)$/i',$range,$matches)) return null; + + if ($matches[1]==='' && $matches[2]==='') return null; + + return array( + $matches[1]!==''?$matches[1]:null, + $matches[2]!==''?$matches[2]:null, + ); + + } + + + /** + * Returns information about Copy and Move requests + * + * This function is created to help getting information about the source and the destination for the + * WebDAV MOVE and COPY HTTP request. It also validates a lot of information and throws proper exceptions + * + * The returned value is an array with the following keys: + * * destination - Destination path + * * destinationExists - Wether or not the destination is an existing url (and should therefore be overwritten) + * + * @return array + */ + public function getCopyAndMoveInfo() { + + // Collecting the relevant HTTP headers + if (!$this->httpRequest->getHeader('Destination')) throw new Sabre_DAV_Exception_BadRequest('The destination header was not supplied'); + $destination = $this->calculateUri($this->httpRequest->getHeader('Destination')); + $overwrite = $this->httpRequest->getHeader('Overwrite'); + if (!$overwrite) $overwrite = 'T'; + if (strtoupper($overwrite)=='T') $overwrite = true; + elseif (strtoupper($overwrite)=='F') $overwrite = false; + // We need to throw a bad request exception, if the header was invalid + else throw new Sabre_DAV_Exception_BadRequest('The HTTP Overwrite header should be either T or F'); + + list($destinationDir) = Sabre_DAV_URLUtil::splitPath($destination); + + try { + $destinationParent = $this->tree->getNodeForPath($destinationDir); + if (!($destinationParent instanceof Sabre_DAV_ICollection)) throw new Sabre_DAV_Exception_UnsupportedMediaType('The destination node is not a collection'); + } catch (Sabre_DAV_Exception_FileNotFound $e) { + + // If the destination parent node is not found, we throw a 409 + throw new Sabre_DAV_Exception_Conflict('The destination node is not found'); + } + + try { + + $destinationNode = $this->tree->getNodeForPath($destination); + + // If this succeeded, it means the destination already exists + // we'll need to throw precondition failed in case overwrite is false + if (!$overwrite) throw new Sabre_DAV_Exception_PreconditionFailed('The destination node already exists, and the overwrite header is set to false','Overwrite'); + + } catch (Sabre_DAV_Exception_FileNotFound $e) { + + // Destination didn't exist, we're all good + $destinationNode = false; + + + + } + + // These are the three relevant properties we need to return + return array( + 'destination' => $destination, + 'destinationExists' => $destinationNode==true, + 'destinationNode' => $destinationNode, + ); + + } + + /** + * Returns a list of properties for a path + * + * This is a simplified version getPropertiesForPath. + * if you aren't interested in status codes, but you just + * want to have a flat list of properties. Use this method. + * + * @param string $path + * @param array $propertyNames + */ + public function getProperties($path, $propertyNames) { + + $result = $this->getPropertiesForPath($path,$propertyNames,0); + return $result[0][200]; + + } + + /** + * Returns a list of HTTP headers for a particular resource + * + * The generated http headers are based on properties provided by the + * resource. The method basically provides a simple mapping between + * DAV property and HTTP header. + * + * The headers are intended to be used for HEAD and GET requests. + * + * @param string $path + */ + public function getHTTPHeaders($path) { + + $propertyMap = array( + '{DAV:}getcontenttype' => 'Content-Type', + '{DAV:}getcontentlength' => 'Content-Length', + '{DAV:}getlastmodified' => 'Last-Modified', + '{DAV:}getetag' => 'ETag', + ); + + $properties = $this->getProperties($path,array_keys($propertyMap)); + + $headers = array(); + foreach($propertyMap as $property=>$header) { + if (!isset($properties[$property])) continue; + + if (is_scalar($properties[$property])) { + $headers[$header] = $properties[$property]; + + // GetLastModified gets special cased + } elseif ($properties[$property] instanceof Sabre_DAV_Property_GetLastModified) { + $headers[$header] = $properties[$property]->getTime()->format(DateTime::RFC1123); + } + + } + + return $headers; + + } + + /** + * Returns a list of properties for a given path + * + * The path that should be supplied should have the baseUrl stripped out + * The list of properties should be supplied in Clark notation. If the list is empty + * 'allprops' is assumed. + * + * If a depth of 1 is requested child elements will also be returned. + * + * @param string $path + * @param array $propertyNames + * @param int $depth + * @return array + */ + public function getPropertiesForPath($path,$propertyNames = array(),$depth = 0) { + + if ($depth!=0) $depth = 1; + + $returnPropertyList = array(); + + $parentNode = $this->tree->getNodeForPath($path); + $nodes = array( + $path => $parentNode + ); + if ($depth==1 && $parentNode instanceof Sabre_DAV_ICollection) { + foreach($this->tree->getChildren($path) as $childNode) + $nodes[$path . '/' . $childNode->getName()] = $childNode; + } + + // If the propertyNames array is empty, it means all properties are requested. + // We shouldn't actually return everything we know though, and only return a + // sensible list. + $allProperties = count($propertyNames)==0; + + foreach($nodes as $myPath=>$node) { + + $currentPropertyNames = $propertyNames; + + $newProperties = array( + '200' => array(), + '404' => array(), + ); + + if ($allProperties) { + // Default list of propertyNames, when all properties were requested. + $currentPropertyNames = array( + '{DAV:}getlastmodified', + '{DAV:}getcontentlength', + '{DAV:}resourcetype', + '{DAV:}quota-used-bytes', + '{DAV:}quota-available-bytes', + '{DAV:}getetag', + '{DAV:}getcontenttype', + ); + } + + // If the resourceType was not part of the list, we manually add it + // and mark it for removal. We need to know the resourcetype in order + // to make certain decisions about the entry. + // WebDAV dictates we should add a / and the end of href's for collections + $removeRT = false; + if (!in_array('{DAV:}resourcetype',$currentPropertyNames)) { + $currentPropertyNames[] = '{DAV:}resourcetype'; + $removeRT = true; + } + + $result = $this->broadcastEvent('beforeGetProperties',array($myPath, $node, &$currentPropertyNames, &$newProperties)); + // If this method explicitly returned false, we must ignore this + // node as it is inacessible. + if ($result===false) continue; + + if (count($currentPropertyNames) > 0) { + + if ($node instanceof Sabre_DAV_IProperties) + $newProperties['200'] = $newProperties[200] + $node->getProperties($currentPropertyNames); + + } + + + foreach($currentPropertyNames as $prop) { + + if (isset($newProperties[200][$prop])) continue; + + switch($prop) { + case '{DAV:}getlastmodified' : if ($node->getLastModified()) $newProperties[200][$prop] = new Sabre_DAV_Property_GetLastModified($node->getLastModified()); break; + case '{DAV:}getcontentlength' : if ($node instanceof Sabre_DAV_IFile) $newProperties[200][$prop] = (int)$node->getSize(); break; + case '{DAV:}quota-used-bytes' : + if ($node instanceof Sabre_DAV_IQuota) { + $quotaInfo = $node->getQuotaInfo(); + $newProperties[200][$prop] = $quotaInfo[0]; + } + break; + case '{DAV:}quota-available-bytes' : + if ($node instanceof Sabre_DAV_IQuota) { + $quotaInfo = $node->getQuotaInfo(); + $newProperties[200][$prop] = $quotaInfo[1]; + } + break; + case '{DAV:}getetag' : if ($node instanceof Sabre_DAV_IFile && $etag = $node->getETag()) $newProperties[200][$prop] = $etag; break; + case '{DAV:}getcontenttype' : if ($node instanceof Sabre_DAV_IFile && $ct = $node->getContentType()) $newProperties[200][$prop] = $ct; break; + case '{DAV:}supported-report-set' : + $reports = array(); + foreach($this->plugins as $plugin) { + $reports = array_merge($reports, $plugin->getSupportedReportSet($myPath)); + } + $newProperties[200][$prop] = new Sabre_DAV_Property_SupportedReportSet($reports); + break; + case '{DAV:}resourcetype' : + $newProperties[200]['{DAV:}resourcetype'] = new Sabre_DAV_Property_ResourceType(); + foreach($this->resourceTypeMapping as $className => $resourceType) { + if ($node instanceof $className) $newProperties[200]['{DAV:}resourcetype']->add($resourceType); + } + break; + + } + + // If we were unable to find the property, we will list it as 404. + if (!$allProperties && !isset($newProperties[200][$prop])) $newProperties[404][$prop] = null; + + } + + $this->broadcastEvent('afterGetProperties',array(trim($myPath,'/'),&$newProperties)); + + $newProperties['href'] = trim($myPath,'/'); + + // Its is a WebDAV recommendation to add a trailing slash to collectionnames. + // Apple's iCal also requires a trailing slash for principals (rfc 3744). + // Therefore we add a trailing / for any non-file. This might need adjustments + // if we find there are other edge cases. + if ($myPath!='' && isset($newProperties[200]['{DAV:}resourcetype']) && count($newProperties[200]['{DAV:}resourcetype']->getValue())>0) $newProperties['href'] .='/'; + + // If the resourcetype property was manually added to the requested property list, + // we will remove it again. + if ($removeRT) unset($newProperties[200]['{DAV:}resourcetype']); + + $returnPropertyList[] = $newProperties; + + } + + return $returnPropertyList; + + } + + /** + * This method is invoked by sub-systems creating a new file. + * + * Currently this is done by HTTP PUT and HTTP LOCK (in the Locks_Plugin). + * It was important to get this done through a centralized function, + * allowing plugins to intercept this using the beforeCreateFile event. + * + * This method will return true if the file was actually created + * + * @param string $uri + * @param resource $data + * @return bool + */ + public function createFile($uri,$data) { + + list($dir,$name) = Sabre_DAV_URLUtil::splitPath($uri); + + if (!$this->broadcastEvent('beforeBind',array($uri))) return false; + if (!$this->broadcastEvent('beforeCreateFile',array($uri,$data))) return false; + + $parent = $this->tree->getNodeForPath($dir); + $parent->createFile($name,$data); + $this->tree->markDirty($dir); + + $this->broadcastEvent('afterBind',array($uri)); + + return true; + } + + /** + * This method is invoked by sub-systems creating a new directory. + * + * @param string $uri + * @return void + */ + public function createDirectory($uri) { + + $this->createCollection($uri,array('{DAV:}collection'),array()); + + } + + /** + * Use this method to create a new collection + * + * The {DAV:}resourcetype is specified using the resourceType array. + * At the very least it must contain {DAV:}collection. + * + * The properties array can contain a list of additional properties. + * + * @param string $uri The new uri + * @param array $resourceType The resourceType(s) + * @param array $properties A list of properties + * @return void + */ + public function createCollection($uri, array $resourceType, array $properties) { + + list($parentUri,$newName) = Sabre_DAV_URLUtil::splitPath($uri); + + // Making sure {DAV:}collection was specified as resourceType + if (!in_array('{DAV:}collection', $resourceType)) { + throw new Sabre_DAV_Exception_InvalidResourceType('The resourceType for this collection must at least include {DAV:}collection'); + } + + + // Making sure the parent exists + try { + + $parent = $this->tree->getNodeForPath($parentUri); + + } catch (Sabre_DAV_Exception_FileNotFound $e) { + + throw new Sabre_DAV_Exception_Conflict('Parent node does not exist'); + + } + + // Making sure the parent is a collection + if (!$parent instanceof Sabre_DAV_ICollection) { + throw new Sabre_DAV_Exception_Conflict('Parent node is not a collection'); + } + + + + // Making sure the child does not already exist + try { + $parent->getChild($newName); + + // If we got here.. it means there's already a node on that url, and we need to throw a 405 + throw new Sabre_DAV_Exception_MethodNotAllowed('The resource you tried to create already exists'); + + } catch (Sabre_DAV_Exception_FileNotFound $e) { + // This is correct + } + + + if (!$this->broadcastEvent('beforeBind',array($uri))) return; + + // There are 2 modes of operation. The standard collection + // creates the directory, and then updates properties + // the extended collection can create it directly. + if ($parent instanceof Sabre_DAV_IExtendedCollection) { + + $parent->createExtendedCollection($newName, $resourceType, $properties); + + } else { + + // No special resourcetypes are supported + if (count($resourceType)>1) { + throw new Sabre_DAV_Exception_InvalidResourceType('The {DAV:}resourcetype you specified is not supported here.'); + } + + $parent->createDirectory($newName); + $rollBack = false; + $exception = null; + $errorResult = null; + + if (count($properties)>0) { + + try { + + $errorResult = $this->updateProperties($uri, $properties); + if (!isset($errorResult[200])) { + $rollBack = true; + } + + } catch (Sabre_DAV_Exception $e) { + + $rollBack = true; + $exception = $e; + + } + + } + + if ($rollBack) { + if (!$this->broadcastEvent('beforeUnbind',array($uri))) return; + $this->tree->delete($uri); + + // Re-throwing exception + if ($exception) throw $exception; + + return $errorResult; + } + + } + $this->tree->markDirty($parentUri); + $this->broadcastEvent('afterBind',array($uri)); + + } + + /** + * This method updates a resource's properties + * + * The properties array must be a list of properties. Array-keys are + * property names in clarknotation, array-values are it's values. + * If a property must be deleted, the value should be null. + * + * Note that this request should either completely succeed, or + * completely fail. + * + * The response is an array with statuscodes for keys, which in turn + * contain arrays with propertynames. This response can be used + * to generate a multistatus body. + * + * @param string $uri + * @param array $properties + * @return array + */ + public function updateProperties($uri, array $properties) { + + // we'll start by grabbing the node, this will throw the appropriate + // exceptions if it doesn't. + $node = $this->tree->getNodeForPath($uri); + + $result = array( + 200 => array(), + 403 => array(), + 424 => array(), + ); + $remainingProperties = $properties; + $hasError = false; + + // Running through all properties to make sure none of them are protected + if (!$hasError) foreach($properties as $propertyName => $value) { + if(in_array($propertyName, $this->protectedProperties)) { + $result[403][$propertyName] = null; + unset($remainingProperties[$propertyName]); + $hasError = true; + } + } + + if (!$hasError) { + // Allowing plugins to take care of property updating + $hasError = !$this->broadcastEvent('updateProperties',array( + &$remainingProperties, + &$result, + $node + )); + } + + // If the node is not an instance of Sabre_DAV_IProperties, every + // property is 403 Forbidden + if (!$hasError && count($remainingProperties) && !($node instanceof Sabre_DAV_IProperties)) { + $hasError = true; + foreach($properties as $propertyName=> $value) { + $result[403][$propertyName] = null; + } + $remainingProperties = array(); + } + + // Only if there were no errors we may attempt to update the resource + if (!$hasError) { + + if (count($remainingProperties)>0) { + + $updateResult = $node->updateProperties($remainingProperties); + + if ($updateResult===true) { + // success + foreach($remainingProperties as $propertyName=>$value) { + $result[200][$propertyName] = null; + } + + } elseif ($updateResult===false) { + // The node failed to update the properties for an + // unknown reason + foreach($remainingProperties as $propertyName=>$value) { + $result[403][$propertyName] = null; + } + + } elseif (is_array($updateResult)) { + + // The node has detailed update information + // We need to merge the results with the earlier results. + foreach($updateResult as $status => $props) { + if (is_array($props)) { + if (!isset($result[$status])) + $result[$status] = array(); + + $result[$status] = array_merge($result[$status], $updateResult[$status]); + } + } + + } else { + throw new Sabre_DAV_Exception('Invalid result from updateProperties'); + } + $remainingProperties = array(); + } + + } + + foreach($remainingProperties as $propertyName=>$value) { + // if there are remaining properties, it must mean + // there's a dependency failure + $result[424][$propertyName] = null; + } + + // Removing empty array values + foreach($result as $status=>$props) { + + if (count($props)===0) unset($result[$status]); + + } + $result['href'] = $uri; + return $result; + + } + + /** + * This method checks the main HTTP preconditions. + * + * Currently these are: + * * If-Match + * * If-None-Match + * * If-Modified-Since + * * If-Unmodified-Since + * + * The method will return true if all preconditions are met + * The method will return false, or throw an exception if preconditions + * failed. If false is returned the operation should be aborted, and + * the appropriate HTTP response headers are already set. + * + * Normally this method will throw 412 Precondition Failed for failures + * related to If-None-Match, If-Match and If-Unmodified Since. It will + * set the status to 304 Not Modified for If-Modified_since. + * + * If the $handleAsGET argument is set to true, it will also return 304 + * Not Modified for failure of the If-None-Match precondition. This is the + * desired behaviour for HTTP GET and HTTP HEAD requests. + * + * @return bool + */ + public function checkPreconditions($handleAsGET = false) { + + $uri = $this->getRequestUri(); + $node = null; + $lastMod = null; + $etag = null; + + if ($ifMatch = $this->httpRequest->getHeader('If-Match')) { + + // If-Match contains an entity tag. Only if the entity-tag + // matches we are allowed to make the request succeed. + // If the entity-tag is '*' we are only allowed to make the + // request succeed if a resource exists at that url. + try { + $node = $this->tree->getNodeForPath($uri); + } catch (Sabre_DAV_Exception_FileNotFound $e) { + throw new Sabre_DAV_Exception_PreconditionFailed('An If-Match header was specified and the resource did not exist','If-Match'); + } + + // Only need to check entity tags if they are not * + if ($ifMatch!=='*') { + + // There can be multiple etags + $ifMatch = explode(',',$ifMatch); + $haveMatch = false; + foreach($ifMatch as $ifMatchItem) { + + // Stripping any extra spaces + $ifMatchItem = trim($ifMatchItem,' '); + + $etag = $node->getETag(); + if ($etag===$ifMatchItem) { + $haveMatch = true; + } + } + if (!$haveMatch) { + throw new Sabre_DAV_Exception_PreconditionFailed('An If-Match header was specified, but none of the specified the ETags matched.','If-Match'); + } + } + } + + if ($ifNoneMatch = $this->httpRequest->getHeader('If-None-Match')) { + + // The If-None-Match header contains an etag. + // Only if the ETag does not match the current ETag, the request will succeed + // The header can also contain *, in which case the request + // will only succeed if the entity does not exist at all. + $nodeExists = true; + if (!$node) { + try { + $node = $this->tree->getNodeForPath($uri); + } catch (Sabre_DAV_Exception_FileNotFound $e) { + $nodeExists = false; + } + } + if ($nodeExists) { + $haveMatch = false; + if ($ifNoneMatch==='*') $haveMatch = true; + else { + + // There might be multiple etags + $ifNoneMatch = explode(',', $ifNoneMatch); + $etag = $node->getETag(); + + foreach($ifNoneMatch as $ifNoneMatchItem) { + + // Stripping any extra spaces + $ifNoneMatchItem = trim($ifNoneMatchItem,' '); + + if ($etag===$ifNoneMatchItem) $haveMatch = true; + + } + + } + + if ($haveMatch) { + if ($handleAsGET) { + $this->httpResponse->sendStatus(304); + return false; + } else { + throw new Sabre_DAV_Exception_PreconditionFailed('An If-None-Match header was specified, but the ETag matched (or * was specified).','If-None-Match'); + } + } + } + + } + + if (!$ifNoneMatch && ($ifModifiedSince = $this->httpRequest->getHeader('If-Modified-Since'))) { + + // The If-Modified-Since header contains a date. We + // will only return the entity if it has been changed since + // that date. If it hasn't been changed, we return a 304 + // header + // Note that this header only has to be checked if there was no If-None-Match header + // as per the HTTP spec. + $date = Sabre_HTTP_Util::parseHTTPDate($ifModifiedSince); + + if ($date) { + if (is_null($node)) { + $node = $this->tree->getNodeForPath($uri); + } + $lastMod = $node->getLastModified(); + if ($lastMod) { + $lastMod = new DateTime('@' . $lastMod); + if ($lastMod <= $date) { + $this->httpResponse->sendStatus(304); + return false; + } + } + } + } + + if ($ifUnmodifiedSince = $this->httpRequest->getHeader('If-Unmodified-Since')) { + + // The If-Unmodified-Since will allow allow the request if the + // entity has not changed since the specified date. + $date = Sabre_HTTP_Util::parseHTTPDate($ifUnmodifiedSince); + + // We must only check the date if it's valid + if ($date) { + if (is_null($node)) { + $node = $this->tree->getNodeForPath($uri); + } + $lastMod = $node->getLastModified(); + if ($lastMod) { + $lastMod = new DateTime('@' . $lastMod); + if ($lastMod > $date) { + throw new Sabre_DAV_Exception_PreconditionFailed('An If-Unmodified-Since header was specified, but the entity has been changed since the specified date.','If-Unmodified-Since'); + } + } + } + + } + return true; + + } + + // }}} + // {{{ XML Readers & Writers + + + /** + * Generates a WebDAV propfind response body based on a list of nodes + * + * @param array $fileProperties The list with nodes + * @param array $requestedProperties The properties that should be returned + * @return string + */ + public function generateMultiStatus(array $fileProperties) { + + $dom = new DOMDocument('1.0','utf-8'); + //$dom->formatOutput = true; + $multiStatus = $dom->createElement('d:multistatus'); + $dom->appendChild($multiStatus); + + // Adding in default namespaces + foreach($this->xmlNamespaces as $namespace=>$prefix) { + + $multiStatus->setAttribute('xmlns:' . $prefix,$namespace); + + } + + foreach($fileProperties as $entry) { + + $href = $entry['href']; + unset($entry['href']); + + $response = new Sabre_DAV_Property_Response($href,$entry); + $response->serialize($this,$multiStatus); + + } + + return $dom->saveXML(); + + } + + /** + * This method parses a PropPatch request + * + * PropPatch changes the properties for a resource. This method + * returns a list of properties. + * + * The keys in the returned array contain the property name (e.g.: {DAV:}displayname, + * and the value contains the property value. If a property is to be removed the value + * will be null. + * + * @param string $body xml body + * @return array list of properties in need of updating or deletion + */ + public function parsePropPatchRequest($body) { + + //We'll need to change the DAV namespace declaration to something else in order to make it parsable + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($body); + + $newProperties = array(); + + foreach($dom->firstChild->childNodes as $child) { + + if ($child->nodeType !== XML_ELEMENT_NODE) continue; + + $operation = Sabre_DAV_XMLUtil::toClarkNotation($child); + + if ($operation!=='{DAV:}set' && $operation!=='{DAV:}remove') continue; + + $innerProperties = Sabre_DAV_XMLUtil::parseProperties($child, $this->propertyMap); + + foreach($innerProperties as $propertyName=>$propertyValue) { + + if ($operation==='{DAV:}remove') { + $propertyValue = null; + } + + $newProperties[$propertyName] = $propertyValue; + + } + + } + + return $newProperties; + + } + + /** + * This method parses the PROPFIND request and returns its information + * + * This will either be a list of properties, or an empty array; in which case + * an {DAV:}allprop was requested. + * + * @param string $body + * @return array + */ + public function parsePropFindRequest($body) { + + // If the propfind body was empty, it means IE is requesting 'all' properties + if (!$body) return array(); + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($body); + $elem = $dom->getElementsByTagNameNS('urn:DAV','propfind')->item(0); + return array_keys(Sabre_DAV_XMLUtil::parseProperties($elem)); + + } + + // }}} + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/ServerPlugin.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/ServerPlugin.php new file mode 100755 index 0000000..d268eb9 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/ServerPlugin.php @@ -0,0 +1,90 @@ +name = $name; + foreach($children as $child) { + + if (!($child instanceof Sabre_DAV_INode)) throw new Sabre_DAV_Exception('Only instances of Sabre_DAV_INode are allowed to be passed in the children argument'); + $this->addChild($child); + + } + + } + + /** + * Adds a new childnode to this collection + * + * @param Sabre_DAV_INode $child + * @return void + */ + public function addChild(Sabre_DAV_INode $child) { + + $this->children[$child->getName()] = $child; + + } + + /** + * Returns the name of the collection + * + * @return string + */ + public function getName() { + + return $this->name; + + } + + /** + * Returns a child object, by its name. + * + * This method makes use of the getChildren method to grab all the child nodes, and compares the name. + * Generally its wise to override this, as this can usually be optimized + * + * @param string $name + * @throws Sabre_DAV_Exception_FileNotFound + * @return Sabre_DAV_INode + */ + public function getChild($name) { + + if (isset($this->children[$name])) return $this->children[$name]; + throw new Sabre_DAV_Exception_FileNotFound('File not found: ' . $name . ' in \'' . $this->getName() . '\''); + + } + + /** + * Returns a list of children for this collection + * + * @return array + */ + public function getChildren() { + + return array_values($this->children); + + } + + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/SimpleDirectory.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/SimpleDirectory.php new file mode 100755 index 0000000..a82fb93 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/SimpleDirectory.php @@ -0,0 +1,21 @@ +name = $name; + $this->contents = $contents; + $this->mimeType = $mimeType; + + } + + /** + * Returns the node name for this file. + * + * This name is used to construct the url. + * + * @return string + */ + public function getName() { + + return $this->name; + + } + + /** + * Returns the data + * + * This method may either return a string or a readable stream resource + * + * @return mixed + */ + public function get() { + + return $this->contents; + + } + + /** + * Returns the size of the file, in bytes. + * + * @return int + */ + public function getSize() { + + return strlen($this->contents); + + } + + /** + * Returns the ETag for a file + * + * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. + * The ETag is an arbritrary string, but MUST be surrounded by double-quotes. + * + * Return null if the ETag can not effectively be determined + */ + public function getETag() { + + return '"' . md5($this->contents) . '"'; + + } + + /** + * Returns the mime-type for a file + * + * If null is returned, we'll assume application/octet-stream + */ + public function getContentType() { + + return $this->mimeType; + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/StringUtil.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/StringUtil.php new file mode 100755 index 0000000..c7036fd --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/StringUtil.php @@ -0,0 +1,91 @@ +dataDir = $dataDir; + + } + + /** + * Initialize the plugin + * + * This is called automatically be the Server class after this plugin is + * added with Sabre_DAV_Server::addPlugin() + * + * @param Sabre_DAV_Server $server + * @return void + */ + public function initialize(Sabre_DAV_Server $server) { + + $this->server = $server; + $server->subscribeEvent('beforeMethod',array($this,'beforeMethod')); + $server->subscribeEvent('beforeCreateFile',array($this,'beforeCreateFile')); + + } + + /** + * This method is called before any HTTP method handler + * + * This method intercepts any GET, DELETE, PUT and PROPFIND calls to + * filenames that are known to match the 'temporary file' regex. + * + * @param string $method + * @return bool + */ + public function beforeMethod($method, $uri) { + + if (!$tempLocation = $this->isTempFile($uri)) + return true; + + switch($method) { + case 'GET' : + return $this->httpGet($tempLocation); + case 'PUT' : + return $this->httpPut($tempLocation); + case 'PROPFIND' : + return $this->httpPropfind($tempLocation, $uri); + case 'DELETE' : + return $this->httpDelete($tempLocation); + } + return true; + + } + + /** + * This method is invoked if some subsystem creates a new file. + * + * This is used to deal with HTTP LOCK requests which create a new + * file. + * + * @param string $uri + * @param resource $data + * @return bool + */ + public function beforeCreateFile($uri,$data) { + + if ($tempPath = $this->isTempFile($uri)) { + + $hR = $this->server->httpResponse; + $hR->setHeader('X-Sabre-Temp','true'); + file_put_contents($tempPath,$data); + return false; + } + return true; + + } + + /** + * This method will check if the url matches the temporary file pattern + * if it does, it will return an path based on $this->dataDir for the + * temporary file storage. + * + * @param string $path + * @return boolean|string + */ + protected function isTempFile($path) { + + // We're only interested in the basename. + list(, $tempPath) = Sabre_DAV_URLUtil::splitPath($path); + + foreach($this->temporaryFilePatterns as $tempFile) { + + if (preg_match($tempFile,$tempPath)) { + return $this->dataDir . '/sabredav_' . md5($path) . '.tempfile'; + } + + } + + return false; + + } + + + /** + * This method handles the GET method for temporary files. + * If the file doesn't exist, it will return false which will kick in + * the regular system for the GET method. + * + * @param string $tempLocation + * @return bool + */ + public function httpGet($tempLocation) { + + if (!file_exists($tempLocation)) return true; + + $hR = $this->server->httpResponse; + $hR->setHeader('Content-Type','application/octet-stream'); + $hR->setHeader('Content-Length',filesize($tempLocation)); + $hR->setHeader('X-Sabre-Temp','true'); + $hR->sendStatus(200); + $hR->sendBody(fopen($tempLocation,'r')); + return false; + + } + + /** + * This method handles the PUT method. + * + * @param string $tempLocation + * @return bool + */ + public function httpPut($tempLocation) { + + $hR = $this->server->httpResponse; + $hR->setHeader('X-Sabre-Temp','true'); + + $newFile = !file_exists($tempLocation); + + if (!$newFile && ($this->server->httpRequest->getHeader('If-None-Match'))) { + throw new Sabre_DAV_Exception_PreconditionFailed('The resource already exists, and an If-None-Match header was supplied'); + } + + file_put_contents($tempLocation,$this->server->httpRequest->getBody()); + $hR->sendStatus($newFile?201:200); + return false; + + } + + /** + * This method handles the DELETE method. + * + * If the file didn't exist, it will return false, which will make the + * standard HTTP DELETE handler kick in. + * + * @param string $tempLocation + * @return bool + */ + public function httpDelete($tempLocation) { + + if (!file_exists($tempLocation)) return true; + + unlink($tempLocation); + $hR = $this->server->httpResponse; + $hR->setHeader('X-Sabre-Temp','true'); + $hR->sendStatus(204); + return false; + + } + + /** + * This method handles the PROPFIND method. + * + * It's a very lazy method, it won't bother checking the request body + * for which properties were requested, and just sends back a default + * set of properties. + * + * @param string $tempLocation + * @return void + */ + public function httpPropfind($tempLocation, $uri) { + + if (!file_exists($tempLocation)) return true; + + $hR = $this->server->httpResponse; + $hR->setHeader('X-Sabre-Temp','true'); + $hR->sendStatus(207); + $hR->setHeader('Content-Type','application/xml; charset=utf-8'); + + $requestedProps = $this->server->parsePropFindRequest($this->server->httpRequest->getBody(true)); + + $properties = array( + 'href' => $uri, + 200 => array( + '{DAV:}getlastmodified' => new Sabre_DAV_Property_GetLastModified(filemtime($tempLocation)), + '{DAV:}getcontentlength' => filesize($tempLocation), + '{DAV:}resourcetype' => new Sabre_DAV_Property_ResourceType(null), + '{'.Sabre_DAV_Server::NS_SABREDAV.'}tempFile' => true, + + ), + ); + + $data = $this->server->generateMultiStatus(array($properties)); + $hR->sendBody($data); + return false; + + } + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Tree.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Tree.php new file mode 100755 index 0000000..df89068 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Tree.php @@ -0,0 +1,192 @@ +getNodeForPath($path); + return true; + + } catch (Sabre_DAV_Exception_FileNotFound $e) { + + return false; + + } + + } + + /** + * Copies a file from path to another + * + * @param string $sourcePath The source location + * @param string $destinationPath The full destination path + * @return void + */ + public function copy($sourcePath, $destinationPath) { + + $sourceNode = $this->getNodeForPath($sourcePath); + + // grab the dirname and basename components + list($destinationDir, $destinationName) = Sabre_DAV_URLUtil::splitPath($destinationPath); + + $destinationParent = $this->getNodeForPath($destinationDir); + $this->copyNode($sourceNode,$destinationParent,$destinationName); + + $this->markDirty($destinationDir); + + } + + /** + * Moves a file from one location to another + * + * @param string $sourcePath The path to the file which should be moved + * @param string $destinationPath The full destination path, so not just the destination parent node + * @return int + */ + public function move($sourcePath, $destinationPath) { + + list($sourceDir, $sourceName) = Sabre_DAV_URLUtil::splitPath($sourcePath); + list($destinationDir, $destinationName) = Sabre_DAV_URLUtil::splitPath($destinationPath); + + if ($sourceDir===$destinationDir) { + $renameable = $this->getNodeForPath($sourcePath); + $renameable->setName($destinationName); + } else { + $this->copy($sourcePath,$destinationPath); + $this->getNodeForPath($sourcePath)->delete(); + } + $this->markDirty($sourceDir); + $this->markDirty($destinationDir); + + } + + /** + * Deletes a node from the tree + * + * @param string $path + * @return void + */ + public function delete($path) { + + $node = $this->getNodeForPath($path); + $node->delete(); + + list($parent) = Sabre_DAV_URLUtil::splitPath($path); + $this->markDirty($parent); + + } + + /** + * Returns a list of childnodes for a given path. + * + * @param string $path + * @return array + */ + public function getChildren($path) { + + $node = $this->getNodeForPath($path); + return $node->getChildren(); + + } + + /** + * This method is called with every tree update + * + * Examples of tree updates are: + * * node deletions + * * node creations + * * copy + * * move + * * renaming nodes + * + * If Tree classes implement a form of caching, this will allow + * them to make sure caches will be expired. + * + * If a path is passed, it is assumed that the entire subtree is dirty + * + * @param string $path + * @return void + */ + public function markDirty($path) { + + + } + + /** + * copyNode + * + * @param Sabre_DAV_INode $source + * @param Sabre_DAV_ICollection $destination + * @return void + */ + protected function copyNode(Sabre_DAV_INode $source,Sabre_DAV_ICollection $destinationParent,$destinationName = null) { + + if (!$destinationName) $destinationName = $source->getName(); + + if ($source instanceof Sabre_DAV_IFile) { + + $data = $source->get(); + + // If the body was a string, we need to convert it to a stream + if (is_string($data)) { + $stream = fopen('php://temp','r+'); + fwrite($stream,$data); + rewind($stream); + $data = $stream; + } + $destinationParent->createFile($destinationName,$data); + $destination = $destinationParent->getChild($destinationName); + + } elseif ($source instanceof Sabre_DAV_ICollection) { + + $destinationParent->createDirectory($destinationName); + + $destination = $destinationParent->getChild($destinationName); + foreach($source->getChildren() as $child) { + + $this->copyNode($child,$destination); + + } + + } + if ($source instanceof Sabre_DAV_IProperties && $destination instanceof Sabre_DAV_IProperties) { + + $props = $source->getProperties(array()); + $destination->updateProperties($props); + + } + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Tree/Filesystem.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Tree/Filesystem.php new file mode 100755 index 0000000..e7786b5 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/Tree/Filesystem.php @@ -0,0 +1,124 @@ +basePath = $basePath; + + } + + /** + * Returns a new node for the given path + * + * @param string $path + * @return void + */ + public function getNodeForPath($path) { + + $realPath = $this->getRealPath($path); + if (!file_exists($realPath)) throw new Sabre_DAV_Exception_FileNotFound('File at location ' . $realPath . ' not found'); + if (is_dir($realPath)) { + return new Sabre_DAV_FS_Directory($path); + } else { + return new Sabre_DAV_FS_File($path); + } + + } + + /** + * Returns the real filesystem path for a webdav url. + * + * @param string $publicPath + * @return string + */ + protected function getRealPath($publicPath) { + + return rtrim($this->basePath,'/') . '/' . trim($publicPath,'/'); + + } + + /** + * Copies a file or directory. + * + * This method must work recursively and delete the destination + * if it exists + * + * @param string $source + * @param string $destination + * @return void + */ + public function copy($source,$destination) { + + $source = $this->getRealPath($source); + $destination = $this->getRealPath($destination); + $this->realCopy($source,$destination); + + } + + /** + * Used by self::copy + * + * @param string $source + * @param string $destination + * @return void + */ + protected function realCopy($source,$destination) { + + if (is_file($source)) { + copy($source,$destination); + } else { + mkdir($destination); + foreach(scandir($source) as $subnode) { + + if ($subnode=='.' || $subnode=='..') continue; + $this->realCopy($source.'/'.$subnode,$destination.'/'.$subnode); + + } + } + + } + + /** + * Moves a file or directory recursively. + * + * If the destination exists, delete it first. + * + * @param string $source + * @param string $destination + * @return void + */ + public function move($source,$destination) { + + $source = $this->getRealPath($source); + $destination = $this->getRealPath($destination); + rename($source,$destination); + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/URLUtil.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/URLUtil.php new file mode 100755 index 0000000..b629bbb --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAV/URLUtil.php @@ -0,0 +1,125 @@ + + * will be returned as: + * {http://www.example.org}myelem + * + * This format is used throughout the SabreDAV sourcecode. + * Elements encoded with the urn:DAV namespace will + * be returned as if they were in the DAV: namespace. This is to avoid + * compatibility problems. + * + * This function will return null if a nodetype other than an Element is passed. + * + * @param DOMElement $dom + * @return string + */ + static function toClarkNotation(DOMNode $dom) { + + if ($dom->nodeType !== XML_ELEMENT_NODE) return null; + + // Mapping back to the real namespace, in case it was dav + if ($dom->namespaceURI=='urn:DAV') $ns = 'DAV:'; else $ns = $dom->namespaceURI; + + // Mapping to clark notation + return '{' . $ns . '}' . $dom->localName; + + } + + /** + * Parses a clark-notation string, and returns the namespace and element + * name components. + * + * If the string was invalid, it will throw an InvalidArgumentException. + * + * @param string $str + * @throws InvalidArgumentException + * @return array + */ + static function parseClarkNotation($str) { + + if (!preg_match('/^{([^}]*)}(.*)$/',$str,$matches)) { + throw new InvalidArgumentException('\'' . $str . '\' is not a valid clark-notation formatted string'); + } + + return array( + $matches[1], + $matches[2] + ); + + } + + /** + * This method takes an XML document (as string) and converts all instances of the + * DAV: namespace to urn:DAV + * + * This is unfortunately needed, because the DAV: namespace violates the xml namespaces + * spec, and causes the DOM to throw errors + */ + static function convertDAVNamespace($xmlDocument) { + + // This is used to map the DAV: namespace to urn:DAV. This is needed, because the DAV: + // namespace is actually a violation of the XML namespaces specification, and will cause errors + return preg_replace("/xmlns(:[A-Za-z0-9_]*)?=(\"|\')DAV:(\\2)/","xmlns\\1=\\2urn:DAV\\2",$xmlDocument); + + } + + /** + * This method provides a generic way to load a DOMDocument for WebDAV use. + * + * This method throws a Sabre_DAV_Exception_BadRequest exception for any xml errors. + * It does not preserve whitespace, and it converts the DAV: namespace to urn:DAV. + * + * @param string $xml + * @throws Sabre_DAV_Exception_BadRequest + * @return DOMDocument + */ + static function loadDOMDocument($xml) { + + if (empty($xml)) + throw new Sabre_DAV_Exception_BadRequest('Empty XML document sent'); + + // The BitKinex client sends xml documents as UTF-16. PHP 5.3.1 (and presumably lower) + // does not support this, so we must intercept this and convert to UTF-8. + if (substr($xml,0,12) === "\x3c\x00\x3f\x00\x78\x00\x6d\x00\x6c\x00\x20\x00") { + + // Note: the preceeding byte sequence is "]*)encoding="UTF-16"([^>]*)>|u','',$xml); + + } + + // Retaining old error setting + $oldErrorSetting = libxml_use_internal_errors(true); + + // Clearing any previous errors + libxml_clear_errors(); + + $dom = new DOMDocument(); + $dom->loadXML(self::convertDAVNamespace($xml),LIBXML_NOWARNING | LIBXML_NOERROR); + + // We don't generally care about any whitespace + $dom->preserveWhiteSpace = false; + + if ($error = libxml_get_last_error()) { + libxml_clear_errors(); + throw new Sabre_DAV_Exception_BadRequest('The request body had an invalid XML body. (message: ' . $error->message . ', errorcode: ' . $error->code . ', line: ' . $error->line . ')'); + } + + // Restoring old mechanism for error handling + if ($oldErrorSetting===false) libxml_use_internal_errors(false); + + return $dom; + + } + + /** + * Parses all WebDAV properties out of a DOM Element + * + * Generally WebDAV properties are encloded in {DAV:}prop elements. This + * method helps by going through all these and pulling out the actual + * propertynames, making them array keys and making the property values, + * well.. the array values. + * + * If no value was given (self-closing element) null will be used as the + * value. This is used in for example PROPFIND requests. + * + * Complex values are supported through the propertyMap argument. The + * propertyMap should have the clark-notation properties as it's keys, and + * classnames as values. + * + * When any of these properties are found, the unserialize() method will be + * (statically) called. The result of this method is used as the value. + * + * @param DOMElement $parentNode + * @param array $propertyMap + * @return array + */ + static function parseProperties(DOMElement $parentNode, array $propertyMap = array()) { + + $propList = array(); + foreach($parentNode->childNodes as $propNode) { + + if (Sabre_DAV_XMLUtil::toClarkNotation($propNode)!=='{DAV:}prop') continue; + + foreach($propNode->childNodes as $propNodeData) { + + /* If there are no elements in here, we actually get 1 text node, this special case is dedicated to netdrive */ + if ($propNodeData->nodeType != XML_ELEMENT_NODE) continue; + + $propertyName = Sabre_DAV_XMLUtil::toClarkNotation($propNodeData); + if (isset($propertyMap[$propertyName])) { + $propList[$propertyName] = call_user_func(array($propertyMap[$propertyName],'unserialize'),$propNodeData); + } else { + $propList[$propertyName] = $propNodeData->textContent; + } + } + + + } + return $propList; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/AbstractPrincipalCollection.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/AbstractPrincipalCollection.php new file mode 100755 index 0000000..e422b34 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/AbstractPrincipalCollection.php @@ -0,0 +1,121 @@ +principalPrefix = $principalPrefix; + $this->principalBackend = $principalBackend; + + } + + /** + * This method returns a node for a principal. + * + * The passed array contains principal information, and is guaranteed to + * at least contain a uri item. Other properties may or may not be + * supplied by the authentication backend. + * + * @param array $principalInfo + * @return Sabre_DAVACL_IPrincipal + */ + abstract function getChildForPrincipal(array $principalInfo); + + /** + * Returns the name of this collection. + * + * @return string + */ + public function getName() { + + list(,$name) = Sabre_DAV_URLUtil::splitPath($this->principalPrefix); + return $name; + + } + + /** + * Return the list of users + * + * @return void + */ + public function getChildren() { + + if ($this->disableListing) + throw new Sabre_DAV_Exception_MethodNotAllowed('Listing members of this collection is disabled'); + + $children = array(); + foreach($this->principalBackend->getPrincipalsByPrefix($this->principalPrefix) as $principalInfo) { + + $children[] = $this->getChildForPrincipal($principalInfo); + + + } + return $children; + + } + + /** + * Returns a child object, by its name. + * + * @param string $name + * @throws Sabre_DAV_Exception_FileNotFound + * @return Sabre_DAV_IPrincipal + */ + public function getChild($name) { + + $principalInfo = $this->principalBackend->getPrincipalByPath($this->principalPrefix . '/' . $name); + if (!$principalInfo) throw new Sabre_DAV_Exception_FileNotFound('Principal with name ' . $name . ' not found'); + return $this->getChildForPrincipal($principalInfo); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/AceConflict.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/AceConflict.php new file mode 100755 index 0000000..e898b8b --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/AceConflict.php @@ -0,0 +1,34 @@ +ownerDocument; + + $np = $doc->createElementNS('DAV:','d:no-ace-conflict'); + $errorNode->appendChild($np); + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/NeedPrivileges.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/NeedPrivileges.php new file mode 100755 index 0000000..8bc7b55 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/NeedPrivileges.php @@ -0,0 +1,80 @@ +uri = $uri; + $this->privileges = $privileges; + + } + + /** + * Adds in extra information in the xml response. + * + * This method adds the {DAV:}need-privileges element as defined in rfc3744 + * + * @param Sabre_DAV_Server $server + * @param DOMElement $errorNode + * @return void + */ + public function serialize(Sabre_DAV_Server $server,DOMElement $errorNode) { + + $doc = $errorNode->ownerDocument; + + $np = $doc->createElementNS('DAV:','d:need-privileges'); + $errorNode->appendChild($np); + + foreach($this->privileges as $privilege) { + + $resource = $doc->createElementNS('DAV:','d:resource'); + $np->appendChild($resource); + + $resource->appendChild($doc->createElementNS('DAV:','d:href',$server->getBaseUri() . $this->uri)); + + $priv = $doc->createElementNS('DAV:','d:privilege'); + $resource->appendChild($priv); + + preg_match('/^{([^}]*)}(.*)$/',$privilege,$privilegeParts); + $priv->appendChild($doc->createElementNS($privilegeParts[1],'d:' . $privilegeParts[2])); + + + } + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/NoAbstract.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/NoAbstract.php new file mode 100755 index 0000000..9bf1967 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/NoAbstract.php @@ -0,0 +1,34 @@ +ownerDocument; + + $np = $doc->createElementNS('DAV:','d:no-abstract'); + $errorNode->appendChild($np); + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/NotRecognizedPrincipal.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/NotRecognizedPrincipal.php new file mode 100755 index 0000000..b8ab5cf --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/NotRecognizedPrincipal.php @@ -0,0 +1,34 @@ +ownerDocument; + + $np = $doc->createElementNS('DAV:','d:recognized-principal'); + $errorNode->appendChild($np); + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/NotSupportedPrivilege.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/NotSupportedPrivilege.php new file mode 100755 index 0000000..7257dd1 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Exception/NotSupportedPrivilege.php @@ -0,0 +1,34 @@ +ownerDocument; + + $np = $doc->createElementNS('DAV:','d:not-supported-privilege'); + $errorNode->appendChild($np); + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/IACL.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/IACL.php new file mode 100755 index 0000000..e53d310 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/IACL.php @@ -0,0 +1,58 @@ +getCurrentUserPrivilegeSet($uri); + + if (is_null($acl)) { + if ($this->allowAccessToNodesWithoutACL) { + return true; + } else { + if ($throwExceptions) + throw new Sabre_DAVACL_Exception_NeedPrivileges($uri,$privileges); + else + return false; + + } + } + + $failed = array(); + foreach($privileges as $priv) { + + if (!in_array($priv, $acl)) { + $failed[] = $priv; + } + + } + + if ($failed) { + if ($throwExceptions) + throw new Sabre_DAVACL_Exception_NeedPrivileges($uri,$failed); + else + return false; + } + return true; + + } + + /** + * Returns the standard users' principal. + * + * This is one authorative principal url for the current user. + * This method will return null if the user wasn't logged in. + * + * @return string|null + */ + public function getCurrentUserPrincipal() { + + $authPlugin = $this->server->getPlugin('auth'); + if (is_null($authPlugin)) return null; + + $userName = $authPlugin->getCurrentUser(); + if (!$userName) return null; + + return $this->defaultUsernamePath . '/' . $userName; + + } + + /** + * Returns a list of principals that's associated to the current + * user, either directly or through group membership. + * + * @return array + */ + public function getCurrentUserPrincipals() { + + $currentUser = $this->getCurrentUserPrincipal(); + + if (is_null($currentUser)) return array(); + + $check = array($currentUser); + $principals = array($currentUser); + + while(count($check)) { + + $principal = array_shift($check); + + $node = $this->server->tree->getNodeForPath($principal); + if ($node instanceof Sabre_DAVACL_IPrincipal) { + foreach($node->getGroupMembership() as $groupMember) { + + if (!in_array($groupMember, $principals)) { + + $check[] = $groupMember; + $principals[] = $groupMember; + + } + + } + + } + + } + + return $principals; + + } + + /** + * Returns the supported privilege structure for this ACL plugin. + * + * See RFC3744 for more details. Currently we default on a simple, + * standard structure. + * + * @return array + */ + public function getSupportedPrivilegeSet() { + + return array( + 'privilege' => '{DAV:}all', + 'abstract' => true, + 'aggregates' => array( + array( + 'privilege' => '{DAV:}read', + 'aggregates' => array( + array( + 'privilege' => '{DAV:}read-acl', + 'abstract' => true, + ), + array( + 'privilege' => '{DAV:}read-current-user-privilege-set', + 'abstract' => true, + ), + ), + ), // {DAV:}read + array( + 'privilege' => '{DAV:}write', + 'aggregates' => array( + array( + 'privilege' => '{DAV:}write-acl', + 'abstract' => true, + ), + array( + 'privilege' => '{DAV:}write-properties', + 'abstract' => true, + ), + array( + 'privilege' => '{DAV:}write-content', + 'abstract' => true, + ), + array( + 'privilege' => '{DAV:}bind', + 'abstract' => true, + ), + array( + 'privilege' => '{DAV:}unbind', + 'abstract' => true, + ), + array( + 'privilege' => '{DAV:}unlock', + 'abstract' => true, + ), + ), + ), // {DAV:}write + ), + ); // {DAV:}all + + } + + /** + * Returns the supported privilege set as a flat list + * + * This is much easier to parse. + * + * The returned list will be index by privilege name. + * The value is a struct containing the following properties: + * - aggregates + * - abstract + * - concrete + * + * @return array + */ + final public function getFlatPrivilegeSet() { + + $privs = $this->getSupportedPrivilegeSet(); + + $flat = array(); + $this->getFPSTraverse($privs, null, $flat); + + return $flat; + + } + + /** + * Traverses the privilege set tree for reordering + * + * This function is solely used by getFlatPrivilegeSet, and would have been + * a closure if it wasn't for the fact I need to support PHP 5.2. + * + * @return void + */ + final private function getFPSTraverse($priv, $concrete, &$flat) { + + $myPriv = array( + 'privilege' => $priv['privilege'], + 'abstract' => isset($priv['abstract']) && $priv['abstract'], + 'aggregates' => array(), + 'concrete' => isset($priv['abstract']) && $priv['abstract']?$concrete:$priv['privilege'], + ); + + if (isset($priv['aggregates'])) + foreach($priv['aggregates'] as $subPriv) $myPriv['aggregates'][] = $subPriv['privilege']; + + $flat[$priv['privilege']] = $myPriv; + + if (isset($priv['aggregates'])) { + + foreach($priv['aggregates'] as $subPriv) { + + $this->getFPSTraverse($subPriv, $myPriv['concrete'], $flat); + + } + + } + + } + + /** + * Returns the full ACL list. + * + * Either a uri or a Sabre_DAV_INode may be passed. + * + * null will be returned if the node doesn't support ACLs. + * + * @param string|Sabre_DAV_INode $node + * @return array + */ + public function getACL($node) { + + if (is_string($node)) { + $node = $this->server->tree->getNodeForPath($node); + } + if ($node instanceof Sabre_DAVACL_IACL) { + return $node->getACL(); + } + return null; + + } + + /** + * Returns a list of privileges the current user has + * on a particular node. + * + * Either a uri or a Sabre_DAV_INode may be passed. + * + * null will be returned if the node doesn't support ACLs. + * + * @param string|Sabre_DAV_INode $node + * @return array + */ + public function getCurrentUserPrivilegeSet($node) { + + if (is_string($node)) { + $node = $this->server->tree->getNodeForPath($node); + } + + $acl = $this->getACL($node); + if (is_null($acl)) return null; + + $principals = $this->getCurrentUserPrincipals(); + + $collected = array(); + + foreach($acl as $ace) { + + if (in_array($ace['principal'], $principals)) { + $collected[] = $ace; + } + + } + + // Now we deduct all aggregated privileges. + $flat = $this->getFlatPrivilegeSet(); + + $collected2 = array(); + while(count($collected)) { + + $current = array_pop($collected); + $collected2[] = $current['privilege']; + + foreach($flat[$current['privilege']]['aggregates'] as $subPriv) { + $collected2[] = $subPriv; + $collected[] = $flat[$subPriv]; + } + + } + + return array_values(array_unique($collected2)); + + } + + /** + * Sets up the plugin + * + * This method is automatically called by the server class. + * + * @param Sabre_DAV_Server $server + * @return void + */ + public function initialize(Sabre_DAV_Server $server) { + + $this->server = $server; + $server->subscribeEvent('beforeGetProperties',array($this,'beforeGetProperties')); + + $server->subscribeEvent('beforeMethod', array($this,'beforeMethod'),20); + $server->subscribeEvent('beforeBind', array($this,'beforeBind'),20); + $server->subscribeEvent('beforeUnbind', array($this,'beforeUnbind'),20); + $server->subscribeEvent('updateProperties',array($this,'updateProperties')); + $server->subscribeEvent('beforeUnlock', array($this,'beforeUnlock'),20); + $server->subscribeEvent('report',array($this,'report')); + $server->subscribeEvent('unknownMethod', array($this, 'unknownMethod')); + + array_push($server->protectedProperties, + '{DAV:}alternate-URI-set', + '{DAV:}principal-URL', + '{DAV:}group-membership', + '{DAV:}principal-collection-set', + '{DAV:}current-user-principal', + '{DAV:}supported-privilege-set', + '{DAV:}current-user-privilege-set', + '{DAV:}acl', + '{DAV:}acl-restrictions', + '{DAV:}inherited-acl-set', + '{DAV:}owner', + '{DAV:}group' + ); + + // Automatically mapping nodes implementing IPrincipal to the + // {DAV:}principal resourcetype. + $server->resourceTypeMapping['Sabre_DAVACL_IPrincipal'] = '{DAV:}principal'; + + // Mapping the group-member-set property to the HrefList property + // class. + $server->propertyMap['{DAV:}group-member-set'] = 'Sabre_DAV_Property_HrefList'; + + } + + + /* {{{ Event handlers */ + + /** + * Triggered before any method is handled + * + * @param string $method + * @param string $uri + * @return void + */ + public function beforeMethod($method, $uri) { + + $exists = $this->server->tree->nodeExists($uri); + + // If the node doesn't exists, none of these checks apply + if (!$exists) return; + + switch($method) { + + case 'GET' : + case 'HEAD' : + case 'OPTIONS' : + // For these 3 we only need to know if the node is readable. + $this->checkPrivileges($uri,'{DAV:}read'); + break; + + case 'PUT' : + case 'LOCK' : + case 'UNLOCK' : + // This method requires the write-content priv if the node + // already exists, and bind on the parent if the node is being + // created. + // The bind privilege is handled in the beforeBind event. + $this->checkPrivileges($uri,'{DAV:}write-content'); + break; + + + case 'PROPPATCH' : + $this->checkPrivileges($uri,'{DAV:}write-properties'); + break; + + case 'ACL' : + $this->checkPrivileges($uri,'{DAV:}write-acl'); + break; + + case 'COPY' : + case 'MOVE' : + // Copy requires read privileges on the entire source tree. + // If the target exists write-content normally needs to be + // checked, however, we're deleting the node beforehand and + // creating a new one after, so this is handled by the + // beforeUnbind event. + // + // The creation of the new node is handled by the beforeBind + // event. + // + // If MOVE is used beforeUnbind will also be used to check if + // the sourcenode can be deleted. + $this->checkPrivileges($uri,'{DAV:}read',self::R_RECURSIVE); + + break; + + } + + } + + /** + * Triggered before a new node is created. + * + * This allows us to check permissions for any operation that creates a + * new node, such as PUT, MKCOL, MKCALENDAR, LOCK, COPY and MOVE. + * + * @param string $uri + * @return void + */ + public function beforeBind($uri) { + + list($parentUri,$nodeName) = Sabre_DAV_URLUtil::splitPath($uri); + $this->checkPrivileges($parentUri,'{DAV:}bind'); + + } + + /** + * Triggered before a node is deleted + * + * This allows us to check permissions for any operation that will delete + * an existing node. + * + * @param string $uri + * @return void + */ + public function beforeUnbind($uri) { + + list($parentUri,$nodeName) = Sabre_DAV_URLUtil::splitPath($uri); + $this->checkPrivileges($parentUri,'{DAV:}unbind',self::R_RECURSIVEPARENTS); + + } + + /** + * Triggered before a node is unlocked. + * + * @param string $uri + * @param Sabre_DAV_Locks_LockInfo $lock + * @TODO: not yet implemented + * @return void + */ + public function beforeUnlock($uri, Sabre_DAV_Locks_LockInfo $lock) { + + + } + + /** + * Triggered before properties are looked up in specific nodes. + * + * @param string $uri + * @param Sabre_DAV_INode $node + * @param array $requestedProperties + * @param array $returnedProperties + * @TODO really should be broken into multiple methods, or even a class. + * @return void + */ + public function beforeGetProperties($uri, Sabre_DAV_INode $node, &$requestedProperties, &$returnedProperties) { + + // Checking the read permission + if (!$this->checkPrivileges($uri,'{DAV:}read',self::R_PARENT,false)) { + + // User is not allowed to read properties + if ($this->hideNodesFromListings) { + return false; + } + + // Marking all requested properties as '403'. + foreach($requestedProperties as $key=>$requestedProperty) { + unset($requestedProperties[$key]); + $returnedProperties[403][$requestedProperty] = null; + } + return; + + } + + /* Adding principal properties */ + if ($node instanceof Sabre_DAVACL_IPrincipal) { + + if (false !== ($index = array_search('{DAV:}alternate-URI-set', $requestedProperties))) { + + unset($requestedProperties[$index]); + $returnedProperties[200]['{DAV:}alternate-URI-set'] = new Sabre_DAV_Property_HrefList($node->getAlternateUriSet()); + + } + if (false !== ($index = array_search('{DAV:}principal-URL', $requestedProperties))) { + + unset($requestedProperties[$index]); + $returnedProperties[200]['{DAV:}principal-URL'] = new Sabre_DAV_Property_Href($node->getPrincipalUrl() . '/'); + + } + if (false !== ($index = array_search('{DAV:}group-member-set', $requestedProperties))) { + + unset($requestedProperties[$index]); + $returnedProperties[200]['{DAV:}group-member-set'] = new Sabre_DAV_Property_HrefList($node->getGroupMemberSet()); + + } + if (false !== ($index = array_search('{DAV:}group-membership', $requestedProperties))) { + + unset($requestedProperties[$index]); + $returnedProperties[200]['{DAV:}group-membership'] = new Sabre_DAV_Property_HrefList($node->getGroupMembership()); + + } + + if (false !== ($index = array_search('{DAV:}displayname', $requestedProperties))) { + + $returnedProperties[200]['{DAV:}displayname'] = $node->getDisplayName(); + + } + + } + if (false !== ($index = array_search('{DAV:}principal-collection-set', $requestedProperties))) { + + unset($requestedProperties[$index]); + $val = $this->principalCollectionSet; + // Ensuring all collections end with a slash + foreach($val as $k=>$v) $val[$k] = $v . '/'; + $returnedProperties[200]['{DAV:}principal-collection-set'] = new Sabre_DAV_Property_HrefList($val); + + } + if (false !== ($index = array_search('{DAV:}current-user-principal', $requestedProperties))) { + + unset($requestedProperties[$index]); + if ($url = $this->getCurrentUserPrincipal()) { + $returnedProperties[200]['{DAV:}current-user-principal'] = new Sabre_DAVACL_Property_Principal(Sabre_DAVACL_Property_Principal::HREF, $url . '/'); + } else { + $returnedProperties[200]['{DAV:}current-user-principal'] = new Sabre_DAVACL_Property_Principal(Sabre_DAVACL_Property_Principal::UNAUTHENTICATED); + } + + } + if (false !== ($index = array_search('{DAV:}supported-privilege-set', $requestedProperties))) { + + unset($requestedProperties[$index]); + $returnedProperties[200]['{DAV:}supported-privilege-set'] = new Sabre_DAVACL_Property_SupportedPrivilegeSet($this->getSupportedPrivilegeSet()); + + } + if (false !== ($index = array_search('{DAV:}current-user-privilege-set', $requestedProperties))) { + + if (!$this->checkPrivileges($uri, '{DAV:}read-current-user-privilege-set', self::R_PARENT, false)) { + $returnedProperties[403]['{DAV:}current-user-privilege-set'] = null; + unset($requestedProperties[$index]); + } else { + $val = $this->getCurrentUserPrivilegeSet($node); + if (!is_null($val)) { + unset($requestedProperties[$index]); + $returnedProperties[200]['{DAV:}current-user-privilege-set'] = new Sabre_DAVACL_Property_CurrentUserPrivilegeSet($val); + } + } + + } + + /* The ACL property contains all the permissions */ + if (false !== ($index = array_search('{DAV:}acl', $requestedProperties))) { + + if (!$this->checkPrivileges($uri, '{DAV:}read-acl', self::R_PARENT, false)) { + + unset($requestedProperties[$index]); + $returnedProperties[403]['{DAV:}acl'] = null; + + } else { + + $acl = $this->getACL($node); + if (!is_null($acl)) { + unset($requestedProperties[$index]); + $returnedProperties[200]['{DAV:}acl'] = new Sabre_DAVACL_Property_Acl($this->getACL($node)); + } + + } + + } + + } + + /** + * This method intercepts PROPPATCH methods and make sure the + * group-member-set is updated correctly. + * + * @param array $propertyDelta + * @param array $result + * @param Sabre_DAV_INode $node + * @return void + */ + public function updateProperties(&$propertyDelta, &$result, Sabre_DAV_INode $node) { + + if (!array_key_exists('{DAV:}group-member-set', $propertyDelta)) + return; + + if (is_null($propertyDelta['{DAV:}group-member-set'])) { + $memberSet = array(); + } elseif ($propertyDelta['{DAV:}group-member-set'] instanceof Sabre_DAV_Property_HrefList) { + $memberSet = $propertyDelta['{DAV:}group-member-set']->getHrefs(); + } else { + throw new Sabre_DAV_Exception('The group-member-set property MUST be an instance of Sabre_DAV_Property_HrefList or null'); + } + + if (!($node instanceof Sabre_DAVACL_IPrincipal)) { + $result[403]['{DAV:}group-member-set'] = null; + unset($propertyDelta['{DAV:}group-member-set']); + + // Returning false will stop the updateProperties process + return false; + } + + $node->setGroupMemberSet($memberSet); + + $result[200]['{DAV:}group-member-set'] = null; + unset($propertyDelta['{DAV:}group-member-set']); + + } + + /** + * This method handels HTTP REPORT requests + * + * @param string $reportName + * @param DOMNode $dom + * @return void + */ + public function report($reportName, $dom) { + + switch($reportName) { + + case '{DAV:}principal-property-search' : + $this->principalPropertySearchReport($dom); + return false; + case '{DAV:}principal-search-property-set' : + $this->principalSearchPropertySetReport($dom); + return false; + case '{DAV:}expand-property' : + $this->expandPropertyReport($dom); + return false; + + } + + } + + /** + * This event is triggered for any HTTP method that is not known by the + * webserver. + * + * @param string $method + * @param string $uri + * @return void + */ + public function unknownMethod($method, $uri) { + + if ($method!=='ACL') return; + + $this->httpACL($uri); + return false; + + } + + /** + * This method is responsible for handling the 'ACL' event. + * + * @param string $uri + * @return void + */ + public function httpACL($uri) { + + $body = $this->server->httpRequest->getBody(true); + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($body); + + $newAcl = + Sabre_DAVACL_Property_Acl::unserialize($dom->firstChild) + ->getPrivileges(); + + // Normalizing urls + foreach($newAcl as $k=>$newAce) { + $newAcl[$k]['principal'] = $this->server->calculateUri($newAce['principal']); + } + + $node = $this->server->tree->getNodeForPath($uri); + + if (!($node instanceof Sabre_DAVACL_IACL)) { + throw new Sabre_DAV_Exception_MethodNotAllowed('This node does not support the ACL method'); + } + + $oldAcl = $this->getACL($node); + + $supportedPrivileges = $this->getFlatPrivilegeSet(); + + /* Checking if protected principals from the existing principal set are + not overwritten. */ + foreach($oldAcl as $k=>$oldAce) { + + if (!isset($oldAce['protected']) || !$oldAce['protected']) continue; + + $found = false; + foreach($newAcl as $newAce) { + if ( + $newAce['privilege'] === $oldAce['privilege'] && + $newAce['principal'] === $oldAce['principal'] && + $newAce['protected'] + ) + $found = true; + } + + if (!$found) + throw new Sabre_DAVACL_Exception_AceConflict('This resource contained a protected {DAV:}ace, but this privilege did not occur in the ACL request'); + + } + + foreach($newAcl as $k=>$newAce) { + + // Do we recognize the privilege + if (!isset($supportedPrivileges[$newAce['privilege']])) { + throw new Sabre_DAVACL_Exception_NotSupportedPrivilege('The privilege you specified (' . $newAce['privilege'] . ') is not recognized by this server'); + } + + if ($supportedPrivileges[$newAce['privilege']]['abstract']) { + throw new Sabre_DAVACL_Exception_NoAbstract('The privilege you specified (' . $newAce['privilege'] . ') is an abstract privilege'); + } + + // Looking up the principal + try { + $principal = $this->server->tree->getNodeForPath($newAce['principal']); + } catch (Sabre_DAV_Exception_FileNotFound $e) { + throw new Sabre_DAVACL_Exception_NotRecognizedPrincipal('The specified principal (' . $newAce['principal'] . ') does not exist'); + } + if (!($principal instanceof Sabre_DAVACL_IPrincipal)) { + throw new Sabre_DAVACL_Exception_NotRecognizedPrincipal('The specified uri (' . $newAce['principal'] . ') is not a principal'); + } + + } + $node->setACL($newAcl); + + } + + /* }}} */ + + /* Reports {{{ */ + + /** + * The expand-property report is defined in RFC3253 section 3-8. + * + * This report is very similar to a standard PROPFIND. The difference is + * that it has the additional ability to look at properties containing a + * {DAV:}href element, follow that property and grab additional elements + * there. + * + * Other rfc's, such as ACL rely on this report, so it made sense to put + * it in this plugin. + * + * @param DOMElement $dom + * @return void + */ + protected function expandPropertyReport($dom) { + + $requestedProperties = $this->parseExpandPropertyReportRequest($dom->firstChild->firstChild); + $depth = $this->server->getHTTPDepth(0); + $requestUri = $this->server->getRequestUri(); + + $result = $this->expandProperties($requestUri,$requestedProperties,$depth); + + $dom = new DOMDocument('1.0','utf-8'); + $dom->formatOutput = true; + $multiStatus = $dom->createElement('d:multistatus'); + $dom->appendChild($multiStatus); + + // Adding in default namespaces + foreach($this->server->xmlNamespaces as $namespace=>$prefix) { + + $multiStatus->setAttribute('xmlns:' . $prefix,$namespace); + + } + + foreach($result as $response) { + $response->serialize($this->server, $multiStatus); + } + + $xml = $dom->saveXML(); + $this->server->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8'); + $this->server->httpResponse->sendStatus(207); + $this->server->httpResponse->sendBody($xml); + + } + + /** + * This method is used by expandPropertyReport to parse + * out the entire HTTP request. + * + * @param DOMElement $node + * @return array + */ + protected function parseExpandPropertyReportRequest($node) { + + $requestedProperties = array(); + do { + + if (Sabre_DAV_XMLUtil::toClarkNotation($node)!=='{DAV:}property') continue; + + if ($node->firstChild) { + + $children = $this->parseExpandPropertyReportRequest($node->firstChild); + + } else { + + $children = array(); + + } + + $namespace = $node->getAttribute('namespace'); + if (!$namespace) $namespace = 'DAV:'; + + $propName = '{'.$namespace.'}' . $node->getAttribute('name'); + $requestedProperties[$propName] = $children; + + } while ($node = $node->nextSibling); + + return $requestedProperties; + + } + + /** + * This method expands all the properties and returns + * a list with property values + * + * @param array $path + * @param array $requestedProperties the list of required properties + * @param array $depth + */ + protected function expandProperties($path,array $requestedProperties,$depth) { + + $foundProperties = $this->server->getPropertiesForPath($path,array_keys($requestedProperties),$depth); + + $result = array(); + + foreach($foundProperties as $node) { + + foreach($requestedProperties as $propertyName=>$childRequestedProperties) { + + // We're only traversing if sub-properties were requested + if(count($childRequestedProperties)===0) continue; + + // We only have to do the expansion if the property was found + // and it contains an href element. + if (!array_key_exists($propertyName,$node[200])) continue; + + if ($node[200][$propertyName] instanceof Sabre_DAV_Property_IHref) { + $hrefs = array($node[200][$propertyName]->getHref()); + } elseif ($node[200][$propertyName] instanceof Sabre_DAV_Property_HrefList) { + $hrefs = $node[200][$propertyName]->getHrefs(); + } + + $childProps = array(); + foreach($hrefs as $href) { + $childProps = array_merge($childProps, $this->expandProperties($href,$childRequestedProperties,0)); + } + $node[200][$propertyName] = new Sabre_DAV_Property_ResponseList($childProps); + + } + $result[] = new Sabre_DAV_Property_Response($path, $node); + + } + + return $result; + + } + + /** + * principalSearchPropertySetReport + * + * This method responsible for handing the + * {DAV:}principal-search-property-set report. This report returns a list + * of properties the client may search on, using the + * {DAV:}principal-property-search report. + * + * @param DOMDocument $dom + * @return void + */ + protected function principalSearchPropertySetReport(DOMDocument $dom) { + + $searchProperties = array( + '{DAV:}displayname' => 'display name' + ); + + $httpDepth = $this->server->getHTTPDepth(0); + if ($httpDepth!==0) { + throw new Sabre_DAV_Exception_BadRequest('This report is only defined when Depth: 0'); + } + + if ($dom->firstChild->hasChildNodes()) + throw new Sabre_DAV_Exception_BadRequest('The principal-search-property-set report element is not allowed to have child elements'); + + $dom = new DOMDocument('1.0','utf-8'); + $dom->formatOutput = true; + $root = $dom->createElement('d:principal-search-property-set'); + $dom->appendChild($root); + // Adding in default namespaces + foreach($this->server->xmlNamespaces as $namespace=>$prefix) { + + $root->setAttribute('xmlns:' . $prefix,$namespace); + + } + + $nsList = $this->server->xmlNamespaces; + + foreach($searchProperties as $propertyName=>$description) { + + $psp = $dom->createElement('d:principal-search-property'); + $root->appendChild($psp); + + $prop = $dom->createElement('d:prop'); + $psp->appendChild($prop); + + $propName = null; + preg_match('/^{([^}]*)}(.*)$/',$propertyName,$propName); + + $currentProperty = $dom->createElement($nsList[$propName[1]] . ':' . $propName[2]); + $prop->appendChild($currentProperty); + + $descriptionElem = $dom->createElement('d:description'); + $descriptionElem->setAttribute('xml:lang','en'); + $descriptionElem->appendChild($dom->createTextNode($description)); + $psp->appendChild($descriptionElem); + + + } + + $this->server->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8'); + $this->server->httpResponse->sendStatus(200); + $this->server->httpResponse->sendBody($dom->saveXML()); + + } + + /** + * principalPropertySearchReport + * + * This method is reponsible for handing the + * {DAV:}principal-property-search report. This report can be used for + * clients to search for groups of principals, based on the value of one + * or more properties. + * + * @param DOMDocument $dom + * @return void + */ + protected function principalPropertySearchReport(DOMDocument $dom) { + + $searchableProperties = array( + '{DAV:}displayname' => 'display name' + + ); + + list($searchProperties, $requestedProperties, $applyToPrincipalCollectionSet) = $this->parsePrincipalPropertySearchReportRequest($dom); + + $result = array(); + + if ($applyToPrincipalCollectionSet) { + $uris = array(); + } else { + $uris = array($this->server->getRequestUri()); + } + + $lookupResults = array(); + foreach($uris as $uri) { + + $p = array_keys($searchProperties); + $p[] = '{DAV:}resourcetype'; + $r = $this->server->getPropertiesForPath($uri, $p, 1); + + // The first item in the results is the parent, so we get rid of it. + array_shift($r); + $lookupResults = array_merge($lookupResults, $r); + } + + $matches = array(); + + foreach($lookupResults as $lookupResult) { + + // We're only looking for principals + if (!isset($lookupResult[200]['{DAV:}resourcetype']) || + (!($lookupResult[200]['{DAV:}resourcetype'] instanceof Sabre_DAV_Property_ResourceType)) || + !$lookupResult[200]['{DAV:}resourcetype']->is('{DAV:}principal')) continue; + + foreach($searchProperties as $searchProperty=>$searchValue) { + if (!isset($searchableProperties[$searchProperty])) { + // If a property is not 'searchable', the spec dictates + // this is not a match. + continue; + } + + if (isset($lookupResult[200][$searchProperty]) && + mb_stripos($lookupResult[200][$searchProperty], $searchValue, 0, 'UTF-8')!==false) { + $matches[] = $lookupResult['href']; + } + + } + + } + + $matchProperties = array(); + + foreach($matches as $match) { + + list($result) = $this->server->getPropertiesForPath($match, $requestedProperties, 0); + $matchProperties[] = $result; + + } + + $xml = $this->server->generateMultiStatus($matchProperties); + $this->server->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8'); + $this->server->httpResponse->sendStatus(207); + $this->server->httpResponse->sendBody($xml); + + } + + /** + * parsePrincipalPropertySearchReportRequest + * + * This method parses the request body from a + * {DAV:}principal-property-search report. + * + * This method returns an array with two elements: + * 1. an array with properties to search on, and their values + * 2. a list of propertyvalues that should be returned for the request. + * + * @param DOMDocument $dom + * @return array + */ + protected function parsePrincipalPropertySearchReportRequest($dom) { + + $httpDepth = $this->server->getHTTPDepth(0); + if ($httpDepth!==0) { + throw new Sabre_DAV_Exception_BadRequest('This report is only defined when Depth: 0'); + } + + $searchProperties = array(); + + $applyToPrincipalCollectionSet = false; + + // Parsing the search request + foreach($dom->firstChild->childNodes as $searchNode) { + + if (Sabre_DAV_XMLUtil::toClarkNotation($searchNode) == '{DAV:}apply-to-principal-collection-set') + $applyToPrincipalCollectionSet = true; + + if (Sabre_DAV_XMLUtil::toClarkNotation($searchNode)!=='{DAV:}property-search') + continue; + + $propertyName = null; + $propertyValue = null; + + foreach($searchNode->childNodes as $childNode) { + + switch(Sabre_DAV_XMLUtil::toClarkNotation($childNode)) { + + case '{DAV:}prop' : + $property = Sabre_DAV_XMLUtil::parseProperties($searchNode); + reset($property); + $propertyName = key($property); + break; + + case '{DAV:}match' : + $propertyValue = $childNode->textContent; + break; + + } + + + } + + if (is_null($propertyName) || is_null($propertyValue)) + throw new Sabre_DAV_Exception_BadRequest('Invalid search request. propertyname: ' . $propertyName . '. propertvvalue: ' . $propertyValue); + + $searchProperties[$propertyName] = $propertyValue; + + } + + return array($searchProperties, array_keys(Sabre_DAV_XMLUtil::parseProperties($dom->firstChild)), $applyToPrincipalCollectionSet); + + } + + + /* }}} */ + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Principal.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Principal.php new file mode 100755 index 0000000..9b13f20 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Principal.php @@ -0,0 +1,263 @@ +principalBackend = $principalBackend; + $this->principalProperties = $principalProperties; + + } + + /** + * Returns the full principal url + * + * @return string + */ + public function getPrincipalUrl() { + + return $this->principalProperties['uri']; + + } + + /** + * Returns a list of altenative urls for a principal + * + * This can for example be an email address, or ldap url. + * + * @return array + */ + public function getAlternateUriSet() { + + $uris = array(); + if (isset($this->principalProperties['{DAV:}alternate-URI-set'])) { + + $uris = $this->principalProperties['{DAV:}alternate-URI-set']; + + } + + if (isset($this->principalProperties['{http://sabredav.org/ns}email-address'])) { + $uris[] = 'mailto:' . $this->principalProperties['{http://sabredav.org/ns}email-address']; + } + + return array_unique($uris); + + } + + /** + * Returns the list of group members + * + * If this principal is a group, this function should return + * all member principal uri's for the group. + * + * @return array + */ + public function getGroupMemberSet() { + + return $this->principalBackend->getGroupMemberSet($this->principalProperties['uri']); + + } + + /** + * Returns the list of groups this principal is member of + * + * If this principal is a member of a (list of) groups, this function + * should return a list of principal uri's for it's members. + * + * @return array + */ + public function getGroupMembership() { + + return $this->principalBackend->getGroupMemberShip($this->principalProperties['uri']); + + } + + + /** + * Sets a list of group members + * + * If this principal is a group, this method sets all the group members. + * The list of members is always overwritten, never appended to. + * + * This method should throw an exception if the members could not be set. + * + * @param array $principals + * @return void + */ + public function setGroupMemberSet(array $groupMembers) { + + $this->principalBackend->setGroupMemberSet($this->principalProperties['uri'], $groupMembers); + + } + + + /** + * Returns this principals name. + * + * @return string + */ + public function getName() { + + $uri = $this->principalProperties['uri']; + list(, $name) = Sabre_DAV_URLUtil::splitPath($uri); + + return $name; + + } + + /** + * Returns the name of the user + * + * @return void + */ + public function getDisplayName() { + + if (isset($this->principalProperties['{DAV:}displayname'])) { + return $this->principalProperties['{DAV:}displayname']; + } else { + return $this->getName(); + } + + } + + /** + * Returns a list of properties + * + * @param array $requestedProperties + * @return void + */ + public function getProperties($requestedProperties) { + + $newProperties = array(); + foreach($requestedProperties as $propName) { + + if (isset($this->principalProperties[$propName])) { + $newProperties[$propName] = $this->principalProperties[$propName]; + } + + } + + return $newProperties; + + } + + /** + * Updates this principals properties. + * + * Currently this is not supported + * + * @param array $properties + * @see Sabre_DAV_IProperties::updateProperties + * @return bool|array + */ + public function updateProperties($properties) { + + return false; + + } + + /** + * Returns the owner principal + * + * This must be a url to a principal, or null if there's no owner + * + * @return string|null + */ + public function getOwner() { + + return $this->principalProperties['uri']; + + + } + + /** + * Returns a group principal + * + * This must be a url to a principal, or null if there's no owner + * + * @return string|null + */ + public function getGroup() { + + return null; + + } + + /** + * Returns a list of ACE's for this node. + * + * Each ACE has the following properties: + * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are + * currently the only supported privileges + * * 'principal', a url to the principal who owns the node + * * 'protected' (optional), indicating that this ACE is not allowed to + * be updated. + * + * @return array + */ + public function getACL() { + + return array( + array( + 'privilege' => '{DAV:}read', + 'principal' => $this->principalProperties['uri'], + 'protected' => true, + ), + ); + + } + + /** + * Updates the ACL + * + * This method will receive a list of new ACE's. + * + * @param array $acl + * @return void + */ + public function setACL(array $acl) { + + throw new Sabre_DAV_Exception_MethodNotAllowed('Updating ACLs is not allowed here'); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/PrincipalBackend/PDO.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/PrincipalBackend/PDO.php new file mode 100755 index 0000000..5eed45b --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/PrincipalBackend/PDO.php @@ -0,0 +1,206 @@ +pdo = $pdo; + $this->tableName = $tableName; + $this->groupMembersTableName = $groupMembersTableName; + + } + + + /** + * Returns a list of principals based on a prefix. + * + * This prefix will often contain something like 'principals'. You are only + * expected to return principals that are in this base path. + * + * You are expected to return at least a 'uri' for every user, you can + * return any additional properties if you wish so. Common properties are: + * {DAV:}displayname + * {http://sabredav.org/ns}email-address - This is a custom SabreDAV + * field that's actualy injected in a number of other properties. If + * you have an email address, use this property. + * + * @param string $prefixPath + * @return array + */ + public function getPrincipalsByPrefix($prefixPath) { + $result = $this->pdo->query('SELECT uri, email, displayname FROM `'. $this->tableName . '`'); + + $principals = array(); + + while($row = $result->fetch(PDO::FETCH_ASSOC)) { + + // Checking if the principal is in the prefix + list($rowPrefix) = Sabre_DAV_URLUtil::splitPath($row['uri']); + if ($rowPrefix !== $prefixPath) continue; + + $principals[] = array( + 'uri' => $row['uri'], + '{DAV:}displayname' => $row['displayname']?$row['displayname']:basename($row['uri']), + '{http://sabredav.org/ns}email-address' => $row['email'], + ); + + } + + return $principals; + + } + + /** + * Returns a specific principal, specified by it's path. + * The returned structure should be the exact same as from + * getPrincipalsByPrefix. + * + * @param string $path + * @return array + */ + public function getPrincipalByPath($path) { + + $stmt = $this->pdo->prepare('SELECT id, uri, email, displayname FROM `'.$this->tableName.'` WHERE uri = ?'); + $stmt->execute(array($path)); + + $users = array(); + + $row = $stmt->fetch(PDO::FETCH_ASSOC); + if (!$row) return; + + return array( + 'id' => $row['id'], + 'uri' => $row['uri'], + '{DAV:}displayname' => $row['displayname']?$row['displayname']:basename($row['uri']), + '{http://sabredav.org/ns}email-address' => $row['email'], + ); + + } + + /** + * Returns the list of members for a group-principal + * + * @param string $principal + * @return array + */ + public function getGroupMemberSet($principal) { + + $principal = $this->getPrincipalByPath($principal); + if (!$principal) throw new Sabre_DAV_Exception('Principal not found'); + + $stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM `'.$this->groupMembersTableName.'` AS groupmembers LEFT JOIN `'.$this->tableName.'` AS principals ON groupmembers.member_id = principals.id WHERE groupmembers.principal_id = ?'); + $stmt->execute(array($principal['id'])); + + $result = array(); + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $result[] = $row['uri']; + } + return $result; + + } + + /** + * Returns the list of groups a principal is a member of + * + * @param string $principal + * @return array + */ + public function getGroupMembership($principal) { + + $principal = $this->getPrincipalByPath($principal); + if (!$principal) throw new Sabre_DAV_Exception('Principal not found'); + + $stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM `'.$this->groupMembersTableName.'` AS groupmembers LEFT JOIN `'.$this->tableName.'` AS principals ON groupmembers.principal_id = principals.id WHERE groupmembers.member_id = ?'); + $stmt->execute(array($principal['id'])); + + $result = array(); + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $result[] = $row['uri']; + } + return $result; + + } + + /** + * Updates the list of group members for a group principal. + * + * The principals should be passed as a list of uri's. + * + * @param string $principal + * @param array $members + * @return void + */ + public function setGroupMemberSet($principal, array $members) { + + // Grabbing the list of principal id's. + $stmt = $this->pdo->prepare('SELECT id, uri FROM `'.$this->tableName.'` WHERE uri IN (? ' . str_repeat(', ? ', count($members)) . ');'); + $stmt->execute(array_merge(array($principal), $members)); + + $memberIds = array(); + $principalId = null; + + while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + if ($row['uri'] == $principal) { + $principalId = $row['id']; + } else { + $memberIds[] = $row['id']; + } + } + if (!$principalId) throw new Sabre_DAV_Exception('Principal not found'); + + // Wiping out old members + $stmt = $this->pdo->prepare('DELETE FROM `'.$this->groupMembersTableName.'` WHERE principal_id = ?;'); + $stmt->execute(array($principalId)); + + foreach($memberIds as $memberId) { + + $stmt = $this->pdo->prepare('INSERT INTO `'.$this->groupMembersTableName.'` (principal_id, member_id) VALUES (?, ?);'); + $stmt->execute(array($principalId, $memberId)); + + } + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/PrincipalCollection.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/PrincipalCollection.php new file mode 100755 index 0000000..421eaec --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/PrincipalCollection.php @@ -0,0 +1,35 @@ +principalBackend, $principal); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Property/Acl.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Property/Acl.php new file mode 100755 index 0000000..41f0acc --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Property/Acl.php @@ -0,0 +1,186 @@ +privileges = $privileges; + $this->prefixBaseUrl = $prefixBaseUrl; + + } + + /** + * Returns the list of privileges for this property + * + * @return array + */ + public function getPrivileges() { + + return $this->privileges; + + } + + /** + * Serializes the property into a DOMElement + * + * @param Sabre_DAV_Server $server + * @param DOMElement $node + * @return void + */ + public function serialize(Sabre_DAV_Server $server,DOMElement $node) { + + $doc = $node->ownerDocument; + foreach($this->privileges as $ace) { + + $this->serializeAce($doc, $node, $ace, $server); + + } + + } + + /** + * Unserializes the {DAV:}acl xml element. + * + * @param DOMElement $dom + * @return Sabre_DAVACL_Property_Acl + */ + static public function unserialize(DOMElement $dom) { + + $privileges = array(); + $xaces = $dom->getElementsByTagNameNS('urn:DAV','ace'); + for($ii=0; $ii < $xaces->length; $ii++) { + + $xace = $xaces->item($ii); + $principal = $xace->getElementsByTagNameNS('urn:DAV','principal'); + if ($principal->length !== 1) { + throw new Sabre_DAV_Exception_BadRequest('Each {DAV:}ace element must have one {DAV:}principal element'); + } + $principal = Sabre_DAVACL_Property_Principal::unserialize($principal->item(0)); + + if ($principal->getType()!==Sabre_DAVACL_Property_Principal::HREF) { + throw new Sabre_DAV_Exception_NotImplemented('Currently only uri based principals are support, {DAV:}all, {DAV:}unauthenticated and {DAV:}authenticated are not implemented yet'); + } + + $principal = $principal->getHref(); + $protected = false; + + if ($xace->getElementsByTagNameNS('urn:DAV','protected')->length > 0) { + $protected = true; + } + + $grants = $xace->getElementsByTagNameNS('urn:DAV','grant'); + if ($grants->length < 1) { + throw new Sabre_DAV_Exception_NotImplemented('Every {DAV:}ace element must have a {DAV:}grant element. {DAV:}deny is not yet supported'); + } + $grant = $grants->item(0); + + $xprivs = $grant->getElementsByTagNameNS('urn:DAV','privilege'); + for($jj=0; $jj<$xprivs->length; $jj++) { + + $xpriv = $xprivs->item($jj); + + $privilegeName = null; + + for ($kk=0;$kk<$xpriv->childNodes->length;$kk++) { + + $childNode = $xpriv->childNodes->item($kk); + if ($t = Sabre_DAV_XMLUtil::toClarkNotation($childNode)) { + $privilegeName = $t; + break; + } + } + if (is_null($privilegeName)) { + throw new Sabre_DAV_Exception_BadRequest('{DAV:}privilege elements must have a privilege element contained within them.'); + } + + $privileges[] = array( + 'principal' => $principal, + 'protected' => $protected, + 'privilege' => $privilegeName, + ); + + } + + } + + return new self($privileges); + + } + + /** + * Serializes a single access control entry. + * + * @param DOMDocument $doc + * @param DOMElement $node + * @param array $ace + * @param Sabre_DAV_Server $server + * @return void + */ + private function serializeAce($doc,$node,$ace, $server) { + + $xace = $doc->createElementNS('DAV:','d:ace'); + $node->appendChild($xace); + + $principal = $doc->createElementNS('DAV:','d:principal'); + $xace->appendChild($principal); + $principal->appendChild($doc->createElementNS('DAV:','d:href',($this->prefixBaseUrl?$server->getBaseUri():'') . $ace['principal'] . '/')); + + $grant = $doc->createElementNS('DAV:','d:grant'); + $xace->appendChild($grant); + + $privParts = null; + + preg_match('/^{([^}]*)}(.*)$/',$ace['privilege'],$privParts); + + $xprivilege = $doc->createElementNS('DAV:','d:privilege'); + $grant->appendChild($xprivilege); + + $xprivilege->appendChild($doc->createElementNS($privParts[1],'d:'.$privParts[2])); + + if (isset($ace['protected']) && $ace['protected']) + $xace->appendChild($doc->createElement('d:protected')); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Property/CurrentUserPrivilegeSet.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Property/CurrentUserPrivilegeSet.php new file mode 100755 index 0000000..8b17a9b --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Property/CurrentUserPrivilegeSet.php @@ -0,0 +1,75 @@ +privileges = $privileges; + + } + + /** + * Serializes the property in the DOM + * + * @param Sabre_DAV_Server $server + * @param DOMElement $node + * @return void + */ + public function serialize(Sabre_DAV_Server $server,DOMElement $node) { + + $doc = $node->ownerDocument; + foreach($this->privileges as $privName) { + + $this->serializePriv($doc,$node,$privName); + + } + + } + + /** + * Serializes one privilege + * + * @param DOMDocument $doc + * @param DOMElement $node + * @param string $privName + * @return void + */ + protected function serializePriv($doc,$node,$privName) { + + $xp = $doc->createElementNS('DAV:','d:privilege'); + $node->appendChild($xp); + + $privParts = null; + preg_match('/^{([^}]*)}(.*)$/',$privName,$privParts); + + $xp->appendChild($doc->createElementNS($privParts[1],'d:'.$privParts[2])); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Property/Principal.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Property/Principal.php new file mode 100755 index 0000000..b035116 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Property/Principal.php @@ -0,0 +1,154 @@ +type = $type; + + if ($type===self::HREF && is_null($href)) { + throw new Sabre_DAV_Exception('The href argument must be specified for the HREF principal type.'); + } + $this->href = $href; + + } + + /** + * Returns the principal type + * + * @return int + */ + public function getType() { + + return $this->type; + + } + + /** + * Returns the principal uri. + * + * @return string + */ + public function getHref() { + + return $this->href; + + } + + /** + * Serializes the property into a DOMElement. + * + * @param Sabre_DAV_Server $server + * @param DOMElement $node + * @return void + */ + public function serialize(Sabre_DAV_Server $server, DOMElement $node) { + + $prefix = $server->xmlNamespaces['DAV:']; + switch($this->type) { + + case self::UNAUTHENTICATED : + $node->appendChild( + $node->ownerDocument->createElement($prefix . ':unauthenticated') + ); + break; + case self::AUTHENTICATED : + $node->appendChild( + $node->ownerDocument->createElement($prefix . ':authenticated') + ); + break; + case self::HREF : + $href = $node->ownerDocument->createElement($prefix . ':href'); + $href->nodeValue = $server->getBaseUri() . $this->href; + $node->appendChild($href); + break; + + } + + } + + /** + * Deserializes a DOM element into a property object. + * + * @param DOMElement $dom + * @return Sabre_DAV_Property_Principal + */ + static public function unserialize(DOMElement $dom) { + + $parent = $dom->firstChild; + while(!Sabre_DAV_XMLUtil::toClarkNotation($parent)) { + $parent = $parent->nextSibling; + } + + switch(Sabre_DAV_XMLUtil::toClarkNotation($parent)) { + + case '{DAV:}unauthenticated' : + return new self(self::UNAUTHENTICATED); + case '{DAV:}authenticated' : + return new self(self::AUTHENTICATED); + case '{DAV:}href': + return new self(self::HREF, $parent->textContent); + default : + throw new Sabre_DAV_Exception_BadRequest('Unexpected element (' . Sabre_DAV_XMLUtil::toClarkNotation($parent) . '). Could not deserialize'); + + } + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Property/SupportedPrivilegeSet.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Property/SupportedPrivilegeSet.php new file mode 100755 index 0000000..2eab5af --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Property/SupportedPrivilegeSet.php @@ -0,0 +1,92 @@ +privileges = $privileges; + + } + + /** + * Serializes the property into a domdocument. + * + * @param Sabre_DAV_Server $server + * @param DOMElement $node + * @return void + */ + public function serialize(Sabre_DAV_Server $server,DOMElement $node) { + + $doc = $node->ownerDocument; + $this->serializePriv($doc, $node, $this->privileges); + + } + + /** + * Serializes a property + * + * This is a recursive function. + * + * @param DOMDocument $doc + * @param DOMElement $node + * @param array $privilege + * @return void + */ + private function serializePriv($doc,$node,$privilege) { + + $xsp = $doc->createElementNS('DAV:','d:supported-privilege'); + $node->appendChild($xsp); + + $xp = $doc->createElementNS('DAV:','d:privilege'); + $xsp->appendChild($xp); + + $privParts = null; + preg_match('/^{([^}]*)}(.*)$/',$privilege['privilege'],$privParts); + + $xp->appendChild($doc->createElementNS($privParts[1],'d:'.$privParts[2])); + + if (isset($privilege['abstract']) && $privilege['abstract']) { + $xsp->appendChild($doc->createElementNS('DAV:','d:abstract')); + } + + if (isset($privilege['description'])) { + $xsp->appendChild($doc->createElementNS('DAV:','d:description',$privilege['description'])); + } + + if (isset($privilege['aggregates'])) { + foreach($privilege['aggregates'] as $subPrivilege) { + $this->serializePriv($doc,$xsp,$subPrivilege); + } + } + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Version.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Version.php new file mode 100755 index 0000000..97fb6f7 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/DAVACL/Version.php @@ -0,0 +1,24 @@ +httpRequest->getHeader('Authorization'); + $authHeader = explode(' ',$authHeader); + + if ($authHeader[0]!='AWS' || !isset($authHeader[1])) { + $this->errorCode = self::ERR_NOAWSHEADER; + return false; + } + + list($this->accessKey,$this->signature) = explode(':',$authHeader[1]); + + return true; + + } + + /** + * Returns the username for the request + * + * @return string + */ + public function getAccessKey() { + + return $this->accessKey; + + } + + /** + * Validates the signature based on the secretKey + * + * @return bool + */ + public function validate($secretKey) { + + $contentMD5 = $this->httpRequest->getHeader('Content-MD5'); + + if ($contentMD5) { + // We need to validate the integrity of the request + $body = $this->httpRequest->getBody(true); + $this->httpRequest->setBody($body,true); + + if ($contentMD5!=base64_encode(md5($body,true))) { + // content-md5 header did not match md5 signature of body + $this->errorCode = self::ERR_MD5CHECKSUMWRONG; + return false; + } + + } + + if (!$requestDate = $this->httpRequest->getHeader('x-amz-date')) + $requestDate = $this->httpRequest->getHeader('Date'); + + if (!$this->validateRFC2616Date($requestDate)) + return false; + + $amzHeaders = $this->getAmzHeaders(); + + $signature = base64_encode( + $this->hmacsha1($secretKey, + $this->httpRequest->getMethod() . "\n" . + $contentMD5 . "\n" . + $this->httpRequest->getHeader('Content-type') . "\n" . + $requestDate . "\n" . + $amzHeaders . + $this->httpRequest->getURI() + ) + ); + + if ($this->signature != $signature) { + + $this->errorCode = self::ERR_INVALIDSIGNATURE; + return false; + + } + + return true; + + } + + + /** + * Returns an HTTP 401 header, forcing login + * + * This should be called when username and password are incorrect, or not supplied at all + * + * @return void + */ + public function requireLogin() { + + $this->httpResponse->setHeader('WWW-Authenticate','AWS'); + $this->httpResponse->sendStatus(401); + + } + + /** + * Makes sure the supplied value is a valid RFC2616 date. + * + * If we would just use strtotime to get a valid timestamp, we have no way of checking if a + * user just supplied the word 'now' for the date header. + * + * This function also makes sure the Date header is within 15 minutes of the operating + * system date, to prevent replay attacks. + * + * @param string $dateHeader + * @return bool + */ + protected function validateRFC2616Date($dateHeader) { + + $date = Sabre_HTTP_Util::parseHTTPDate($dateHeader); + + // Unknown format + if (!$date) { + $this->errorCode = self::ERR_INVALIDDATEFORMAT; + return false; + } + + $min = new DateTime('-15 minutes'); + $max = new DateTime('+15 minutes'); + + // We allow 15 minutes around the current date/time + if ($date > $max || $date < $min) { + $this->errorCode = self::ERR_REQUESTTIMESKEWED; + return false; + } + + return $date; + + } + + /** + * Returns a list of AMZ headers + * + * @return void + */ + protected function getAmzHeaders() { + + $amzHeaders = array(); + $headers = $this->httpRequest->getHeaders(); + foreach($headers as $headerName => $headerValue) { + if (strpos(strtolower($headerName),'x-amz-')===0) { + $amzHeaders[strtolower($headerName)] = str_replace(array("\r\n"),array(' '),$headerValue) . "\n"; + } + } + ksort($amzHeaders); + + $headerStr = ''; + foreach($amzHeaders as $h=>$v) { + $headerStr.=$h.':'.$v; + } + + return $headerStr; + + } + + /** + * Generates an HMAC-SHA1 signature + * + * @param string $key + * @param string $message + * @return string + */ + private function hmacsha1($key, $message) { + + $blocksize=64; + if (strlen($key)>$blocksize) + $key=pack('H*', sha1($key)); + $key=str_pad($key,$blocksize,chr(0x00)); + $ipad=str_repeat(chr(0x36),$blocksize); + $opad=str_repeat(chr(0x5c),$blocksize); + $hmac = pack('H*',sha1(($key^$opad).pack('H*',sha1(($key^$ipad).$message)))); + return $hmac; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/AbstractAuth.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/AbstractAuth.php new file mode 100755 index 0000000..68a7ca7 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/AbstractAuth.php @@ -0,0 +1,111 @@ +httpResponse = new Sabre_HTTP_Response(); + $this->httpRequest = new Sabre_HTTP_Request(); + + } + + /** + * Sets an alternative HTTP response object + * + * @param Sabre_HTTP_Response $response + * @return void + */ + public function setHTTPResponse(Sabre_HTTP_Response $response) { + + $this->httpResponse = $response; + + } + + /** + * Sets an alternative HTTP request object + * + * @param Sabre_HTTP_Request $request + * @return void + */ + public function setHTTPRequest(Sabre_HTTP_Request $request) { + + $this->httpRequest = $request; + + } + + + /** + * Sets the realm + * + * The realm is often displayed in authentication dialog boxes + * Commonly an application name displayed here + * + * @param string $realm + * @return void + */ + public function setRealm($realm) { + + $this->realm = $realm; + + } + + /** + * Returns the realm + * + * @return string + */ + public function getRealm() { + + return $this->realm; + + } + + /** + * Returns an HTTP 401 header, forcing login + * + * This should be called when username and password are incorrect, or not supplied at all + * + * @return void + */ + abstract public function requireLogin(); + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/BasicAuth.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/BasicAuth.php new file mode 100755 index 0000000..b5fd4f3 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/BasicAuth.php @@ -0,0 +1,61 @@ +httpRequest->getRawServerValue('PHP_AUTH_USER')) && ($pass = $this->httpRequest->getRawServerValue('PHP_AUTH_PW'))) { + + return array($user,$pass); + + } + + // Most other webservers + $auth = $this->httpRequest->getHeader('Authorization'); + + if (!$auth) return false; + + if (strpos(strtolower($auth),'basic')!==0) return false; + + return explode(':', base64_decode(substr($auth, 6))); + + } + + /** + * Returns an HTTP 401 header, forcing login + * + * This should be called when username and password are incorrect, or not supplied at all + * + * @return void + */ + public function requireLogin() { + + $this->httpResponse->setHeader('WWW-Authenticate','Basic realm="' . $this->realm . '"'); + $this->httpResponse->sendStatus(401); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/DigestAuth.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/DigestAuth.php new file mode 100755 index 0000000..6c7c6b8 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/DigestAuth.php @@ -0,0 +1,234 @@ +nonce = uniqid(); + $this->opaque = md5($this->realm); + parent::__construct(); + + } + + /** + * Gathers all information from the headers + * + * This method needs to be called prior to anything else. + * + * @return void + */ + public function init() { + + $digest = $this->getDigest(); + $this->digestParts = $this->parseDigest($digest); + + } + + /** + * Sets the quality of protection value. + * + * Possible values are: + * Sabre_HTTP_DigestAuth::QOP_AUTH + * Sabre_HTTP_DigestAuth::QOP_AUTHINT + * + * Multiple values can be specified using logical OR. + * + * QOP_AUTHINT ensures integrity of the request body, but this is not + * supported by most HTTP clients. QOP_AUTHINT also requires the entire + * request body to be md5'ed, which can put strains on CPU and memory. + * + * @param int $qop + * @return void + */ + public function setQOP($qop) { + + $this->qop = $qop; + + } + + /** + * Validates the user. + * + * The A1 parameter should be md5($username . ':' . $realm . ':' . $password); + * + * @param string $A1 + * @return bool + */ + public function validateA1($A1) { + + $this->A1 = $A1; + return $this->validate(); + + } + + /** + * Validates authentication through a password. The actual password must be provided here. + * It is strongly recommended not store the password in plain-text and use validateA1 instead. + * + * @param string $password + * @return bool + */ + public function validatePassword($password) { + + $this->A1 = md5($this->digestParts['username'] . ':' . $this->realm . ':' . $password); + return $this->validate(); + + } + + /** + * Returns the username for the request + * + * @return string + */ + public function getUsername() { + + return $this->digestParts['username']; + + } + + /** + * Validates the digest challenge + * + * @return bool + */ + protected function validate() { + + $A2 = $this->httpRequest->getMethod() . ':' . $this->digestParts['uri']; + + if ($this->digestParts['qop']=='auth-int') { + // Making sure we support this qop value + if (!($this->qop & self::QOP_AUTHINT)) return false; + // We need to add an md5 of the entire request body to the A2 part of the hash + $body = $this->httpRequest->getBody(true); + $this->httpRequest->setBody($body,true); + $A2 .= ':' . md5($body); + } else { + + // We need to make sure we support this qop value + if (!($this->qop & self::QOP_AUTH)) return false; + } + + $A2 = md5($A2); + + $validResponse = md5("{$this->A1}:{$this->digestParts['nonce']}:{$this->digestParts['nc']}:{$this->digestParts['cnonce']}:{$this->digestParts['qop']}:{$A2}"); + + return $this->digestParts['response']==$validResponse; + + + } + + /** + * Returns an HTTP 401 header, forcing login + * + * This should be called when username and password are incorrect, or not supplied at all + * + * @return void + */ + public function requireLogin() { + + $qop = ''; + switch($this->qop) { + case self::QOP_AUTH : $qop = 'auth'; break; + case self::QOP_AUTHINT : $qop = 'auth-int'; break; + case self::QOP_AUTH | self::QOP_AUTHINT : $qop = 'auth,auth-int'; break; + } + + $this->httpResponse->setHeader('WWW-Authenticate','Digest realm="' . $this->realm . '",qop="'.$qop.'",nonce="' . $this->nonce . '",opaque="' . $this->opaque . '"'); + $this->httpResponse->sendStatus(401); + + } + + + /** + * This method returns the full digest string. + * + * It should be compatibile with mod_php format and other webservers. + * + * If the header could not be found, null will be returned + * + * @return mixed + */ + public function getDigest() { + + // mod_php + $digest = $this->httpRequest->getRawServerValue('PHP_AUTH_DIGEST'); + if ($digest) return $digest; + + // most other servers + $digest = $this->httpRequest->getHeader('Authorization'); + + if ($digest && strpos(strtolower($digest),'digest')===0) { + return substr($digest,7); + } else { + return null; + } + + } + + + /** + * Parses the different pieces of the digest string into an array. + * + * This method returns false if an incomplete digest was supplied + * + * @param string $digest + * @return mixed + */ + protected function parseDigest($digest) { + + // protect against missing data + $needed_parts = array('nonce'=>1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1); + $data = array(); + + preg_match_all('@(\w+)=(?:(?:")([^"]+)"|([^\s,$]+))@', $digest, $matches, PREG_SET_ORDER); + + foreach ($matches as $m) { + $data[$m[1]] = $m[2] ? $m[2] : $m[3]; + unset($needed_parts[$m[1]]); + } + + return $needed_parts ? false : $data; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/Request.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/Request.php new file mode 100755 index 0000000..3907d7a --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/Request.php @@ -0,0 +1,243 @@ +_SERVER = $serverData; + else $this->_SERVER =& $_SERVER; + + } + + /** + * Returns the value for a specific http header. + * + * This method returns null if the header did not exist. + * + * @param string $name + * @return string + */ + public function getHeader($name) { + + $name = strtoupper(str_replace(array('-'),array('_'),$name)); + if (isset($this->_SERVER['HTTP_' . $name])) { + return $this->_SERVER['HTTP_' . $name]; + } + + // There's a few headers that seem to end up in the top-level + // server array. + switch($name) { + case 'CONTENT_TYPE' : + case 'CONTENT_LENGTH' : + if (isset($this->_SERVER[$name])) { + return $this->_SERVER[$name]; + } + break; + + } + return; + + } + + /** + * Returns all (known) HTTP headers. + * + * All headers are converted to lower-case, and additionally all underscores + * are automatically converted to dashes + * + * @return array + */ + public function getHeaders() { + + $hdrs = array(); + foreach($this->_SERVER as $key=>$value) { + + switch($key) { + case 'CONTENT_LENGTH' : + case 'CONTENT_TYPE' : + $hdrs[strtolower(str_replace('_','-',$key))] = $value; + break; + default : + if (strpos($key,'HTTP_')===0) { + $hdrs[substr(strtolower(str_replace('_','-',$key)),5)] = $value; + } + break; + } + + } + + return $hdrs; + + } + + /** + * Returns the HTTP request method + * + * This is for example POST or GET + * + * @return string + */ + public function getMethod() { + + return $this->_SERVER['REQUEST_METHOD']; + + } + + /** + * Returns the requested uri + * + * @return string + */ + public function getUri() { + + return $this->_SERVER['REQUEST_URI']; + + } + + /** + * Will return protocol + the hostname + the uri + * + * @return void + */ + public function getAbsoluteUri() { + + // Checking if the request was made through HTTPS. The last in line is for IIS + $protocol = isset($this->_SERVER['HTTPS']) && ($this->_SERVER['HTTPS']) && ($this->_SERVER['HTTPS']!='off'); + return ($protocol?'https':'http') . '://' . $this->getHeader('Host') . $this->getUri(); + + } + + /** + * Returns everything after the ? from the current url + * + * @return string + */ + public function getQueryString() { + + return isset($this->_SERVER['QUERY_STRING'])?$this->_SERVER['QUERY_STRING']:''; + + } + + /** + * Returns the HTTP request body body + * + * This method returns a readable stream resource. + * If the asString parameter is set to true, a string is sent instead. + * + * @param bool asString + * @return resource + */ + public function getBody($asString = false) { + + if (is_null($this->body)) { + if (!is_null(self::$defaultInputStream)) { + $this->body = self::$defaultInputStream; + } else { + $this->body = fopen('php://input','r'); + self::$defaultInputStream = $this->body; + } + } + if ($asString) { + $body = stream_get_contents($this->body); + return $body; + } else { + return $this->body; + } + + } + + /** + * Sets the contents of the HTTP request body + * + * This method can either accept a string, or a readable stream resource. + * + * If the setAsDefaultInputStream is set to true, it means for this run of the + * script the supplied body will be used instead of php://input. + * + * @param mixed $body + * @param bool $setAsDefaultInputStream + * @return void + */ + public function setBody($body,$setAsDefaultInputStream = false) { + + if(is_resource($body)) { + $this->body = $body; + } else { + + $stream = fopen('php://temp','r+'); + fputs($stream,$body); + rewind($stream); + // String is assumed + $this->body = $stream; + } + if ($setAsDefaultInputStream) { + self::$defaultInputStream = $this->body; + } + + } + + /** + * Returns a specific item from the _SERVER array. + * + * Do not rely on this feature, it is for internal use only. + * + * @param string $field + * @return string + */ + public function getRawServerValue($field) { + + return isset($this->_SERVER[$field])?$this->_SERVER[$field]:null; + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/Response.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/Response.php new file mode 100755 index 0000000..df3fe5c --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/Response.php @@ -0,0 +1,152 @@ + 'Continue', + 101 => 'Switching Protocols', + 102 => 'Processing', + 200 => 'OK', + 201 => 'Created', + 202 => 'Accepted', + 203 => 'Non-Authorative Information', + 204 => 'No Content', + 205 => 'Reset Content', + 206 => 'Partial Content', + 207 => 'Multi-Status', // RFC 4918 + 208 => 'Already Reported', // RFC 5842 + 226 => 'IM Used', // RFC 3229 + 300 => 'Multiple Choices', + 301 => 'Moved Permanently', + 302 => 'Found', + 303 => 'See Other', + 304 => 'Not Modified', + 305 => 'Use Proxy', + 306 => 'Reserved', + 307 => 'Temporary Redirect', + 400 => 'Bad request', + 401 => 'Unauthorized', + 402 => 'Payment Required', + 403 => 'Forbidden', + 404 => 'Not Found', + 405 => 'Method Not Allowed', + 406 => 'Not Acceptable', + 407 => 'Proxy Authentication Required', + 408 => 'Request Timeout', + 409 => 'Conflict', + 410 => 'Gone', + 411 => 'Length Required', + 412 => 'Precondition failed', + 413 => 'Request Entity Too Large', + 414 => 'Request-URI Too Long', + 415 => 'Unsupported Media Type', + 416 => 'Requested Range Not Satisfiable', + 417 => 'Expectation Failed', + 418 => 'I\'m a teapot', // RFC 2324 + 422 => 'Unprocessable Entity', // RFC 4918 + 423 => 'Locked', // RFC 4918 + 424 => 'Failed Dependency', // RFC 4918 + 426 => 'Upgrade required', + 500 => 'Internal Server Error', + 501 => 'Not Implemented', + 502 => 'Bad Gateway', + 503 => 'Service Unavailable', + 504 => 'Gateway Timeout', + 505 => 'HTTP Version not supported', + 506 => 'Variant Also Negotiates', + 507 => 'Unsufficient Storage', // RFC 4918 + 508 => 'Loop Detected', // RFC 5842 + 509 => 'Bandwidth Limit Exceeded', // non-standard + 510 => 'Not extended', + ); + + return 'HTTP/1.1 ' . $code . ' ' . $msg[$code]; + + } + + /** + * Sends an HTTP status header to the client + * + * @param int $code HTTP status code + * @return void + */ + public function sendStatus($code) { + + if (!headers_sent()) + return header($this->getStatusMessage($code)); + else return false; + + } + + /** + * Sets an HTTP header for the response + * + * @param string $name + * @param string $value + * @return void + */ + public function setHeader($name, $value, $replace = true) { + + $value = str_replace(array("\r","\n"),array('\r','\n'),$value); + if (!headers_sent()) + return header($name . ': ' . $value, $replace); + else return false; + + } + + /** + * Sets a bunch of HTTP Headers + * + * headersnames are specified as keys, value in the array value + * + * @param array $headers + * @return void + */ + public function setHeaders(array $headers) { + + foreach($headers as $key=>$value) + $this->setHeader($key, $value); + + } + + /** + * Sends the entire response body + * + * This method can accept either an open filestream, or a string. + * + * @param mixed $body + * @return void + */ + public function sendBody($body) { + + if (is_resource($body)) { + + fpassthru($body); + + } else { + + // We assume a string + echo $body; + + } + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/Util.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/Util.php new file mode 100755 index 0000000..d58585e --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/Util.php @@ -0,0 +1,65 @@ += 0) + return new DateTime('@' . $realDate, new DateTimeZone('UTC')); + + return false; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/Version.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/Version.php new file mode 100755 index 0000000..924e750 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/HTTP/Version.php @@ -0,0 +1,24 @@ +name = strtoupper($name); + if (!is_null($iterator)) $this->iterator = $iterator; + + } + + /** + * Turns the object back into a serialized blob. + * + * @return string + */ + public function serialize() { + + $str = "BEGIN:" . $this->name . "\r\n"; + + usort($this->children, array($this, 'childrenSort')); + + foreach($this->children as $child) $str.=$child->serialize(); + $str.= "END:" . $this->name . "\r\n"; + + return $str; + + } + + /** + * Sorts the children based on the rules of RFC5545 and RFC6350. + * + * This is solely used by 'serialize' and will be removed in 1.6.0. + * + * @param Sabre_VObject_Node $a + * @param Sabre_VObject_Node $b + * @return int + */ + public function childrenSort($a, $b) { + + $sA = $this->sortScore($a); + $sB = $this->sortScore($b); + + if ($sA === $sB) return 0; + + return ($sA > $sB) ? -1 : 1; + + } + + /** + * Gives a component a 'score' for sorting purposes. + * + * This is solely used by the childrenSort method. + * + * A higher score means the item will be higher in the list + * + * @param Sabre_VObject_Node $a + * @return int + */ + private function sortScore(Sabre_VObject_Node $n) { + + if ($n instanceof Sabre_VObject_Component) { + // We want to encode VTIMEZONE first, this is a personal + // preference. + if ($n->name === 'VTIMEZONE') { + return 1; + } else { + return 0; + } + } else { + // VCARD version 4.0 wants the VERSION property to appear first + if ($n->name === 'VERSION') { + return 3; + } else { + return 2; + } + } + + } + + /** + * Adds a new componenten or element + * + * You can call this method with the following syntaxes: + * + * add(Sabre_VObject_Element $element) + * add(string $name, $value) + * + * The first version adds an Element + * The second adds a property as a string. + * + * @param mixed $item + * @param mixed $itemValue + * @return void + */ + public function add($item, $itemValue = null) { + + if ($item instanceof Sabre_VObject_Element) { + if (!is_null($itemValue)) { + throw new InvalidArgumentException('The second argument must not be specified, when passing a VObject'); + } + $item->parent = $this; + $this->children[] = $item; + } elseif(is_string($item)) { + + if (!is_scalar($itemValue)) { + throw new InvalidArgumentException('The second argument must be scalar'); + } + $item = new Sabre_VObject_Property($item,$itemValue); + $item->parent = $this; + $this->children[] = $item; + + } else { + + throw new InvalidArgumentException('The first argument must either be a Sabre_VObject_Element or a string'); + + } + + } + + /** + * Returns an iterable list of children + * + * @return Sabre_VObject_ElementList + */ + public function children() { + + return new Sabre_VObject_ElementList($this->children); + + } + + /** + * Returns an array with elements that match the specified name. + * + * This function is also aware of MIME-Directory groups (as they appear in + * vcards). This means that if a property is grouped as "HOME.EMAIL", it + * will also be returned when searching for just "EMAIL". If you want to + * search for a property in a specific group, you can select on the entire + * string ("HOME.EMAIL"). If you want to search on a specific property that + * has not been assigned a group, specify ".EMAIL". + * + * Keys are retained from the 'children' array, which may be confusing in + * certain cases. + * + * @param string $name + * @return array + */ + public function select($name) { + + $group = null; + $name = strtoupper($name); + if (strpos($name,'.')!==false) { + list($group,$name) = explode('.', $name, 2); + } + + $result = array(); + foreach($this->children as $key=>$child) { + + if ( + strtoupper($child->name) === $name && + (is_null($group) || ( $child instanceof Sabre_VObject_Property && strtoupper($child->group) === $group)) + ) { + + $result[$key] = $child; + + } + } + + reset($result); + return $result; + + } + + /* Magic property accessors {{{ */ + + /** + * Using 'get' you will either get a propery or component, + * + * If there were no child-elements found with the specified name, + * null is returned. + * + * @param string $name + * @return void + */ + public function __get($name) { + + $matches = $this->select($name); + if (count($matches)===0) { + return null; + } else { + $firstMatch = current($matches); + $firstMatch->setIterator(new Sabre_VObject_ElementList(array_values($matches))); + return $firstMatch; + } + + } + + /** + * This method checks if a sub-element with the specified name exists. + * + * @param string $name + * @return bool + */ + public function __isset($name) { + + $matches = $this->select($name); + return count($matches)>0; + + } + + /** + * Using the setter method you can add properties or subcomponents + * + * You can either pass a Sabre_VObject_Component, Sabre_VObject_Property + * object, or a string to automatically create a Property. + * + * If the item already exists, it will be removed. If you want to add + * a new item with the same name, always use the add() method. + * + * @param string $name + * @param mixed $value + * @return void + */ + public function __set($name, $value) { + + $matches = $this->select($name); + $overWrite = count($matches)?key($matches):null; + + if ($value instanceof Sabre_VObject_Component || $value instanceof Sabre_VObject_Property) { + $value->parent = $this; + if (!is_null($overWrite)) { + $this->children[$overWrite] = $value; + } else { + $this->children[] = $value; + } + } elseif (is_scalar($value)) { + $property = new Sabre_VObject_Property($name,$value); + $property->parent = $this; + if (!is_null($overWrite)) { + $this->children[$overWrite] = $property; + } else { + $this->children[] = $property; + } + } else { + throw new InvalidArgumentException('You must pass a Sabre_VObject_Component, Sabre_VObject_Property or scalar type'); + } + + } + + /** + * Removes all properties and components within this component. + * + * @param string $name + * @return void + */ + public function __unset($name) { + + $matches = $this->select($name); + foreach($matches as $k=>$child) { + + unset($this->children[$k]); + $child->parent = null; + + } + + } + + /* }}} */ + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Element.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Element.php new file mode 100755 index 0000000..cbdeebd --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Element.php @@ -0,0 +1,15 @@ +setValue($dt->format('Ymd\\THis')); + $this->offsetUnset('VALUE'); + $this->offsetUnset('TZID'); + $this->offsetSet('VALUE','DATE-TIME'); + break; + case self::UTC : + $dt->setTimeZone(new DateTimeZone('UTC')); + $this->setValue($dt->format('Ymd\\THis\\Z')); + $this->offsetUnset('VALUE'); + $this->offsetUnset('TZID'); + $this->offsetSet('VALUE','DATE-TIME'); + break; + case self::LOCALTZ : + $this->setValue($dt->format('Ymd\\THis')); + $this->offsetUnset('VALUE'); + $this->offsetUnset('TZID'); + $this->offsetSet('VALUE','DATE-TIME'); + $this->offsetSet('TZID', $dt->getTimeZone()->getName()); + break; + case self::DATE : + $this->setValue($dt->format('Ymd')); + $this->offsetUnset('VALUE'); + $this->offsetUnset('TZID'); + $this->offsetSet('VALUE','DATE'); + break; + default : + throw new InvalidArgumentException('You must pass a valid dateType constant'); + + } + $this->dateTime = $dt; + $this->dateType = $dateType; + + } + + /** + * Returns the current DateTime value. + * + * If no value was set, this method returns null. + * + * @return DateTime|null + */ + public function getDateTime() { + + if ($this->dateTime) + return $this->dateTime; + + list( + $this->dateType, + $this->dateTime + ) = self::parseData($this->value, $this); + return $this->dateTime; + + } + + /** + * Returns the type of Date format. + * + * This method returns one of the format constants. If no date was set, + * this method will return null. + * + * @return int|null + */ + public function getDateType() { + + if ($this->dateType) + return $this->dateType; + + list( + $this->dateType, + $this->dateTime, + ) = self::parseData($this->value, $this); + return $this->dateType; + + } + + /** + * Parses the internal data structure to figure out what the current date + * and time is. + * + * The returned array contains two elements: + * 1. A 'DateType' constant (as defined on this class), or null. + * 2. A DateTime object (or null) + * + * @param string|null $propertyValue The string to parse (yymmdd or + * ymmddThhmmss, etc..) + * @param Sabre_VObject_Property|null $property The instance of the + * property we're parsing. + * @return array + */ + static public function parseData($propertyValue, Sabre_VObject_Property $property = null) { + + if (is_null($propertyValue)) { + return array(null, null); + } + + $date = '(?P[1-2][0-9]{3})(?P[0-1][0-9])(?P[0-3][0-9])'; + $time = '(?P[0-2][0-9])(?P[0-5][0-9])(?P[0-5][0-9])'; + $regex = "/^$date(T$time(?PZ)?)?$/"; + + if (!preg_match($regex, $propertyValue, $matches)) { + throw new InvalidArgumentException($propertyValue . ' is not a valid DateTime or Date string'); + } + + if (!isset($matches['hour'])) { + // Date-only + return array( + self::DATE, + new DateTime($matches['year'] . '-' . $matches['month'] . '-' . $matches['date'] . ' 00:00:00'), + ); + } + + $dateStr = + $matches['year'] .'-' . + $matches['month'] . '-' . + $matches['date'] . ' ' . + $matches['hour'] . ':' . + $matches['minute'] . ':' . + $matches['second']; + + if (isset($matches['isutc'])) { + $dt = new DateTime($dateStr,new DateTimeZone('UTC')); + $dt->setTimeZone(new DateTimeZone('UTC')); + return array( + self::UTC, + $dt + ); + } + + // Finding the timezone. + $tzid = $property['TZID']; + if (!$tzid) { + return array( + self::LOCAL, + new DateTime($dateStr) + ); + } + + try { + $tz = new DateTimeZone($tzid->value); + } catch (Exception $e) { + + // The id was invalid, we're going to try to find the information + // through the VTIMEZONE object. + + // First we find the root object + $root = $property; + while($root->parent) { + $root = $root->parent; + } + + if (isset($root->VTIMEZONE)) { + foreach($root->VTIMEZONE as $vtimezone) { + if (((string)$vtimezone->TZID) == $tzid) { + if (isset($vtimezone->{'X-LIC-LOCATION'})) { + $tzid = (string)$vtimezone->{'X-LIC-LOCATION'}; + } + } + } + } + + $tz = new DateTimeZone($tzid); + + } + $dt = new DateTime($dateStr, $tz); + $dt->setTimeZone($tz); + + return array( + self::LOCALTZ, + $dt + ); + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Element/MultiDateTime.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Element/MultiDateTime.php new file mode 100755 index 0000000..0106b2f --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Element/MultiDateTime.php @@ -0,0 +1,168 @@ +offsetUnset('VALUE'); + $this->offsetUnset('TZID'); + switch($dateType) { + + case Sabre_VObject_Element_DateTime::LOCAL : + $val = array(); + foreach($dt as $i) { + $val[] = $i->format('Ymd\\THis'); + } + $this->setValue(implode(',',$val)); + $this->offsetSet('VALUE','DATE-TIME'); + break; + case Sabre_VObject_Element_DateTime::UTC : + $val = array(); + foreach($dt as $i) { + $i->setTimeZone(new DateTimeZone('UTC')); + $val[] = $i->format('Ymd\\THis\\Z'); + } + $this->setValue(implode(',',$val)); + $this->offsetSet('VALUE','DATE-TIME'); + break; + case Sabre_VObject_Element_DateTime::LOCALTZ : + $val = array(); + foreach($dt as $i) { + $val[] = $i->format('Ymd\\THis'); + } + $this->setValue(implode(',',$val)); + $this->offsetSet('VALUE','DATE-TIME'); + $this->offsetSet('TZID', $dt[0]->getTimeZone()->getName()); + break; + case Sabre_VObject_Element_DateTime::DATE : + $val = array(); + foreach($dt as $i) { + $val[] = $i->format('Ymd'); + } + $this->setValue(implode(',',$val)); + $this->offsetSet('VALUE','DATE'); + break; + default : + throw new InvalidArgumentException('You must pass a valid dateType constant'); + + } + $this->dateTimes = $dt; + $this->dateType = $dateType; + + } + + /** + * Returns the current DateTime value. + * + * If no value was set, this method returns null. + * + * @return array|null + */ + public function getDateTimes() { + + if ($this->dateTimes) + return $this->dateTimes; + + $dts = array(); + + if (!$this->value) { + $this->dateTimes = null; + $this->dateType = null; + return null; + } + + foreach(explode(',',$this->value) as $val) { + list( + $type, + $dt + ) = Sabre_VObject_Element_DateTime::parseData($val, $this); + $dts[] = $dt; + $this->dateType = $type; + } + $this->dateTimes = $dts; + return $this->dateTimes; + + } + + /** + * Returns the type of Date format. + * + * This method returns one of the format constants. If no date was set, + * this method will return null. + * + * @return int|null + */ + public function getDateType() { + + if ($this->dateType) + return $this->dateType; + + if (!$this->value) { + $this->dateTimes = null; + $this->dateType = null; + return null; + } + + $dts = array(); + foreach(explode(',',$this->value) as $val) { + list( + $type, + $dt + ) = Sabre_VObject_Element_DateTime::parseData($val, $this); + $dts[] = $dt; + $this->dateType = $type; + } + $this->dateTimes = $dts; + return $this->dateType; + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/ElementList.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/ElementList.php new file mode 100755 index 0000000..cfbfcc3 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/ElementList.php @@ -0,0 +1,172 @@ +vevent where there's multiple VEVENT objects. + * + * @package Sabre + * @subpackage VObject + * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ +class Sabre_VObject_ElementList implements Iterator, Countable, ArrayAccess { + + /** + * Inner elements + * + * @var array + */ + protected $elements = array(); + + /** + * Creates the element list. + * + * @param array $elements + */ + public function __construct(array $elements) { + + $this->elements = $elements; + + } + + /* {{{ Iterator interface */ + + /** + * Current position + * + * @var int + */ + private $key = 0; + + /** + * Returns current item in iteration + * + * @return Sabre_VObject_Element + */ + public function current() { + + return $this->elements[$this->key]; + + } + + /** + * To the next item in the iterator + * + * @return void + */ + public function next() { + + $this->key++; + + } + + /** + * Returns the current iterator key + * + * @return int + */ + public function key() { + + return $this->key; + + } + + /** + * Returns true if the current position in the iterator is a valid one + * + * @return bool + */ + public function valid() { + + return isset($this->elements[$this->key]); + + } + + /** + * Rewinds the iterator + * + * @return void + */ + public function rewind() { + + $this->key = 0; + + } + + /* }}} */ + + /* {{{ Countable interface */ + + /** + * Returns the number of elements + * + * @return int + */ + public function count() { + + return count($this->elements); + + } + + /* }}} */ + + /* {{{ ArrayAccess Interface */ + + + /** + * Checks if an item exists through ArrayAccess. + * + * @param int $offset + * @return bool + */ + public function offsetExists($offset) { + + return isset($this->elements[$offset]); + + } + + /** + * Gets an item through ArrayAccess. + * + * @param int $offset + * @return mixed + */ + public function offsetGet($offset) { + + return $this->elements[$offset]; + + } + + /** + * Sets an item through ArrayAccess. + * + * @param int $offset + * @param mixed $value + * @return void + */ + public function offsetSet($offset,$value) { + + throw new LogicException('You can not add new objects to an ElementList'); + + } + + /** + * Sets an item through ArrayAccess. + * + * This method just forwards the request to the inner iterator + * + * @param int $offset + * @return void + */ + public function offsetUnset($offset) { + + throw new LogicException('You can not remove objects from an ElementList'); + + } + + /* }}} */ + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Node.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Node.php new file mode 100755 index 0000000..0bd9ddd --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Node.php @@ -0,0 +1,149 @@ +iterator)) + return $this->iterator; + + return new Sabre_VObject_ElementList(array($this)); + + } + + /** + * Sets the overridden iterator + * + * Note that this is not actually part of the iterator interface + * + * @param Sabre_VObject_ElementList $iterator + * @return void + */ + public function setIterator(Sabre_VObject_ElementList $iterator) { + + $this->iterator = $iterator; + + } + + /* }}} */ + + /* {{{ Countable interface */ + + /** + * Returns the number of elements + * + * @return int + */ + public function count() { + + $it = $this->getIterator(); + return $it->count(); + + } + + /* }}} */ + + /* {{{ ArrayAccess Interface */ + + + /** + * Checks if an item exists through ArrayAccess. + * + * This method just forwards the request to the inner iterator + * + * @param int $offset + * @return bool + */ + public function offsetExists($offset) { + + $iterator = $this->getIterator(); + return $iterator->offsetExists($offset); + + } + + /** + * Gets an item through ArrayAccess. + * + * This method just forwards the request to the inner iterator + * + * @param int $offset + * @return mixed + */ + public function offsetGet($offset) { + + $iterator = $this->getIterator(); + return $iterator->offsetGet($offset); + + } + + /** + * Sets an item through ArrayAccess. + * + * This method just forwards the request to the inner iterator + * + * @param int $offset + * @param mixed $value + * @return void + */ + public function offsetSet($offset,$value) { + + $iterator = $this->getIterator(); + return $iterator->offsetSet($offset,$value); + + } + + /** + * Sets an item through ArrayAccess. + * + * This method just forwards the request to the inner iterator + * + * @param int $offset + * @return void + */ + public function offsetUnset($offset) { + + $iterator = $this->getIterator(); + return $iterator->offsetUnset($offset); + + } + + /* }}} */ + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Parameter.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Parameter.php new file mode 100755 index 0000000..8dfc0de --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Parameter.php @@ -0,0 +1,81 @@ +name = strtoupper($name); + $this->value = $value; + + } + + /** + * Turns the object back into a serialized blob. + * + * @return string + */ + public function serialize() { + + $src = array( + '\\', + "\n", + ';', + ',', + ); + $out = array( + '\\\\', + '\n', + '\;', + '\,', + ); + + return $this->name . '=' . str_replace($src, $out, $this->value); + + } + + /** + * Called when this object is being cast to a string + * + * @return string + */ + public function __toString() { + + return $this->value; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/ParseException.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/ParseException.php new file mode 100755 index 0000000..b62e1dc --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/ParseException.php @@ -0,0 +1,12 @@ +name = $name; + $this->group = $group; + if (!is_null($iterator)) $this->iterator = $iterator; + $this->setValue($value); + + } + + /** + * Updates the internal value + * + * @param string $value + * @return void + */ + public function setValue($value) { + + $this->value = $value; + + } + + /** + * Turns the object back into a serialized blob. + * + * @return string + */ + public function serialize() { + + $str = $this->name; + if ($this->group) $str = $this->group . '.' . $this->name; + + if (count($this->parameters)) { + foreach($this->parameters as $param) { + + $str.=';' . $param->serialize(); + + } + } + $src = array( + '\\', + "\n", + ); + $out = array( + '\\\\', + '\n', + ); + $str.=':' . str_replace($src, $out, $this->value); + + $out = ''; + while(strlen($str)>0) { + if (strlen($str)>75) { + $out.= mb_strcut($str,0,75,'utf-8') . "\r\n"; + $str = ' ' . mb_strcut($str,75,strlen($str),'utf-8'); + } else { + $out.=$str . "\r\n"; + $str=''; + break; + } + } + + return $out; + + } + + /** + * Adds a new componenten or element + * + * You can call this method with the following syntaxes: + * + * add(Sabre_VObject_Parameter $element) + * add(string $name, $value) + * + * The first version adds an Parameter + * The second adds a property as a string. + * + * @param mixed $item + * @param mixed $itemValue + * @return void + */ + public function add($item, $itemValue = null) { + + if ($item instanceof Sabre_VObject_Parameter) { + if (!is_null($itemValue)) { + throw new InvalidArgumentException('The second argument must not be specified, when passing a VObject'); + } + $item->parent = $this; + $this->parameters[] = $item; + } elseif(is_string($item)) { + + if (!is_scalar($itemValue)) { + throw new InvalidArgumentException('The second argument must be scalar'); + } + $parameter = new Sabre_VObject_Parameter($item,$itemValue); + $parameter->parent = $this; + $this->parameters[] = $parameter; + + } else { + + throw new InvalidArgumentException('The first argument must either be a Sabre_VObject_Element or a string'); + + } + + } + + + /* ArrayAccess interface {{{ */ + + /** + * Checks if an array element exists + * + * @param mixed $name + * @return bool + */ + public function offsetExists($name) { + + if (is_int($name)) return parent::offsetExists($name); + + $name = strtoupper($name); + + foreach($this->parameters as $parameter) { + if ($parameter->name == $name) return true; + } + return false; + + } + + /** + * Returns a parameter, or parameter list. + * + * @param string $name + * @return Sabre_VObject_Element + */ + public function offsetGet($name) { + + if (is_int($name)) return parent::offsetGet($name); + $name = strtoupper($name); + + $result = array(); + foreach($this->parameters as $parameter) { + if ($parameter->name == $name) + $result[] = $parameter; + } + + if (count($result)===0) { + return null; + } elseif (count($result)===1) { + return $result[0]; + } else { + $result[0]->setIterator(new Sabre_VObject_ElementList($result)); + return $result[0]; + } + + } + + /** + * Creates a new parameter + * + * @param string $name + * @param mixed $value + * @return void + */ + public function offsetSet($name, $value) { + + if (is_int($name)) return parent::offsetSet($name, $value); + + if (is_scalar($value)) { + if (!is_string($name)) + throw new InvalidArgumentException('A parameter name must be specified. This means you cannot use the $array[]="string" to add parameters.'); + + $this->offsetUnset($name); + $parameter = new Sabre_VObject_Parameter($name, $value); + $parameter->parent = $this; + $this->parameters[] = $parameter; + + } elseif ($value instanceof Sabre_VObject_Parameter) { + if (!is_null($name)) + throw new InvalidArgumentException('Don\'t specify a parameter name if you\'re passing a Sabre_VObject_Parameter. Add using $array[]=$parameterObject.'); + + $value->parent = $this; + $this->parameters[] = $value; + } else { + throw new InvalidArgumentException('You can only add parameters to the property object'); + } + + } + + /** + * Removes one or more parameters with the specified name + * + * @param string $name + * @return void + */ + public function offsetUnset($name) { + + if (is_int($name)) return parent::offsetUnset($name, $value); + $name = strtoupper($name); + + $result = array(); + foreach($this->parameters as $key=>$parameter) { + if ($parameter->name == $name) { + $parameter->parent = null; + unset($this->parameters[$key]); + } + + } + + } + + /* }}} */ + + /** + * Called when this object is being cast to a string + * + * @return string + */ + public function __toString() { + + return $this->value; + + } + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Reader.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Reader.php new file mode 100755 index 0000000..a2c1804 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Reader.php @@ -0,0 +1,191 @@ + 'Sabre_VObject_Element_DateTime', + 'DTEND' => 'Sabre_VObject_Element_DateTime', + 'COMPLETED' => 'Sabre_VObject_Element_DateTime', + 'DUE' => 'Sabre_VObject_Element_DateTime', + 'EXDATE' => 'Sabre_VObject_Element_MultiDateTime', + ); + + /** + * Parses the file and returns the top component + * + * @param string $data + * @return Sabre_VObject_Element + */ + static function read($data) { + + // Normalizing newlines + $data = str_replace(array("\r","\n\n"), array("\n","\n"), $data); + + $lines = explode("\n", $data); + + // Unfolding lines + $lines2 = array(); + foreach($lines as $line) { + + // Skipping empty lines + if (!$line) continue; + + if ($line[0]===" " || $line[0]==="\t") { + $lines2[count($lines2)-1].=substr($line,1); + } else { + $lines2[] = $line; + } + + } + + unset($lines); + + reset($lines2); + + return self::readLine($lines2); + + } + + /** + * Reads and parses a single line. + * + * This method receives the full array of lines. The array pointer is used + * to traverse. + * + * @param array $lines + * @return Sabre_VObject_Element + */ + static private function readLine(&$lines) { + + $line = current($lines); + $lineNr = key($lines); + next($lines); + + // Components + if (stripos($line,"BEGIN:")===0) { + + // This is a component + $obj = new Sabre_VObject_Component(strtoupper(substr($line,6))); + + $nextLine = current($lines); + + while(stripos($nextLine,"END:")!==0) { + + $obj->add(self::readLine($lines)); + $nextLine = current($lines); + + if ($nextLine===false) + throw new Sabre_VObject_ParseException('Invalid VObject. Document ended prematurely.'); + + } + + // Checking component name of the 'END:' line. + if (substr($nextLine,4)!==$obj->name) { + throw new Sabre_VObject_ParseException('Invalid VObject, expected: "END:' . $obj->name . '" got: "' . $nextLine . '"'); + } + next($lines); + + return $obj; + + } + + // Properties + //$result = preg_match('/(?P[A-Z0-9-]+)(?:;(?P^(?([^:^\"]|\"([^\"]*)\")*))?"; + $regex = "/^(?P$token)$parameters:(?P.*)$/i"; + + $result = preg_match($regex,$line,$matches); + + if (!$result) { + throw new Sabre_VObject_ParseException('Invalid VObject, line ' . ($lineNr+1) . ' did not follow the icalendar/vcard format'); + } + + $propertyName = strtoupper($matches['name']); + $propertyValue = stripcslashes($matches['value']); + + if (isset(self::$elementMap[$propertyName])) { + $className = self::$elementMap[$propertyName]; + } else { + $className = 'Sabre_VObject_Property'; + } + + $obj = new $className($propertyName, $propertyValue); + + if ($matches['parameters']) { + + foreach(self::readParameters($matches['parameters']) as $param) { + $obj->add($param); + } + } + + return $obj; + + + } + + /** + * Reads a parameter list from a property + * + * This method returns an array of Sabre_VObject_Parameter + * + * @param string $parameters + * @return array + */ + static private function readParameters($parameters) { + + $token = '[A-Z0-9-]+'; + + $paramValue = '(?P[^\"^;]*|"[^"]*")'; + + $regex = "/(?<=^|;)(?P$token)(=$paramValue(?=$|;))?/i"; + preg_match_all($regex, $parameters, $matches, PREG_SET_ORDER); + + $params = array(); + foreach($matches as $match) { + + $value = isset($match['paramValue'])?$match['paramValue']:null; + + if (isset($value[0])) { + // Stripping quotes, if needed + if ($value[0] === '"') $value = substr($value,1,strlen($value)-2); + } else { + $value = ''; + } + + $params[] = new Sabre_VObject_Parameter($match['paramName'], stripcslashes($value)); + + } + + return $params; + + } + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Version.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Version.php new file mode 100755 index 0000000..8dce597 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/lib/Sabre/VObject/Version.php @@ -0,0 +1,24 @@ +pdo); + $this->assertTrue($backend instanceof Sabre_CalDAV_Backend_PDO); + + } + + /** + * @depends testConstruct + */ + function testGetCalendarsForUserNoCalendars() { + + $backend = new Sabre_CalDAV_Backend_PDO($this->pdo); + $calendars = $backend->getCalendarsForUser('principals/user2'); + $this->assertEquals(array(),$calendars); + + } + + /** + * @depends testConstruct + */ + function testCreateCalendarAndFetch() { + + $backend = new Sabre_CalDAV_Backend_PDO($this->pdo); + $returnedId = $backend->createCalendar('principals/user2','somerandomid',array( + '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VEVENT')) + )); + $calendars = $backend->getCalendarsForUser('principals/user2'); + + $elementCheck = array( + 'id' => $returnedId, + 'uri' => 'somerandomid', + '{DAV:}displayname' => '', + '{urn:ietf:params:xml:ns:caldav}calendar-description' => '', + ); + + $this->assertInternalType('array',$calendars); + $this->assertEquals(1,count($calendars)); + + foreach($elementCheck as $name=>$value) { + + $this->assertArrayHasKey($name, $calendars[0]); + $this->assertEquals($value,$calendars[0][$name]); + + } + + } + + /** + * @depends testConstruct + */ + function testUpdateCalendarAndFetch() { + + $backend = new Sabre_CalDAV_Backend_PDO($this->pdo); + + //Creating a new calendar + $newId = $backend->createCalendar('principals/user2','somerandomid',array()); + + // Updating the calendar + $result = $backend->updateCalendar($newId,array( + '{DAV:}displayname' => 'myCalendar', + )); + + // Verifying the result of the update + $this->assertEquals(true, $result); + + // Fetching all calendars from this user + $calendars = $backend->getCalendarsForUser('principals/user2'); + + // Checking if all the information is still correct + $elementCheck = array( + 'id' => $newId, + 'uri' => 'somerandomid', + '{DAV:}displayname' => 'myCalendar', + '{urn:ietf:params:xml:ns:caldav}calendar-description' => '', + '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => '', + '{http://calendarserver.org/ns/}getctag' => '2', + ); + + $this->assertInternalType('array',$calendars); + $this->assertEquals(1,count($calendars)); + + foreach($elementCheck as $name=>$value) { + + $this->assertArrayHasKey($name, $calendars[0]); + $this->assertEquals($value,$calendars[0][$name]); + + } + + } + + /** + * @depends testUpdateCalendarAndFetch + */ + function testUpdateCalendarUnknownProperty() { + + $backend = new Sabre_CalDAV_Backend_PDO($this->pdo); + + //Creating a new calendar + $newId = $backend->createCalendar('principals/user2','somerandomid',array()); + + // Updating the calendar + $result = $backend->updateCalendar($newId,array( + '{DAV:}displayname' => 'myCalendar', + '{DAV:}yourmom' => 'wittycomment', + )); + + // Verifying the result of the update + $this->assertEquals(array( + '403' => array('{DAV:}yourmom' => null), + '424' => array('{DAV:}displayname' => null), + ), $result); + + } + + /** + * @depends testCreateCalendarAndFetch + * @expectedException Sabre_DAV_Exception + */ + function testCreateCalendarIncorrectComponentSet() {; + + $backend = new Sabre_CalDAV_Backend_PDO($this->pdo); + + //Creating a new calendar + $newId = $backend->createCalendar('principals/user2','somerandomid',array( + '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => 'blabla', + )); + + } + + function testCreateCalendarObject() { + + $backend = new Sabre_CalDAV_Backend_PDO($this->pdo); + $returnedId = $backend->createCalendar('principals/user2','somerandomid',array()); + + $backend->createCalendarObject($returnedId, 'random-id', 'calendar-data'); + + $data = $backend->getCalendarObject($returnedId,'random-id'); + + $this->assertEquals('calendar-data', $data['calendardata']); + $this->assertEquals($returnedId, $data['calendarid']); + $this->assertEquals('random-id', $data['uri']); + + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Backend/AbstractTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Backend/AbstractTest.php new file mode 100755 index 0000000..bf0238c --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Backend/AbstractTest.php @@ -0,0 +1,25 @@ +assertEquals(false, $abstract->updateCalendar('randomid', array('{DAV:}displayname' => 'anything'))); + + } + +} + +class Sabre_CalDAV_Backend_AbstractMock extends Sabre_CalDAV_Backend_Abstract { + + function getCalendarsForUser($principalUri) { } + function createCalendar($principalUri,$calendarUri,array $properties) { } + function deleteCalendar($calendarId) { } + function getCalendarObjects($calendarId) { } + function getCalendarObject($calendarId,$objectUri) { } + function createCalendarObject($calendarId,$objectUri,$calendarData) { } + function updateCalendarObject($calendarId,$objectUri,$calendarData) { } + function deleteCalendarObject($calendarId,$objectUri) { } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Backend/Mock.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Backend/Mock.php new file mode 100755 index 0000000..23e4ae1 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Backend/Mock.php @@ -0,0 +1,201 @@ +calendarData = $calendarData; + + } + + /** + * Returns a list of calendars for a principal. + * + * Every project is an array with the following keys: + * * id, a unique id that will be used by other functions to modify the + * calendar. This can be the same as the uri or a database key. + * * uri, which the basename of the uri with which the calendar is + * accessed. + * * principalUri. The owner of the calendar. Almost always the same as + * principalUri passed to this method. + * + * Furthermore it can contain webdav properties in clark notation. A very + * common one is '{DAV:}displayname'. + * + * @param string $principalUri + * @return array + */ + function getCalendarsForUser($principalUri) { + + return array(); + + } + + /** + * Creates a new calendar for a principal. + * + * If the creation was a success, an id must be returned that can be used to reference + * this calendar in other methods, such as updateCalendar. + * + * This function must return a server-wide unique id that can be used + * later to reference the calendar. + * + * @param string $principalUri + * @param string $calendarUri + * @param array $properties + * @return string|int + */ + function createCalendar($principalUri,$calendarUri,array $properties) { + + throw new Exception('Not implemented'); + + } + + /** + * Updates properties on this node, + * + * The properties array uses the propertyName in clark-notation as key, + * and the array value for the property value. In the case a property + * should be deleted, the property value will be null. + * + * This method must be atomic. If one property cannot be changed, the + * entire operation must fail. + * + * If the operation was successful, true can be returned. + * If the operation failed, false can be returned. + * + * Deletion of a non-existant property is always succesful. + * + * Lastly, it is optional to return detailed information about any + * failures. In this case an array should be returned with the following + * structure: + * + * array( + * 403 => array( + * '{DAV:}displayname' => null, + * ), + * 424 => array( + * '{DAV:}owner' => null, + * ) + * ) + * + * In this example it was forbidden to update {DAV:}displayname. + * (403 Forbidden), which in turn also caused {DAV:}owner to fail + * (424 Failed Dependency) because the request needs to be atomic. + * + * @param string $calendarId + * @param array $properties + * @return bool|array + */ + public function updateCalendar($calendarId, array $properties) { + + return false; + + } + + /** + * Delete a calendar and all it's objects + * + * @param string $calendarId + * @return void + */ + public function deleteCalendar($calendarId) { + + throw new Exception('Not implemented'); + + } + + /** + * Returns all calendar objects within a calendar object. + * + * Every item contains an array with the following keys: + * * id - unique identifier which will be used for subsequent updates + * * calendardata - The iCalendar-compatible calnedar data + * * uri - a unique key which will be used to construct the uri. This can be any arbitrary string. + * * lastmodified - a timestamp of the last modification time + * * etag - An arbitrary string, surrounded by double-quotes. (e.g.: + * ' "abcdef"') + * * calendarid - The calendarid as it was passed to this function. + * + * Note that the etag is optional, but it's highly encouraged to return for + * speed reasons. + * + * The calendardata is also optional. If it's not returned + * 'getCalendarObject' will be called later, which *is* expected to return + * calendardata. + * + * @param string $calendarId + * @return array + */ + public function getCalendarObjects($calendarId) { + + return $this->calendarData[$calendarId]; + + } + + /** + * Returns information from a single calendar object, based on it's object + * uri. + * + * The returned array must have the same keys as getCalendarObjects. The + * 'calendardata' object is required here though, while it's not required + * for getCalendarObjects. + * + * @param string $calendarId + * @param string $objectUri + * @return array + */ + function getCalendarObject($calendarId,$objectUri) { + + if (!isset($this->calendarData[$calendarId][$objectUri])) { + throw new Sabre_DAV_Exception_FileNotFound('Object could not be found'); + } + return $this->calendarData[$calendarId][$objectUri]; + + } + + /** + * Creates a new calendar object. + * + * @param string $calendarId + * @param string $objectUri + * @param string $calendarData + * @return void + */ + function createCalendarObject($calendarId,$objectUri,$calendarData) { + + throw new Exception('Not implemented'); + + } + + /** + * Updates an existing calendarobject, based on it's uri. + * + * @param string $calendarId + * @param string $objectUri + * @param string $calendarData + * @return void + */ + function updateCalendarObject($calendarId,$objectUri,$calendarData) { + + throw new Exception('Not implemented'); + + } + + /** + * Deletes an existing calendar object. + * + * @param string $calendarId + * @param string $objectUri + * @return void + */ + function deleteCalendarObject($calendarId,$objectUri) { + + throw new Exception('Not implemented'); + + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php new file mode 100755 index 0000000..8814247 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php @@ -0,0 +1,48 @@ +markTestSkipped('MySQL driver is not available, or not properly configured'); + $pdo = Sabre_TestUtil::getMySQLDB(); + if (!$pdo) $this->markTestSkipped('Could not connect to mysql database'); + + $pdo->query('DROP TABLE IF EXISTS calendarobjects, calendars'); + + $pdo->query('CREATE TABLE calendarobjects ( + id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + calendardata TEXT, + uri VARCHAR(100), + calendarid INTEGER UNSIGNED NOT NULL, + lastmodified DATETIME + );'); + + $pdo->query('CREATE TABLE calendars ( + id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + principaluri VARCHAR(100), + displayname VARCHAR(100), + uri VARCHAR(100), + ctag INTEGER UNSIGNED NOT NULL DEFAULT \'0\', + description TEXT, + calendarorder INTEGER UNSIGNED NOT NULL DEFAULT \'0\', + calendarcolor VARCHAR(10), + timezone TEXT, + components VARCHAR(20) + );'); + + $this->pdo = $pdo; + + } + + function teardown() { + + $this->pdo = null; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php new file mode 100755 index 0000000..b52e5ec --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php @@ -0,0 +1,21 @@ +markTestSkipped('SQLite driver is not available'); + $this->pdo = Sabre_CalDAV_TestUtil::getSQLiteDB(); + + } + + function teardown() { + + $this->pdo = null; + unlink(SABRE_TEMPDIR . '/testdb.sqlite'); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/CalendarObjectTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/CalendarObjectTest.php new file mode 100755 index 0000000..c678135 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/CalendarObjectTest.php @@ -0,0 +1,294 @@ +markTestSkipped('SQLite driver is not available'); + $this->backend = Sabre_CalDAV_TestUtil::getBackend(); + $this->principalBackend = new Sabre_DAVACL_MockPrincipalBackend; + + $calendars = $this->backend->getCalendarsForUser('principals/user1'); + $this->assertEquals(1,count($calendars)); + $this->calendar = new Sabre_CalDAV_Calendar($this->principalBackend,$this->backend, $calendars[0]); + + } + + function teardown() { + + unset($this->calendar); + unset($this->backend); + + } + + function testSetup() { + + $children = $this->calendar->getChildren(); + $this->assertTrue($children[0] instanceof Sabre_CalDAV_CalendarObject); + + $this->assertInternalType('string',$children[0]->getName()); + $this->assertInternalType('string',$children[0]->get()); + $this->assertInternalType('string',$children[0]->getETag()); + $this->assertEquals('text/calendar', $children[0]->getContentType()); + + } + + /** + * @expectedException InvalidArgumentException + */ + function testInvalidArg1() { + + $obj = new Sabre_CalDAV_CalendarObject( + new Sabre_CalDAV_Backend_Mock(array()), + array(), + array() + ); + + } + + /** + * @expectedException InvalidArgumentException + */ + function testInvalidArg2() { + + $obj = new Sabre_CalDAV_CalendarObject( + new Sabre_CalDAV_Backend_Mock(array()), + array(), + array('calendarid' => '1') + ); + + } + + /** + * @depends testSetup + */ + function testPut() { + + $children = $this->calendar->getChildren(); + $this->assertTrue($children[0] instanceof Sabre_CalDAV_CalendarObject); + $newData = Sabre_CalDAV_TestUtil::getTestCalendarData(); + + $children[0]->put($newData); + $this->assertEquals($newData, $children[0]->get()); + + } + + /** + * @depends testSetup + */ + function testDelete() { + + $children = $this->calendar->getChildren(); + $this->assertTrue($children[0] instanceof Sabre_CalDAV_CalendarObject); + + $obj = $children[0]; + $obj->delete(); + + $children2 = $this->calendar->getChildren(); + $this->assertEquals(count($children)-1, count($children2)); + + } + + /** + * @depends testSetup + */ + function testGetLastModified() { + + $children = $this->calendar->getChildren(); + $this->assertTrue($children[0] instanceof Sabre_CalDAV_CalendarObject); + + $obj = $children[0]; + + $lastMod = $obj->getLastModified(); + $this->assertTrue(is_int($lastMod) || ctype_digit($lastMod)); + + } + + /** + * @depends testSetup + */ + function testGetSize() { + + $children = $this->calendar->getChildren(); + $this->assertTrue($children[0] instanceof Sabre_CalDAV_CalendarObject); + + $obj = $children[0]; + + $size = $obj->getSize(); + $this->assertInternalType('int', $size); + + } + + function testGetOwner() { + + $children = $this->calendar->getChildren(); + $this->assertTrue($children[0] instanceof Sabre_CalDAV_CalendarObject); + + $obj = $children[0]; + $this->assertEquals('principals/user1', $obj->getOwner()); + + } + + function testGetGroup() { + + $children = $this->calendar->getChildren(); + $this->assertTrue($children[0] instanceof Sabre_CalDAV_CalendarObject); + + $obj = $children[0]; + $this->assertNull($obj->getGroup()); + + } + + function testGetACL() { + + $expected = array( + array( + 'privilege' => '{DAV:}read', + 'principal' => 'principals/user1', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => 'principals/user1', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}read', + 'principal' => 'principals/user1/calendar-proxy-write', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => 'principals/user1/calendar-proxy-write', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}read', + 'principal' => 'principals/user1/calendar-proxy-read', + 'protected' => true, + ), + ); + + $children = $this->calendar->getChildren(); + $this->assertTrue($children[0] instanceof Sabre_CalDAV_CalendarObject); + + $obj = $children[0]; + $this->assertEquals($expected, $obj->getACL()); + + } + + /** + * @expectedException Sabre_DAV_Exception_MethodNotAllowed + */ + function testSetACL() { + + $children = $this->calendar->getChildren(); + $this->assertTrue($children[0] instanceof Sabre_CalDAV_CalendarObject); + + $obj = $children[0]; + $obj->setACL(array()); + + } + + function testGet() { + + $children = $this->calendar->getChildren(); + $this->assertTrue($children[0] instanceof Sabre_CalDAV_CalendarObject); + + $obj = $children[0]; + + $expected = "BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//Apple Inc.//iCal 4.0.1//EN +CALSCALE:GREGORIAN +BEGIN:VTIMEZONE +TZID:Asia/Seoul +BEGIN:DAYLIGHT +TZOFFSETFROM:+0900 +RRULE:FREQ=YEARLY;UNTIL=19880507T150000Z;BYMONTH=5;BYDAY=2SU +DTSTART:19870510T000000 +TZNAME:GMT+09:00 +TZOFFSETTO:+1000 +END:DAYLIGHT +BEGIN:STANDARD +TZOFFSETFROM:+1000 +DTSTART:19881009T000000 +TZNAME:GMT+09:00 +TZOFFSETTO:+0900 +END:STANDARD +END:VTIMEZONE +BEGIN:VEVENT +CREATED:20100225T154229Z +UID:39A6B5ED-DD51-4AFE-A683-C35EE3749627 +TRANSP:TRANSPARENT +SUMMARY:Something here +DTSTAMP:20100228T130202Z +DTSTART;TZID=Asia/Seoul:20100223T060000 +DTEND;TZID=Asia/Seoul:20100223T070000 +ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com +SEQUENCE:2 +END:VEVENT +END:VCALENDAR"; + + + + $this->assertEquals($expected, $obj->get()); + + } + + function testGetRefetch() { + + $backend = new Sabre_CalDAV_Backend_Mock(array( + 1 => array( + 'foo' => array( + 'calendardata' => 'foo', + 'uri' => 'foo' + ), + ) + )); + $obj = new Sabre_CalDAV_CalendarObject($backend, array(), array('calendarid' => 1, 'uri' => 'foo')); + + $this->assertEquals('foo', $obj->get()); + + } + + function testGetEtag1() { + + $objectInfo = array( + 'calendardata' => 'foo', + 'uri' => 'foo', + 'etag' => 'bar', + 'calendarid' => 1 + ); + + $backend = new Sabre_CalDAV_Backend_Mock(array()); + $obj = new Sabre_CalDAV_CalendarObject($backend, array(), $objectInfo); + + $this->assertEquals('bar', $obj->getETag()); + + } + + function testGetEtag2() { + + $objectInfo = array( + 'calendardata' => 'foo', + 'uri' => 'foo', + 'calendarid' => 1 + ); + + $backend = new Sabre_CalDAV_Backend_Mock(array()); + $obj = new Sabre_CalDAV_CalendarObject($backend, array(), $objectInfo); + + $this->assertEquals('"' . md5('foo') . '"', $obj->getETag()); + + } +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/CalendarQueryFilterTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/CalendarQueryFilterTest.php new file mode 100755 index 0000000..b974458 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/CalendarQueryFilterTest.php @@ -0,0 +1,201 @@ + array(), + '/c:iCalendar/c:vcalendar/c:vevent' => array(), + ); + + $this->assertTrue($calendarPlugin->validateFilters(Sabre_CalDAV_TestUtil::getTestCalendarData(),$filters)); + + } + + + /** + * @depends testCompFilter + */ + function testTimeRangeEvent() { + + $calendarPlugin = new Sabre_CalDAV_Plugin(Sabre_CalDAV_Util::getBackend()); + + $filters = array( + '/c:iCalendar/c:vcalendar' => array(), + '/c:iCalendar/c:vcalendar/c:vevent' => array( + 'time-range' => array( + 'start' => new DateTime('2006-01-04 00:00:00',new DateTimeZone('UTC')), + 'end' => new DateTime('2006-01-05 00:00:00',new DateTimeZone('UTC')), + ), + ), + ); + + + $this->assertFalse($calendarPlugin->validateFilters(Sabre_CalDAV_TestUtil::getTestCalendarData(),$filters)); + $filters['/c:iCalendar/c:vcalendar/c:vevent']['time-range']['end'] = new DateTime('2011-01-01 00:00:00', new DateTimeZone('UTC')); + + foreach(range(1,7) as $testCase) { + $this->assertTrue($calendarPlugin->validateFilters(Sabre_CalDAV_TestUtil::getTestCalendarData($testCase),$filters)); + } + + } + + /** + * @depends testCompFilter + * @depends testTimeRangeEvent + */ + function testTimeRangeTodo() { + + $calendarPlugin = new Sabre_CalDAV_Plugin(Sabre_CalDAV_Util::getBackend()); + + $filters = array( + '/c:iCalendar/c:vcalendar' => array(), + '/c:iCalendar/c:vcalendar/c:vtodo' => array( + 'time-range' => array( + 'start' => new DateTime('2006-01-01 00:00:00',new DateTimeZone('UTC')), + 'end' => new DateTime('2007-01-01 00:00:00', new DateTimeZone('UTC')), + ), + ), + ); + + + $tests = array( + 'dtstart_duration' => true, + 'dtstart_duration2'=> false, + 'due' => false, + 'due2' => true, + 'due_date' => true, + 'due_tz' => true, + 'due_dtstart' => true, + 'due_dtstart2' => false, + 'dtstart' => false, + 'dtstart2' => true, + 'dtstart_tz' => false, + 'dtstart_date' => false, + 'completed' => true, + 'completed2' => false, + 'created' => true, + 'created2' => false, + 'completedcreated' => true, + 'completedcreated2'=> false, + 'notime' => true, + ); + foreach($tests as $test=>$expectedResult) { + $this->assertEquals($expectedResult, $calendarPlugin->validateFilters(Sabre_CalDAV_TestUtil::getTestTodo($test),$filters), 'Testname: ' . $test); + } + + } + + /** + * @depends testTimeRangeEvent + * @expectedException Sabre_DAV_Exception_BadRequest + */ + function testTimeRangeNoDTSTART() { + + $calendarPlugin = new Sabre_CalDAV_Plugin(Sabre_CalDAV_Util::getBackend()); + + $filters = array( + '/c:iCalendar/c:vcalendar' => array(), + '/c:iCalendar/c:vcalendar/c:vevent' => array( + 'time-range' => array( + 'start' => new DateTime('2006-01-04 00:00:00', new DateTimeZone('UTC')), + 'end' => new DateTime('2011-01-05 00:00:00', new DateTimeZone('UTC')), + ), + ), + ); + + $calendarPlugin->validateFilters(Sabre_CalDAV_TestUtil::getTestCalendarData('X'),$filters); + + } + + + /** + * @depends testCompFilter + */ + function testPropFilter() { + + $calendarPlugin = new Sabre_CalDAV_Plugin(Sabre_CalDAV_Util::getBackend()); + + $filters = array( + '/c:iCalendar/c:vcalendar' => array(), + '/c:iCalendar/c:vcalendar/c:vevent' => array(), + '/c:iCalendar/c:vcalendar/c:vevent/c:uid' => array( + 'text-match' => array( + 'collation' => 'i;octet', + 'value' => 'DC6C50A017428C5216A2F1CD@example.com', + 'negate-condition' => false, + ), + ), + ); + + $this->assertFalse($calendarPlugin->validateFilters(Sabre_CalDAV_TestUtil::getTestCalendarData(),$filters)); + $filters['/c:iCalendar/c:vcalendar/c:vevent/c:uid']['text-match']['value'] = '39A6B5ED-DD51-4AFE-A683-C35EE3749627'; + $this->assertTrue($calendarPlugin->validateFilters(Sabre_CalDAV_TestUtil::getTestCalendarData(),$filters)); + + + } + + /** + * @depends testPropFilter + */ + function testParamFilter() { + + $calendarPlugin = new Sabre_CalDAV_Plugin(Sabre_CalDAV_Util::getBackend()); + + $filters = array( + '/c:iCalendar/c:vcalendar' => array(), + '/c:iCalendar/c:vcalendar/c:vevent' => array(), + '/c:iCalendar/c:vcalendar/c:vevent/c:attendee' => array( + 'text-match' => array( + 'collation' => 'i;ascii-casemap', + 'negate-condition' => false, + 'value' => 'mailto:lisa@example.com', + ), + ), + '/c:iCalendar/c:vcalendar/c:vevent/c:attendee/@partstat' => array( + 'text-match' => array( + 'collation' => 'i;ascii-casemap', + 'negate-condition' => false, + 'value' => 'needs-action', + ), + ), + ); + + $this->assertTrue($calendarPlugin->validateFilters(Sabre_CalDAV_TestUtil::getTestCalendarData(),$filters)); + + + } + + /** + * @depends testParamFilter + */ + function testUndefinedNegation() { + + $calendarPlugin = new Sabre_CalDAV_Plugin(Sabre_CalDAV_Util::getBackend()); + + $filters = array( + '/c:iCalendar/c:vcalendar' => array(), + '/c:iCalendar/c:vcalendar/c:vtodo' => array(), + '/c:iCalendar/c:vcalendar/c:vtodo/c:completed' => array( + 'is-not-defined' => true, + ), + '/c:iCalendar/c:vcalendar/c:vtodo/c:status' => array( + 'text-match' => array( + 'collation' => 'i;ascii-casemap', + 'negate-condition' => true, + 'value' => 'CANCELLED', + ), + ), + ); + + $this->assertFalse($calendarPlugin->validateFilters(Sabre_CalDAV_TestUtil::getTestCalendarData(),$filters)); + $this->assertTrue($calendarPlugin->validateFilters(Sabre_CalDAV_TestUtil::getTestTodo(),$filters)); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/CalendarTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/CalendarTest.php new file mode 100755 index 0000000..b12a4ae --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/CalendarTest.php @@ -0,0 +1,215 @@ +markTestSkipped('SQLite driver is not available'); + $this->backend = Sabre_CalDAV_TestUtil::getBackend(); + $this->principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); + + $this->calendars = $this->backend->getCalendarsForUser('principals/user1'); + $this->assertEquals(1, count($this->calendars)); + $this->calendar = new Sabre_CalDAV_Calendar($this->principalBackend, $this->backend, $this->calendars[0]); + + + } + + function teardown() { + + unset($this->backend); + + } + + function testSimple() { + + $this->assertEquals($this->calendars[0]['uri'], $this->calendar->getName()); + + } + + /** + * @depends testSimple + */ + function testUpdateProperties() { + + $result = $this->calendar->updateProperties(array( + '{DAV:}displayname' => 'NewName', + )); + + $this->assertEquals(true, $result); + + $calendars2 = $this->backend->getCalendarsForUser('principals/user1'); + $this->assertEquals('NewName',$calendars2[0]['{DAV:}displayname']); + + } + + /** + * @depends testSimple + */ + function testGetProperties() { + + $question = array( + '{DAV:}owner', + '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set', + '{urn:ietf:params:xml:ns:caldav}supported-calendar-data', + '{urn:ietf:params:xml:ns:caldav}supported-collation-set', + ); + + $result = $this->calendar->getProperties($question); + + foreach($question as $q) $this->assertArrayHasKey($q,$result); + + $this->assertEquals(array('VEVENT','VTODO'), $result['{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set']->getValue()); + + $this->assertTrue($result['{urn:ietf:params:xml:ns:caldav}supported-collation-set'] instanceof Sabre_CalDAV_Property_SupportedCollationSet); + + $this->assertTrue($result['{DAV:}owner'] instanceof Sabre_DAVACL_Property_Principal); + $this->assertEquals('principals/user1', $result['{DAV:}owner']->getHref()); + + } + + /** + * @expectedException Sabre_DAV_Exception_FileNotFound + * @depends testSimple + */ + function testGetChildNotFound() { + + $this->calendar->getChild('randomname'); + + } + + /** + * @depends testSimple + */ + function testGetChildren() { + + $children = $this->calendar->getChildren(); + $this->assertEquals(1,count($children)); + + $this->assertTrue($children[0] instanceof Sabre_CalDAV_CalendarObject); + + } + + /** + * @depends testGetChildren + */ + function testChildExists() { + + $this->assertFalse($this->calendar->childExists('foo')); + + $children = $this->calendar->getChildren(); + $this->assertTrue($this->calendar->childExists($children[0]->getName())); + } + + + + /** + * @expectedException Sabre_DAV_Exception_MethodNotAllowed + */ + function testCreateDirectory() { + + $this->calendar->createDirectory('hello'); + + } + + /** + * @expectedException Sabre_DAV_Exception_MethodNotAllowed + */ + function testSetName() { + + $this->calendar->setName('hello'); + + } + + function testGetLastModified() { + + $this->assertNull($this->calendar->getLastModified()); + + } + + function testCreateFile() { + + $file = fopen('php://memory','r+'); + fwrite($file,Sabre_CalDAV_TestUtil::getTestCalendarData()); + rewind($file); + + $this->calendar->createFile('hello',$file); + + $file = $this->calendar->getChild('hello'); + $this->assertTrue($file instanceof Sabre_CalDAV_CalendarObject); + + + } + + function testDelete() { + + $this->calendar->delete(); + + $calendars = $this->backend->getCalendarsForUser('principals/user1'); + $this->assertEquals(0, count($calendars)); + } + + function testGetOwner() { + + $this->assertEquals('principals/user1',$this->calendar->getOwner()); + + } + + function testGetGroup() { + + $this->assertNull($this->calendar->getGroup()); + + } + + function testGetACL() { + + $expected = array( + array( + 'privilege' => '{DAV:}read', + 'principal' => 'principals/user1', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => 'principals/user1', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}read', + 'principal' => 'principals/user1/calendar-proxy-write', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => 'principals/user1/calendar-proxy-write', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}read', + 'principal' => 'principals/user1/calendar-proxy-read', + 'protected' => true, + ), + ); + $this->assertEquals($expected, $this->calendar->getACL()); + + } + + /** + * @expectedException Sabre_DAV_Exception_MethodNotAllowed + */ + function testSetACL() { + + $this->calendar->setACL(array()); + + } + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/ICSExportPluginTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/ICSExportPluginTest.php new file mode 100755 index 0000000..b02ff05 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/ICSExportPluginTest.php @@ -0,0 +1,121 @@ +addPlugin($p); + + } + + function testBeforeMethod() { + + if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available'); + $cbackend = Sabre_CalDAV_TestUtil::getBackend(); + $pbackend = new Sabre_DAVACL_MockPrincipalBackend(); + + $props = array( + 'uri'=>'UUID-123467', + 'principaluri' => 'admin', + 'id' => 1, + ); + $tree = array( + new Sabre_CalDAV_Calendar($pbackend,$cbackend,$props), + ); + + $p = new Sabre_CalDAV_ICSExportPlugin(); + + $s = new Sabre_DAV_Server($tree); + $s->addPlugin($p); + $s->addPlugin(new Sabre_CalDAV_Plugin()); + + $h = new Sabre_HTTP_Request(array( + 'QUERY_STRING' => 'export', + )); + + $s->httpRequest = $h; + $s->httpResponse = new Sabre_HTTP_ResponseMock(); + + $this->assertFalse($p->beforeMethod('GET','UUID-123467?export')); + + $this->assertEquals('HTTP/1.1 200 OK',$s->httpResponse->status); + $this->assertEquals(array( + 'Content-Type' => 'text/calendar', + ), $s->httpResponse->headers); + + $obj = Sabre_VObject_Reader::read($s->httpResponse->body); + + $this->assertEquals(5,count($obj->children())); + $this->assertEquals(1,count($obj->VERSION)); + $this->assertEquals(1,count($obj->CALSCALE)); + $this->assertEquals(1,count($obj->PRODID)); + $this->assertEquals(1,count($obj->VTIMEZONE)); + $this->assertEquals(1,count($obj->VEVENT)); + + } + + function testBeforeMethodNoGET() { + + $p = new Sabre_CalDAV_ICSExportPlugin(); + + $s = new Sabre_DAV_Server(); + $s->addPlugin($p); + + $this->assertNull($p->beforeMethod('POST','UUID-123467?export')); + + } + + function testBeforeMethodNoExport() { + + $p = new Sabre_CalDAV_ICSExportPlugin(); + + $s = new Sabre_DAV_Server(); + $s->addPlugin($p); + + $this->assertNull($p->beforeMethod('GET','UUID-123467')); + + } + + /** + * @expectedException Sabre_DAVACL_Exception_NeedPrivileges + */ + function testACLIntegration() { + + if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available'); + $cbackend = Sabre_CalDAV_TestUtil::getBackend(); + $pbackend = new Sabre_DAVACL_MockPrincipalBackend(); + + $props = array( + 'uri'=>'UUID-123467', + 'principaluri' => 'admin', + 'id' => 1, + ); + $tree = array( + new Sabre_CalDAV_Calendar($pbackend,$cbackend,$props), + ); + + $p = new Sabre_CalDAV_ICSExportPlugin(); + + $s = new Sabre_DAV_Server($tree); + $s->addPlugin($p); + $s->addPlugin(new Sabre_CalDAV_Plugin()); + $s->addPlugin(new Sabre_DAVACL_Plugin()); + + $h = new Sabre_HTTP_Request(array( + 'QUERY_STRING' => 'export', + )); + + $s->httpRequest = $h; + $s->httpResponse = new Sabre_HTTP_ResponseMock(); + + $p->beforeMethod('GET','UUID-123467?export'); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/ICalendarUtilTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/ICalendarUtilTest.php new file mode 100755 index 0000000..64a6a1b --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/ICalendarUtilTest.php @@ -0,0 +1,233 @@ + + + + 2.0 + -//hacksw/handcal//NONSGML v1.0//EN + +'; + + $this->assertEquals($compare, $out); + + } + + function testWindowsLineEndings() { + + $in = array( + 'BEGIN:VCALENDAR', + 'VERSION:2.0', + 'PRODID:-//hacksw/handcal//NONSGML v1.0//EN', + 'END:VCALENDAR'); + + $out = Sabre_CalDAV_ICalendarUtil::toXCal(implode("\r\n",$in)); + + $compare = ' + + + 2.0 + -//hacksw/handcal//NONSGML v1.0//EN + +'; + + $this->assertEquals($compare, $out); + + + } + + function testEvent() { + + $in = array( + 'BEGIN:VCALENDAR', + 'VERSION:2.0', + 'PRODID:-//hacksw/handcal//NONSGML v1.0//EN', + 'BEGIN:VEVENT', + 'SUMMARY:meeting', + 'END:VEVENT', + 'END:VCALENDAR'); + + $out = Sabre_CalDAV_ICalendarUtil::toXCal(implode("\n",$in)); + + $compare = ' + + + 2.0 + -//hacksw/handcal//NONSGML v1.0//EN + + meeting + + +'; + + $this->assertEquals($compare, $out); + + } + + function testLineFolding() { + + $in = array( + 'BEGIN:VCALENDAR', + 'VERSION:2.0', + 'PRODID:-//hacksw/handcal//NONSGML v1.0//EN', + 'BEGIN:VEVENT', + 'SUMMARY:mee', + ' ting', + 'END:VEVENT', + 'END:VCALENDAR'); + + $out = Sabre_CalDAV_ICalendarUtil::toXCal(implode("\n",$in)); + + $compare = ' + + + 2.0 + -//hacksw/handcal//NONSGML v1.0//EN + + meeting + + +'; + + $this->assertEquals($compare, $out); + + } + + function testAttribute() { + + $in = array( + 'BEGIN:VCALENDAR', + 'VERSION:2.0', + 'PRODID:-//hacksw/handcal//NONSGML v1.0//EN', + 'BEGIN:VEVENT', + 'SUMMARY:meeting', + 'X-SABRE;att1=val1:This is the property content', + 'END:VEVENT', + 'END:VCALENDAR'); + + $out = Sabre_CalDAV_ICalendarUtil::toXCal(implode("\n",$in)); + + $compare = ' + + + 2.0 + -//hacksw/handcal//NONSGML v1.0//EN + + meeting + This is the property content + + +'; + + $this->assertEquals($compare, $out); + + } + + function testAttribute2() { + + $in = array( + 'BEGIN:VCALENDAR', + 'VERSION:2.0', + 'PRODID:-//hacksw/handcal//NONSGML v1.0//EN', + 'BEGIN:VEVENT', + 'SUMMARY;LANGUAGE=nl-NL:meeting', + 'X-SABRE;att1=val1;att2=val2:This is the property content', + 'END:VEVENT', + 'END:VCALENDAR'); + + $out = Sabre_CalDAV_ICalendarUtil::toXCal(implode("\n",$in)); + + $compare = ' + + + 2.0 + -//hacksw/handcal//NONSGML v1.0//EN + + meeting + This is the property content + + +'; + + $this->assertEquals($compare, $out); + + } + + function testValidateICalendarObjectValid() { + + $in = array( + 'BEGIN:VCALENDAR', + 'VERSION:2.0', + 'PRODID:-//hacksw/handcal//NONSGML v1.0//EN', + 'BEGIN:VEVENT', + 'SUMMARY;LANGUAGE=nl-NL:meeting', + 'X-SABRE;att1=val1;att2=val2:This is the property content', + 'END:VEVENT', + 'END:VCALENDAR'); + + $this->assertTrue(Sabre_CalDAV_ICalendarUtil::validateICalendarObject(implode("\n",$in),array('VEVENT'))); + + } + + /** + * @expectedException Sabre_CalDAV_Exception_InvalidICalendarObject + * @depends testValidateICalendarObjectValid + */ + function testValidateICalendarObjectNoData() { + + Sabre_CalDAV_ICalendarUtil::validateICalendarObject('',array('VEVENT')); + + } + + /** + * @expectedException Sabre_CalDAV_Exception_InvalidICalendarObject + * @depends testValidateICalendarObjectValid + */ + function testValidateICalendarObjectWrongObject() { + + $in = array( + 'BEGIN:VCALENDAR', + 'VERSION:2.0', + 'PRODID:-//hacksw/handcal//NONSGML v1.0//EN', + 'BEGIN:VEVENT', + 'SUMMARY;LANGUAGE=nl-NL:meeting', + 'X-SABRE;att1=val1;att2=val2:This is the property content', + 'END:VEVENT', + 'END:VCALENDAR'); + + Sabre_CalDAV_ICalendarUtil::validateICalendarObject(implode("\n",$in),array('VTODO')); + + } + + /** + * @expectedException Sabre_CalDAV_Exception_InvalidICalendarObject + * @depends testValidateICalendarObjectValid + */ + function testValidateICalendarObjectHasMethodProperty() { + + $in = array( + 'BEGIN:VCALENDAR', + 'VERSION:2.0', + 'METHOD:blabla', + 'PRODID:-//hacksw/handcal//NONSGML v1.0//EN', + 'BEGIN:VEVENT', + 'SUMMARY;LANGUAGE=nl-NL:meeting', + 'X-SABRE;att1=val1;att2=val2:This is the property content', + 'END:VEVENT', + 'END:VCALENDAR'); + + Sabre_CalDAV_ICalendarUtil::validateICalendarObject(implode("\n",$in),array('VEVENT')); + + } +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Issue166Test.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Issue166Test.php new file mode 100755 index 0000000..e7bfe77 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Issue166Test.php @@ -0,0 +1,49 @@ + array(), + '/c:iCalendar/c:vcalendar/c:vevent' => array( + 'time-range' => array( + 'start' => new DateTime('2011-12-01'), + 'end' => new DateTime('2012-02-01'), + ), + ), + ); + $this->assertTrue($plugin->validateFilters($input,$filters)); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/PluginTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/PluginTest.php new file mode 100755 index 0000000..16615f7 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/PluginTest.php @@ -0,0 +1,600 @@ +markTestSkipped('No PDO SQLite support'); + $this->caldavBackend = Sabre_CalDAV_TestUtil::getBackend(); + $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); + $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-read',array('principals/user1')); + $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-write',array('principals/user1')); + + $calendars = new Sabre_CalDAV_CalendarRootNode($principalBackend,$this->caldavBackend); + $principals = new Sabre_CalDAV_Principal_Collection($principalBackend); + + $root = new Sabre_DAV_SimpleDirectory('root'); + $root->addChild($calendars); + $root->addChild($principals); + + $objectTree = new Sabre_DAV_ObjectTree($root); + $this->server = new Sabre_DAV_Server($objectTree); + $this->server->debugExceptions = true; + $this->server->setBaseUri('/'); + $this->plugin = new Sabre_CalDAV_Plugin(); + $this->server->addPlugin($this->plugin); + + $this->response = new Sabre_HTTP_ResponseMock(); + $this->server->httpResponse = $this->response; + + } + + function testSimple() { + + $this->assertEquals(array('MKCALENDAR'), $this->plugin->getHTTPMethods('calendars/user1/randomnewcalendar')); + $this->assertEquals(array('calendar-access','calendar-proxy'), $this->plugin->getFeatures()); + $this->assertArrayHasKey('urn:ietf:params:xml:ns:caldav', $this->server->xmlNamespaces); + + } + + function testUnknownMethodPassThrough() { + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'MKBREAKFAST', + 'REQUEST_URI' => '/', + )); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 501 Not Implemented', $this->response->status,'Incorrect status returned. Full response body:' . $this->response->body); + + } + + function testReportPassThrough() { + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'REPORT', + 'HTTP_CONTENT_TYPE' => 'application/xml', + 'REQUEST_URI' => '/', + )); + $request->setBody(''); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 501 Not Implemented', $this->response->status); + + } + + function testMkCalendarBadLocation() { + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'MKCALENDAR', + 'REQUEST_URI' => '/blabla', + )); + + $body = ' + + + + Lisa\'s Events + Calendar restricted to events. + + + + + + + '; + + $request->setBody($body); + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 403 Forbidden', $this->response->status); + + } + + function testMkCalendarNoParentNode() { + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'MKCALENDAR', + 'REQUEST_URI' => '/doesntexist/calendar', + )); + + $body = ' + + + + Lisa\'s Events + Calendar restricted to events. + + + + + + + '; + + $request->setBody($body); + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 409 Conflict', $this->response->status); + + } + + function testMkCalendarExistingCalendar() { + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'MKCALENDAR', + 'REQUEST_URI' => '/calendars/user1/UUID-123467', + )); + + $body = ' + + + + Lisa\'s Events + Calendar restricted to events. + + + + + + + '; + + $request->setBody($body); + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 405 Method Not Allowed', $this->response->status); + + } + + function testMkCalendarSucceed() { + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'MKCALENDAR', + 'REQUEST_URI' => '/calendars/user1/NEWCALENDAR', + )); + + $timezone = 'BEGIN:VCALENDAR +PRODID:-//Example Corp.//CalDAV Client//EN +VERSION:2.0 +BEGIN:VTIMEZONE +TZID:US-Eastern +LAST-MODIFIED:19870101T000000Z +BEGIN:STANDARD +DTSTART:19671029T020000 +RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 +TZOFFSETFROM:-0400 +TZOFFSETTO:-0500 +TZNAME:Eastern Standard Time (US & Canada) +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:19870405T020000 +RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4 +TZOFFSETFROM:-0500 +TZOFFSETTO:-0400 +TZNAME:Eastern Daylight Time (US & Canada) +END:DAYLIGHT +END:VTIMEZONE +END:VCALENDAR'; + + $body = ' + + + + Lisa\'s Events + Calendar restricted to events. + + + + + + + '; + + $request->setBody($body); + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 201 Created', $this->response->status,'Invalid response code received. Full response body: ' .$this->response->body); + + $calendars = $this->caldavBackend->getCalendarsForUser('principals/user1'); + $this->assertEquals(2, count($calendars)); + + $newCalendar = null; + foreach($calendars as $calendar) { + if ($calendar['uri'] === 'NEWCALENDAR') { + $newCalendar = $calendar; + break; + } + } + + $this->assertInternalType('array',$newCalendar); + + $keys = array( + 'uri' => 'NEWCALENDAR', + 'id' => null, + '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar restricted to events.', + '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => $timezone, + '{DAV:}displayname' => 'Lisa\'s Events', + '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => null, + ); + + foreach($keys as $key=>$value) { + + $this->assertArrayHasKey($key, $newCalendar); + + if (is_null($value)) continue; + $this->assertEquals($value, $newCalendar[$key]); + + } + $sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set'; + $this->assertTrue($newCalendar[$sccs] instanceof Sabre_CalDAV_Property_SupportedCalendarComponentSet); + $this->assertEquals(array('VEVENT'),$newCalendar[$sccs]->getValue()); + + } + + function testMkCalendarEmptyBodySucceed() { + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'MKCALENDAR', + 'REQUEST_URI' => '/calendars/user1/NEWCALENDAR', + )); + + $request->setBody(''); + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 201 Created', $this->response->status,'Invalid response code received. Full response body: ' .$this->response->body); + + $calendars = $this->caldavBackend->getCalendarsForUser('principals/user1'); + $this->assertEquals(2, count($calendars)); + + $newCalendar = null; + foreach($calendars as $calendar) { + if ($calendar['uri'] === 'NEWCALENDAR') { + $newCalendar = $calendar; + break; + } + } + + $this->assertInternalType('array',$newCalendar); + + $keys = array( + 'uri' => 'NEWCALENDAR', + 'id' => null, + '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => null, + ); + + foreach($keys as $key=>$value) { + + $this->assertArrayHasKey($key, $newCalendar); + + if (is_null($value)) continue; + $this->assertEquals($value, $newCalendar[$key]); + + } + $sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set'; + $this->assertTrue($newCalendar[$sccs] instanceof Sabre_CalDAV_Property_SupportedCalendarComponentSet); + $this->assertEquals(array('VEVENT','VTODO'),$newCalendar[$sccs]->getValue()); + + } + + function testPrincipalProperties() { + + $httpRequest = new Sabre_HTTP_Request(array( + 'HTTP_HOST' => 'sabredav.org', + )); + $this->server->httpRequest = $httpRequest; + + $props = $this->server->getPropertiesForPath('/principals/user1',array( + '{urn:ietf:params:xml:ns:caldav}calendar-home-set', + '{urn:ietf:params:xml:ns:caldav}calendar-user-address-set', + '{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}calendar-proxy-read-for', + '{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}calendar-proxy-write-for', + )); + + $this->assertArrayHasKey(0,$props); + $this->assertArrayHasKey(200,$props[0]); + $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}calendar-home-set',$props[0][200]); + + + $prop = $props[0][200]['{urn:ietf:params:xml:ns:caldav}calendar-home-set']; + $this->assertTrue($prop instanceof Sabre_DAV_Property_Href); + $this->assertEquals('calendars/user1/',$prop->getHref()); + + $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}calendar-user-address-set',$props[0][200]); + $prop = $props[0][200]['{urn:ietf:params:xml:ns:caldav}calendar-user-address-set']; + $this->assertTrue($prop instanceof Sabre_DAV_Property_HrefList); + $this->assertEquals(array('mailto:user1.sabredav@sabredav.org','/principals/user1'),$prop->getHrefs()); + + $this->assertArrayHasKey('{http://calendarserver.org/ns/}calendar-proxy-read-for', $props[0][200]); + $prop = $props[0][200]['{http://calendarserver.org/ns/}calendar-proxy-read-for']; + $this->assertInstanceOf('Sabre_DAV_Property_HrefList', $prop); + $this->assertEquals(array('principals/admin'), $prop->getHrefs()); + + $this->assertArrayHasKey('{http://calendarserver.org/ns/}calendar-proxy-write-for', $props[0][200]); + $prop = $props[0][200]['{http://calendarserver.org/ns/}calendar-proxy-write-for']; + $this->assertInstanceOf('Sabre_DAV_Property_HrefList', $prop); + $this->assertEquals(array('principals/admin'), $prop->getHrefs()); + + } + + function testSupportedReportSetPropertyNonCalendar() { + + $props = $this->server->getPropertiesForPath('/calendars/user1',array( + '{DAV:}supported-report-set', + )); + + $this->assertArrayHasKey(0,$props); + $this->assertArrayHasKey(200,$props[0]); + $this->assertArrayHasKey('{DAV:}supported-report-set',$props[0][200]); + + $prop = $props[0][200]['{DAV:}supported-report-set']; + + $this->assertTrue($prop instanceof Sabre_DAV_Property_SupportedReportSet); + $value = array( + ); + $this->assertEquals($value,$prop->getValue()); + + } + + /** + * @depends testSupportedReportSetPropertyNonCalendar + */ + function testSupportedReportSetProperty() { + + $props = $this->server->getPropertiesForPath('/calendars/user1/UUID-123467',array( + '{DAV:}supported-report-set', + )); + + $this->assertArrayHasKey(0,$props); + $this->assertArrayHasKey(200,$props[0]); + $this->assertArrayHasKey('{DAV:}supported-report-set',$props[0][200]); + + $prop = $props[0][200]['{DAV:}supported-report-set']; + + $this->assertTrue($prop instanceof Sabre_DAV_Property_SupportedReportSet); + $value = array( + '{urn:ietf:params:xml:ns:caldav}calendar-multiget', + '{urn:ietf:params:xml:ns:caldav}calendar-query', + ); + $this->assertEquals($value,$prop->getValue()); + + } + + /** + * @depends testSupportedReportSetProperty + */ + function testCalendarMultiGetReport() { + + $body = + '' . + '' . + '' . + ' ' . + ' ' . + '' . + '/calendars/user1/UUID-123467/UUID-2345' . + ''; + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_URI' => '/calendars/user1', + 'HTTP_DEPTH' => '1', + )); + $request->setBody($body); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status); + + $xml = simplexml_load_string(Sabre_DAV_XMLUtil::convertDAVNamespace($this->response->body)); + + $xml->registerXPathNamespace('d','urn:DAV'); + $xml->registerXPathNamespace('c','urn:ietf:params:xml:ns:caldav'); + + $check = array( + '/d:multistatus', + '/d:multistatus/d:response', + '/d:multistatus/d:response/d:href', + '/d:multistatus/d:response/d:propstat', + '/d:multistatus/d:response/d:propstat/d:prop', + '/d:multistatus/d:response/d:propstat/d:prop/d:getetag', + '/d:multistatus/d:response/d:propstat/d:prop/c:calendar-data', + '/d:multistatus/d:response/d:propstat/d:status' => 'HTTP/1.1 200 OK', + ); + + foreach($check as $v1=>$v2) { + + $xpath = is_int($v1)?$v2:$v1; + + $result = $xml->xpath($xpath); + $this->assertEquals(1,count($result)); + + if (!is_int($v1)) $this->assertEquals($v2,(string)$result[0]); + + } + + } + + /** + * @depends testSupportedReportSetProperty + * @depends testCalendarMultiGetReport + */ + function testCalendarQueryReport() { + + $body = + '' . + '' . + '' . + ' ' . + ' ' . + '' . + '' . + ' ' . + ' ' . + ' ' . + '' . + ''; + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_URI' => '/calendars/user1//UUID-123467', + 'HTTP_DEPTH' => '1', + )); + $request->setBody($body); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'Received an unexpected status. Full response body: ' . $this->response->body); + + $xml = simplexml_load_string(Sabre_DAV_XMLUtil::convertDAVNamespace($this->response->body)); + + $xml->registerXPathNamespace('d','urn:DAV'); + $xml->registerXPathNamespace('c','urn:ietf:params:xml:ns:caldav'); + + $check = array( + '/d:multistatus', + '/d:multistatus/d:response', + '/d:multistatus/d:response/d:href', + '/d:multistatus/d:response/d:propstat', + '/d:multistatus/d:response/d:propstat/d:prop', + '/d:multistatus/d:response/d:propstat/d:prop/d:getetag', + '/d:multistatus/d:response/d:propstat/d:prop/c:calendar-data', + '/d:multistatus/d:response/d:propstat/d:status' => 'HTTP/1.1 200 OK', + ); + + foreach($check as $v1=>$v2) { + + $xpath = is_int($v1)?$v2:$v1; + + $result = $xml->xpath($xpath); + $this->assertEquals(1,count($result), 'We expected 1 ' . $xpath . ' elements. We\'ve found ' . count($result) . '. Full result: ' . $this->response->body); + + if (!is_int($v1)) $this->assertEquals($v2,(string)$result[0]); + + } + + } + + /** + * @depends testCalendarQueryReport + */ + function testCalendarQueryReportNoFilters() { + + $body = + '' . + '' . + '' . + ' ' . + ' ' . + '' . + ''; + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_URI' => '/calendars/user1//UUID-123467', + )); + $request->setBody($body); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 400 Bad request',$this->response->status,'Received an unexpected status. Full response body: ' . $this->response->body); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Principal/CollectionTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Principal/CollectionTest.php new file mode 100755 index 0000000..0495df1 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Principal/CollectionTest.php @@ -0,0 +1,18 @@ +getChildForPrincipal(array( + 'uri' => 'principals/admin', + )); + $this->assertInstanceOf('Sabre_CalDAV_Principal_User', $r); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Principal/ProxyReadTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Principal/ProxyReadTest.php new file mode 100755 index 0000000..d269d89 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Principal/ProxyReadTest.php @@ -0,0 +1,98 @@ + 'principal/user', + )); + $this->backend = $backend; + return $principal; + + } + + function testGetName() { + + $i = $this->getInstance(); + $this->assertEquals('calendar-proxy-read', $i->getName()); + + } + function testGetDisplayName() { + + $i = $this->getInstance(); + $this->assertEquals('calendar-proxy-read', $i->getDisplayName()); + + } + + function testGetLastModified() { + + $i = $this->getInstance(); + $this->assertNull($i->getLastModified()); + + } + + /** + * @expectedException Sabre_DAV_Exception_Forbidden + */ + function testDelete() { + + $i = $this->getInstance(); + $i->delete(); + + } + + /** + * @expectedException Sabre_DAV_Exception_Forbidden + */ + function testSetName() { + + $i = $this->getInstance(); + $i->setName('foo'); + + } + + function testGetAlternateUriSet() { + + $i = $this->getInstance(); + $this->assertEquals(array(), $i->getAlternateUriSet()); + + } + + function testGetPrincipalUri() { + + $i = $this->getInstance(); + $this->assertEquals('principal/user/calendar-proxy-read', $i->getPrincipalUrl()); + + } + + function testGetGroupMemberSet() { + + $i = $this->getInstance(); + $this->assertEquals(array(), $i->getGroupMemberSet()); + + } + + function testGetGroupMembership() { + + $i = $this->getInstance(); + $this->assertEquals(array(), $i->getGroupMembership()); + + } + + function testSetGroupMemberSet() { + + $i = $this->getInstance(); + $i->setGroupMemberSet(array('principals/foo')); + + $expected = array( + $i->getPrincipalUrl() => array('principals/foo') + ); + + $this->assertEquals($expected, $this->backend->groupMembers); + + } +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Principal/ProxyWriteTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Principal/ProxyWriteTest.php new file mode 100755 index 0000000..02bce59 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Principal/ProxyWriteTest.php @@ -0,0 +1,36 @@ + 'principal/user', + )); + $this->backend = $backend; + return $principal; + + } + + function testGetName() { + + $i = $this->getInstance(); + $this->assertEquals('calendar-proxy-write', $i->getName()); + + } + function testGetDisplayName() { + + $i = $this->getInstance(); + $this->assertEquals('calendar-proxy-write', $i->getDisplayName()); + + } + + function testGetPrincipalUri() { + + $i = $this->getInstance(); + $this->assertEquals('principal/user/calendar-proxy-write', $i->getPrincipalUrl()); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Principal/UserTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Principal/UserTest.php new file mode 100755 index 0000000..09689e9 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Principal/UserTest.php @@ -0,0 +1,104 @@ + 'principal/user', + )); + + } + + /** + * @expectedException Sabre_DAV_Exception_Forbidden + */ + function testCreateFile() { + + $u = $this->getInstance(); + $u->createFile('test'); + + } + + /** + * @expectedException Sabre_DAV_Exception_Forbidden + */ + function testCreateDirectory() { + + $u = $this->getInstance(); + $u->createDirectory('test'); + + } + + function testGetChildProxyRead() { + + $u = $this->getInstance(); + $child = $u->getChild('calendar-proxy-read'); + $this->assertInstanceOf('Sabre_CalDAV_Principal_ProxyRead', $child); + + } + + function testGetChildProxyWrite() { + + $u = $this->getInstance(); + $child = $u->getChild('calendar-proxy-write'); + $this->assertInstanceOf('Sabre_CalDAV_Principal_ProxyWrite', $child); + + } + + /** + * @expectedException Sabre_DAV_Exception_FileNotFound + */ + function testGetChildNotFound() { + + $u = $this->getInstance(); + $child = $u->getChild('foo'); + + } + + function testGetChildren() { + + $u = $this->getInstance(); + $children = $u->getChildren(); + $this->assertEquals(2, count($children)); + $this->assertInstanceOf('Sabre_CalDAV_Principal_ProxyRead', $children[0]); + $this->assertInstanceOf('Sabre_CalDAV_Principal_ProxyWrite', $children[1]); + + } + + function testChildExist() { + + $u = $this->getInstance(); + $this->assertTrue($u->childExists('calendar-proxy-read')); + $this->assertTrue($u->childExists('calendar-proxy-write')); + $this->assertFalse($u->childExists('foo')); + + } + + function testGetACL() { + + $expected = array( + array( + 'privilege' => '{DAV:}read', + 'principal' => 'principal/user', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}read', + 'principal' => 'principal/user/calendar-proxy-read', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}read', + 'principal' => 'principal/user/calendar-proxy-write', + 'protected' => true, + ), + ); + + $u = $this->getInstance(); + $this->assertEquals($expected, $u->getACL()); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Property/SupportedCalendarComponentSetTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Property/SupportedCalendarComponentSetTest.php new file mode 100755 index 0000000..a0b90f7 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Property/SupportedCalendarComponentSetTest.php @@ -0,0 +1,66 @@ +assertEquals(array('VEVENT'), $sccs->getValue()); + + } + + /** + * @depends testSimple + */ + function testSerialize() { + + $property = new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VEVENT','VJOURNAL')); + + $doc = new DOMDocument(); + $root = $doc->createElement('d:root'); + $root->setAttribute('xmlns:d','DAV:'); + $root->setAttribute('xmlns:cal',Sabre_CalDAV_Plugin::NS_CALDAV); + + $doc->appendChild($root); + $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('rootdir')); + $server = new Sabre_DAV_Server($objectTree); + + $property->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' +' . +'' . +'' . +' +', $xml); + + } + + /** + * @depends testSimple + */ + function testUnserializer() { + + $xml = ' +' . +'' . +'' . +''; + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml); + + $property = Sabre_CalDAV_Property_SupportedCalendarComponentSet::unserialize($dom->firstChild); + + $this->assertTrue($property instanceof Sabre_CalDAV_Property_SupportedCalendarComponentSet); + $this->assertEquals(array( + 'VEVENT', + 'VJOURNAL', + ), + $property->getValue()); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Property/SupportedCalendarDataTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Property/SupportedCalendarDataTest.php new file mode 100755 index 0000000..5bd691e --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Property/SupportedCalendarDataTest.php @@ -0,0 +1,40 @@ +createElement('d:root'); + $root->setAttribute('xmlns:d','DAV:'); + $root->setAttribute('xmlns:cal',Sabre_CalDAV_Plugin::NS_CALDAV); + + $doc->appendChild($root); + $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('rootdir')); + $server = new Sabre_DAV_Server($objectTree); + + $property->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' +' . +'' . +' +', $xml); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Property/SupportedCollationSetTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Property/SupportedCollationSetTest.php new file mode 100755 index 0000000..f9da369 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/Property/SupportedCollationSetTest.php @@ -0,0 +1,42 @@ +createElement('d:root'); + $root->setAttribute('xmlns:d','DAV:'); + $root->setAttribute('xmlns:cal',Sabre_CalDAV_Plugin::NS_CALDAV); + + $doc->appendChild($root); + $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('rootdir')); + $server = new Sabre_DAV_Server($objectTree); + + $property->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' +' . +'i;ascii-casemap' . +'i;octet' . +'i;unicode-casemap' . +' +', $xml); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/ServerTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/ServerTest.php new file mode 100755 index 0000000..2369cfd --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/ServerTest.php @@ -0,0 +1,31 @@ +markTestSkipped('SQLite driver is not available'); + $pdo = Sabre_CalDAV_TestUtil::getSQLiteDB(); + $server = new Sabre_CalDAV_Server($pdo); + + $authPlugin = $server->getPlugin('auth'); + $this->assertTrue($authPlugin instanceof Sabre_DAV_Auth_Plugin); + + $caldavPlugin = $server->getPlugin('caldav'); + $this->assertTrue($caldavPlugin instanceof Sabre_CalDAV_Plugin); + + $node = $server->tree->getNodeForPath(''); + $this->assertTrue($node instanceof Sabre_DAV_SimpleCollection); + + $this->assertEquals('root', $node->getName()); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/TestUtil.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/TestUtil.php new file mode 100755 index 0000000..c31cbd5 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/TestUtil.php @@ -0,0 +1,207 @@ +setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); + $pdo->query(' +CREATE TABLE calendarobjects ( + id integer primary key asc, + calendardata text, + uri text, + calendarid integer, + lastmodified integer +); +'); + + $pdo->query(' +CREATE TABLE calendars ( + id integer primary key asc, + principaluri text, + displayname text, + uri text, + ctag integer, + description text, + calendarorder integer, + calendarcolor text, + timezone text, + components text +);'); + + $pdo->query('INSERT INTO calendars (principaluri,displayname,uri,description,calendarorder,calendarcolor,components) + VALUES ("principals/user1","user1 calendar","UUID-123467","Calendar description", "1", "#FF0000","VEVENT,VTODO");'); + + $stmt = $pdo->prepare('INSERT INTO calendarobjects (calendardata, uri, calendarid, lastmodified) VALUES (?, "UUID-2345", 1, ?)'); + $stmt->execute(array(self::getTestCalendarData(),time())); + + return $pdo; + + } + + static function getTestCalendarData($type = 1) { + + $calendarData = 'BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//Apple Inc.//iCal 4.0.1//EN +CALSCALE:GREGORIAN +BEGIN:VTIMEZONE +TZID:Asia/Seoul +BEGIN:DAYLIGHT +TZOFFSETFROM:+0900 +RRULE:FREQ=YEARLY;UNTIL=19880507T150000Z;BYMONTH=5;BYDAY=2SU +DTSTART:19870510T000000 +TZNAME:GMT+09:00 +TZOFFSETTO:+1000 +END:DAYLIGHT +BEGIN:STANDARD +TZOFFSETFROM:+1000 +DTSTART:19881009T000000 +TZNAME:GMT+09:00 +TZOFFSETTO:+0900 +END:STANDARD +END:VTIMEZONE +BEGIN:VEVENT +CREATED:20100225T154229Z +UID:39A6B5ED-DD51-4AFE-A683-C35EE3749627 +TRANSP:TRANSPARENT +SUMMARY:Something here +DTSTAMP:20100228T130202Z'; + + switch($type) { + case 1 : + $calendarData.="\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDTEND;TZID=Asia/Seoul:20100223T070000\n"; + break; + case 2 : + $calendarData.="\nDTSTART:20100223T060000\nDTEND:20100223T070000\n"; + break; + case 3 : + $calendarData.="\nDTSTART;VALUE=DATE:20100223\nDTEND;VALUE=DATE:20100223\n"; + break; + case 4 : + $calendarData.="\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDURATION:PT1H\n"; + break; + case 5 : + $calendarData.="\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDURATION:-P5D\n"; + break; + case 6 : + $calendarData.="\nDTSTART;VALUE=DATE:20100223\n"; + break; + case 7 : + $calendarData.="\nDTSTART;VALUE=DATETIME:20100223T060000\n"; + break; + + // No DTSTART, so intentionally broken + case 'X' : + $calendarData.="\n"; + break; + } + + + $calendarData.='ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com +SEQUENCE:2 +END:VEVENT +END:VCALENDAR'; + + return $calendarData; + + } + + static function getTestTODO($type = 'due') { + + switch($type) { + + case 'due' : + $extra = "DUE:20100104T000000Z"; + break; + case 'due2' : + $extra = "DUE:20060104T000000Z"; + break; + case 'due_date' : + $extra = "DUE;VALUE=DATE:20060104"; + break; + case 'due_tz' : + $extra = "DUE;TZID=Asia/Seoul:20060104T000000Z"; + break; + case 'due_dtstart' : + $extra = "DTSTART:20050223T060000Z\nDUE:20060104T000000Z"; + break; + case 'due_dtstart2' : + $extra = "DTSTART:20090223T060000Z\nDUE:20100104T000000Z"; + break; + case 'dtstart' : + $extra = 'DTSTART:20100223T060000Z'; + break; + case 'dtstart2' : + $extra = 'DTSTART:20060223T060000Z'; + break; + case 'dtstart_date' : + $extra = 'DTSTART;VALUE=DATE:20100223'; + break; + case 'dtstart_tz' : + $extra = 'DTSTART;TZID=Asia/Seoul:20100223T060000Z'; + break; + case 'dtstart_duration' : + $extra = "DTSTART:20061023T060000Z\nDURATION:PT1H"; + break; + case 'dtstart_duration2' : + $extra = "DTSTART:20101023T060000Z\nDURATION:PT1H"; + break; + case 'completed' : + $extra = 'COMPLETED:20060601T000000Z'; + break; + case 'completed2' : + $extra = 'COMPLETED:20090601T000000Z'; + break; + case 'created' : + $extra = 'CREATED:20060601T000000Z'; + break; + case 'created2' : + $extra = 'CREATED:20090601T000000Z'; + break; + case 'completedcreated' : + $extra = "CREATED:20060601T000000Z\nCOMPLETED:20070101T000000Z"; + break; + case 'completedcreated2' : + $extra = "CREATED:20090601T000000Z\nCOMPLETED:20100101T000000Z"; + break; + case 'notime' : + $extra = 'X-FILLER:oh hello'; + break; + default : + throw new Exception('Unknown type: ' . $type); + + } + + $todo = 'BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//Example Corp.//CalDAV Client//EN +BEGIN:VTODO +DTSTAMP:20060205T235335Z +' . $extra . ' +STATUS:NEEDS-ACTION +SUMMARY:Task #1 +UID:DDDEEB7915FA61233B861457@example.com +BEGIN:VALARM +ACTION:AUDIO +TRIGGER;RELATED=START:-PT10M +END:VALARM +END:VTODO +END:VCALENDAR'; + + return $todo; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/UserCalendarsTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/UserCalendarsTest.php new file mode 100755 index 0000000..a8204e1 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/UserCalendarsTest.php @@ -0,0 +1,174 @@ +markTestSkipped('SQLite driver is not available'); + $this->backend = Sabre_CalDAV_TestUtil::getBackend(); + $this->principalBackend = new Sabre_DAVACL_MockPrincipalBackend('realm'); + $this->usercalendars = new Sabre_CalDAV_UserCalendars($this->principalBackend, $this->backend, 'principals/user1'); + + } + + function testSimple() { + + $this->assertEquals('user1',$this->usercalendars->getName()); + + } + + /** + * @expectedException Sabre_DAV_Exception_FileNotFound + * @depends testSimple + */ + function testGetChildNotFound() { + + $this->usercalendars->getChild('randomname'); + + } + + function testChildExists() { + + $this->assertFalse($this->usercalendars->childExists('foo')); + $this->assertTrue($this->usercalendars->childExists('UUID-123467')); + + } + + function testGetOwner() { + + $this->assertEquals('principals/user1', $this->usercalendars->getOwner()); + + } + + function testGetGroup() { + + $this->assertNull($this->usercalendars->getGroup()); + + } + + function testGetACL() { + + $expected = array( + array( + 'privilege' => '{DAV:}read', + 'principal' => 'principals/user1', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => 'principals/user1', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}read', + 'principal' => 'principals/user1/calendar-proxy-write', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => 'principals/user1/calendar-proxy-write', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}read', + 'principal' => 'principals/user1/calendar-proxy-read', + 'protected' => true, + ), + ); + $this->assertEquals($expected, $this->usercalendars->getACL()); + + } + + /** + * @expectedException Sabre_DAV_Exception_MethodNotAllowed + */ + function testSetACL() { + + $this->usercalendars->setACL(array()); + + } + + /** + * @expectedException Sabre_DAV_Exception_Forbidden + * @depends testSimple + */ + function testSetName() { + + $this->usercalendars->setName('bla'); + + } + + /** + * @expectedException Sabre_DAV_Exception_Forbidden + * @depends testSimple + */ + function testDelete() { + + $this->usercalendars->delete(); + + } + + /** + * @depends testSimple + */ + function testGetLastModified() { + + $this->assertNull($this->usercalendars->getLastModified()); + + } + + /** + * @expectedException Sabre_DAV_Exception_MethodNotAllowed + * @depends testSimple + */ + function testCreateFile() { + + $this->usercalendars->createFile('bla'); + + } + + + /** + * @expectedException Sabre_DAV_Exception_MethodNotAllowed + * @depends testSimple + */ + function testCreateDirectory() { + + $this->usercalendars->createDirectory('bla'); + + } + + /** + * @depends testSimple + */ + function testCreateExtendedCollection() { + + $result = $this->usercalendars->createExtendedCollection('newcalendar', array('{DAV:}collection', '{urn:ietf:params:xml:ns:caldav}calendar'), array()); + $this->assertNull($result); + $cals = $this->backend->getCalendarsForUser('principals/user1'); + $this->assertEquals(2,count($cals)); + + } + + /** + * @expectedException Sabre_DAV_Exception_InvalidResourceType + * @depends testSimple + */ + function testCreateExtendedCollectionBadResourceType() { + + $this->usercalendars->createExtendedCollection('newcalendar', array('{DAV:}collection','{DAV:}blabla'), array()); + + } + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/VersionTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/VersionTest.php new file mode 100755 index 0000000..717edd8 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/VersionTest.php @@ -0,0 +1,15 @@ +assertEquals(-1, version_compare('1.0.0',$v)); + + $s = Sabre_CalDAV_Version::STABILITY; + $this->assertTrue($s == 'alpha' || $s == 'beta' || $s =='stable'); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/XMLUtilTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/XMLUtilTest.php new file mode 100755 index 0000000..fc97b1e --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CalDAV/XMLUtilTest.php @@ -0,0 +1,325 @@ +assertEquals('+1 weeks', Sabre_CalDAV_XMLUtil::parseICalendarDuration('P1W')); + $this->assertEquals('+5 days', Sabre_CalDAV_XMLUtil::parseICalendarDuration('P5D')); + $this->assertEquals('+5 days 3 hours 50 minutes 12 seconds', Sabre_CalDAV_XMLUtil::parseICalendarDuration('P5DT3H50M12S')); + $this->assertEquals('-1 weeks 50 minutes', Sabre_CalDAV_XMLUtil::parseICalendarDuration('-P1WT50M')); + $this->assertEquals('+50 days 3 hours 2 seconds', Sabre_CalDAV_XMLUtil::parseICalendarDuration('+P50DT3H2S')); + + } + + /** + * @expectedException Sabre_DAV_Exception_BadRequest + */ + function testParseICalendarDurationFail() { + + Sabre_CalDAV_XMLUtil::parseICalendarDuration('P1X'); + + } + + function testCompFilter() { + + $xml = << + + + + + +XML; + + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml); + $expected = array( + '/c:iCalendar/c:vcalendar' => array(), + '/c:iCalendar/c:vcalendar/c:vevent' => array(), + ); + + + $result = Sabre_CalDAV_XMLUtil::parseCalendarQueryFilters($dom->firstChild); + $this->assertEquals($expected, $result); + + } + + + /** + * @depends testCompFilter + * @depends testParseICalendarDuration + */ + function testTimeRangeEvent() { + + $xml = << + + + + + + + +XML; + + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml); + $expected = array( + '/c:iCalendar/c:vcalendar' => array(), + '/c:iCalendar/c:vcalendar/c:vevent' => array( + 'time-range' => array( + 'start' => new DateTime('2006-01-04 00:00:00',new DateTimeZone('UTC')), + 'end' => new DateTime('2006-01-05 00:00:00',new DateTimeZone('UTC')), + ), + ), + ); + + + $filters = Sabre_CalDAV_XMLUtil::parseCalendarQueryFilters($dom->firstChild); + $this->assertEquals($expected, $filters); + + } + + /** + * @depends testCompFilter + * @depends testParseICalendarDuration + * @depends testTimeRangeEvent + */ + function testTimeRangeTodo() { + + $xml = << + + + + + + + +XML; + + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml); + $expected = array( + '/c:iCalendar/c:vcalendar' => array(), + '/c:iCalendar/c:vcalendar/c:vtodo' => array( + 'time-range' => array( + 'start' => new DateTime('2006-01-01 00:00:00',new DateTimeZone('UTC')), + 'end' => new DateTime('2007-01-01 00:00:00', new DateTimeZone('UTC')), + ), + ), + ); + + + $filters = Sabre_CalDAV_XMLUtil::parseCalendarQueryFilters($dom->firstChild); + $this->assertEquals($expected, $filters); + + + } + + /** + * @depends testCompFilter + */ + function testPropFilter() { + + $xml = << + + + + + DC6C50A017428C5216A2F1CD@example.com + + + + +XML; + + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml); + $expected = array( + '/c:iCalendar/c:vcalendar' => array(), + '/c:iCalendar/c:vcalendar/c:vevent' => array(), + '/c:iCalendar/c:vcalendar/c:vevent/c:uid' => array( + 'text-match' => array( + 'collation' => 'i;octet', + 'value' => 'DC6C50A017428C5216A2F1CD@example.com', + 'negate-condition' => false, + ), + ), + ); + + $filters = Sabre_CalDAV_XMLUtil::parseCalendarQueryFilters($dom->firstChild); + $this->assertEquals($expected, $filters); + + } + + /** + * @depends testPropFilter + */ + function testParamFilter() { + + $xml = << + + + + + mailto:lisa@example.com + + needs-action + + + + + +XML; + + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml); + $expected = array( + '/c:iCalendar/c:vcalendar' => array(), + '/c:iCalendar/c:vcalendar/c:vevent' => array(), + '/c:iCalendar/c:vcalendar/c:vevent/c:attendee' => array( + 'text-match' => array( + 'collation' => 'i;ascii-casemap', + 'negate-condition' => false, + 'value' => 'mailto:lisa@example.com', + ), + ), + '/c:iCalendar/c:vcalendar/c:vevent/c:attendee/@partstat' => array( + 'text-match' => array( + 'collation' => 'i;ascii-casemap', + 'negate-condition' => false, + 'value' => 'needs-action', + ), + ), + ); + + $result = Sabre_CalDAV_XMLUtil::parseCalendarQueryFilters($dom->firstChild); + $this->assertEquals($expected, $result); + + } + + /** + * @depends testParamFilter + */ + function testUndefinedNegation() { + + $xml = << + + + + + + + + CANCELLED + + + + +XML; + + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml); + $expected = array( + '/c:iCalendar/c:vcalendar' => array(), + '/c:iCalendar/c:vcalendar/c:vtodo' => array(), + '/c:iCalendar/c:vcalendar/c:vtodo/c:completed' => array( + 'is-not-defined' => true, + ), + '/c:iCalendar/c:vcalendar/c:vtodo/c:status' => array( + 'text-match' => array( + 'collation' => 'i;ascii-casemap', + 'negate-condition' => true, + 'value' => 'CANCELLED', + ), + ), + ); + + $result = Sabre_CalDAV_XMLUtil::parseCalendarQueryFilters($dom->firstChild); + $this->assertEquals($expected, $result); + + } + + function testParseICalendarDateTime() { + + $dateTime = Sabre_CalDAV_XMLUtil::parseICalendarDateTime('20100316T141405'); + + $compare = new DateTime('2010-03-16 14:14:05',new DateTimeZone('UTC')); + + $this->assertEquals($compare, $dateTime); + + } + + /** + * @depends testParseICalendarDateTime + * @expectedException Sabre_DAV_Exception_BadRequest + */ + function testParseICalendarDateTimeBadFormat() { + + $dateTime = Sabre_CalDAV_XMLUtil::parseICalendarDateTime('20100316T141405 '); + + } + + /** + * @depends testParseICalendarDateTime + */ + function testParseICalendarDateTimeUTC() { + + $dateTime = Sabre_CalDAV_XMLUtil::parseICalendarDateTime('20100316T141405Z'); + + $compare = new DateTime('2010-03-16 14:14:05',new DateTimeZone('UTC')); + $this->assertEquals($compare, $dateTime); + + } + + /** + * @depends testParseICalendarDateTime + */ + function testParseICalendarDateTimeUTC2() { + + $dateTime = Sabre_CalDAV_XMLUtil::parseICalendarDateTime('20101211T160000Z'); + + $compare = new DateTime('2010-12-11 16:00:00',new DateTimeZone('UTC')); + $this->assertEquals($compare, $dateTime); + + } + + /** + * @depends testParseICalendarDateTime + */ + function testParseICalendarDateTimeCustomTimeZone() { + + $dateTime = Sabre_CalDAV_XMLUtil::parseICalendarDateTime('20100316T141405', new DateTimeZone('Europe/Amsterdam')); + + $compare = new DateTime('2010-03-16 13:14:05',new DateTimeZone('UTC')); + $this->assertEquals($compare, $dateTime); + + } + + function testParseICalendarDate() { + + $dateTime = Sabre_CalDAV_XMLUtil::parseICalendarDate('20100316'); + + $compare = new DateTime('2010-03-16 00:00:00',new DateTimeZone('UTC')); + + $this->assertEquals($compare, $dateTime); + + } + + /** + * @depends testParseICalendarDate + * @expectedException Sabre_DAV_Exception_BadRequest + */ + function testParseICalendarDateBadFormat() { + + $dateTime = Sabre_CalDAV_XMLUtil::parseICalendarDate('20100316T141405'); + + } +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AbstractPluginTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AbstractPluginTest.php new file mode 100755 index 0000000..b002ab6 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AbstractPluginTest.php @@ -0,0 +1,30 @@ +backend = new Sabre_CardDAV_MockBackend(); + $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); + + $tree = array( + new Sabre_CardDAV_AddressBookRoot($principalBackend, $this->backend), + new Sabre_DAVACL_PrincipalCollection($principalBackend) + ); + + $this->plugin = new Sabre_CardDAV_Plugin(); + $this->plugin->directories = array('directory'); + $this->server = new Sabre_DAV_Server($tree); + $this->server->addPlugin($this->plugin); + $this->server->debugExceptions = true; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AddressBookQueryParserTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AddressBookQueryParserTest.php new file mode 100755 index 0000000..9834594 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AddressBookQueryParserTest.php @@ -0,0 +1,296 @@ +parse(); + return $q; + + } + + function testFilterBasic() { + + $xml = array( + '', + '', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + '' + ); + + $q = $this->parse($xml); + + $this->assertEquals( + array('{DAV:}foo'), + $q->requestedProperties + ); + + $this->assertEquals( + array( + array( + 'name' => 'NICKNAME', + 'test' => 'anyof', + 'is-not-defined' => false, + 'param-filters' => array(), + 'text-matches' => array(), + ), + ), + $q->filters + ); + + $this->assertNull($q->limit); + $this->assertEquals('anyof', $q->test); + + } + + /** + * @expectedException Sabre_DAV_Exception_BadRequest + */ + function testFilterDoubleFilter() { + + $xml = array( + '', + '', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + '' + ); + + $q = $this->parse($xml); + + } + /** + * @expectedException Sabre_DAV_Exception_BadRequest + */ + function testFilterCorruptTest() { + + $xml = array( + '', + '', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + '' + ); + + $q = $this->parse($xml); + + } + + function testPropFilter() { + + $xml = array( + '', + '', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' 4', + '' + ); + + $q = $this->parse($xml); + + $this->assertEquals( + array( + array( + 'name' => 'NICKNAME', + 'test' => 'anyof', + 'is-not-defined' => false, + 'param-filters' => array(), + 'text-matches' => array(), + ), + array( + 'name' => 'EMAIL', + 'test' => 'allof', + 'is-not-defined' => false, + 'param-filters' => array(), + 'text-matches' => array(), + ), + array( + 'name' => 'FN', + 'test' => 'anyof', + 'is-not-defined' => true, + 'param-filters' => array(), + 'text-matches' => array(), + ), + ), + $q->filters + ); + + $this->assertEquals(4,$q->limit); + $this->assertEquals('allof', $q->test); + + } + + function testParamFilter() { + + $xml = array( + '', + '', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + '' + ); + + $q = $this->parse($xml); + + $this->assertEquals( + array( + array( + 'name' => 'NICKNAME', + 'test' => 'anyof', + 'is-not-defined' => false, + 'param-filters' => array( + array( + 'name' => 'BLA', + 'is-not-defined' => false, + 'text-match' => null + ), + array( + 'name' => 'BLA2', + 'is-not-defined' => true, + 'text-match' => null + ), + ), + 'text-matches' => array(), + ), + ), + $q->filters + ); + + } + + function testTextMatch() { + + $xml = array( + '', + '', + ' ', + ' ', + ' ', + ' ', + ' ', + ' evert', + ' evert', + ' rene', + ' e', + ' ', + ' foo', + ' ', + ' ', + ' ', + '' + ); + + $q = $this->parse($xml); + + $this->assertEquals( + array( + array( + 'name' => 'NICKNAME', + 'test' => 'anyof', + 'is-not-defined' => false, + 'param-filters' => array( + array( + 'name' => 'BLA', + 'is-not-defined' => false, + 'text-match' => array( + 'negate-condition' => false, + 'collation' => 'i;unicode-casemap', + 'match-type' => 'contains', + 'value' => 'foo', + ), + ), + ), + 'text-matches' => array( + array( + 'negate-condition' => false, + 'collation' => 'i;unicode-casemap', + 'match-type' => 'contains', + 'value' => 'evert', + ), + array( + 'negate-condition' => false, + 'collation' => 'i;octet', + 'match-type' => 'contains', + 'value' => 'evert', + ), + array( + 'negate-condition' => true, + 'collation' => 'i;unicode-casemap', + 'match-type' => 'contains', + 'value' => 'rene', + ), + array( + 'negate-condition' => false, + 'collation' => 'i;unicode-casemap', + 'match-type' => 'starts-with', + 'value' => 'e', + ), + ), + ), + ), + $q->filters + ); + + } + + /** + * @expectedException Sabre_DAV_Exception_BadRequest + */ + function testBadTextMatch() { + + $xml = array( + '', + '', + ' ', + ' ', + ' ', + ' ', + ' ', + ' evert', + ' ', + ' ', + '' + ); + + $q = $this->parse($xml); + + } +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AddressBookQueryTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AddressBookQueryTest.php new file mode 100755 index 0000000..598f653 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AddressBookQueryTest.php @@ -0,0 +1,187 @@ + 'REPORT', + 'REQUEST_URI' => '/addressbooks/user1/book1', + 'HTTP_DEPTH' => '1', + )); + + $request->setBody( +' + + + + + + + +' + ); + + $response = new Sabre_HTTP_ResponseMock(); + + $this->server->httpRequest = $request; + $this->server->httpResponse = $response; + + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 207 Multi-Status', $response->status, 'Incorrect status code. Full response body:' . $response->body); + + // using the client for parsing + $client = new Sabre_DAV_Client(array('baseUri'=>'/')); + + $result = $client->parseMultiStatus($response->body); + + $this->assertEquals(array( + '/addressbooks/user1/book1/card1' => array( + 200 => array( + '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', + ), + ), + '/addressbooks/user1/book1/card2' => array( + 200 => array( + '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:45678\nEND:VCARD") . '"', + ), + ) + ), $result); + + + } + + function testQueryDepth0() { + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_URI' => '/addressbooks/user1/book1/card1', + 'HTTP_DEPTH' => '0', + )); + + $request->setBody( +' + + + + + + + +' + ); + + $response = new Sabre_HTTP_ResponseMock(); + + $this->server->httpRequest = $request; + $this->server->httpResponse = $response; + + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 207 Multi-Status', $response->status, 'Incorrect status code. Full response body:' . $response->body); + + // using the client for parsing + $client = new Sabre_DAV_Client(array('baseUri'=>'/')); + + $result = $client->parseMultiStatus($response->body); + + $this->assertEquals(array( + '/addressbooks/user1/book1/card1' => array( + 200 => array( + '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', + ), + ), + ), $result); + + + } + + function testQueryNoMatch() { + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_URI' => '/addressbooks/user1/book1', + 'HTTP_DEPTH' => '1', + )); + + $request->setBody( +' + + + + + + + +' + ); + + $response = new Sabre_HTTP_ResponseMock(); + + $this->server->httpRequest = $request; + $this->server->httpResponse = $response; + + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 207 Multi-Status', $response->status, 'Incorrect status code. Full response body:' . $response->body); + + // using the client for parsing + $client = new Sabre_DAV_Client(array('baseUri'=>'/')); + + $result = $client->parseMultiStatus($response->body); + + $this->assertEquals(array(), $result); + + } + + function testQueryLimit() { + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_URI' => '/addressbooks/user1/book1', + 'HTTP_DEPTH' => '1', + )); + + $request->setBody( +' + + + + + + + + 1 +' + ); + + $response = new Sabre_HTTP_ResponseMock(); + + $this->server->httpRequest = $request; + $this->server->httpResponse = $response; + + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 207 Multi-Status', $response->status, 'Incorrect status code. Full response body:' . $response->body); + + // using the client for parsing + $client = new Sabre_DAV_Client(array('baseUri'=>'/')); + + $result = $client->parseMultiStatus($response->body); + + $this->assertEquals(array( + '/addressbooks/user1/book1/card1' => array( + 200 => array( + '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD"). '"', + ), + ), + ), $result); + + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AddressBookRootTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AddressBookRootTest.php new file mode 100755 index 0000000..d68198c --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AddressBookRootTest.php @@ -0,0 +1,27 @@ +assertEquals('addressbooks', $root->getName()); + + } + + function testGetChildForPrincipal() { + + $pBackend = new Sabre_DAVACL_MockPrincipalBackend(); + $cBackend = new Sabre_CardDAV_MockBackend(); + $root = new Sabre_CardDAV_AddressBookRoot($pBackend, $cBackend); + + $children = $root->getChildren(); + $this->assertEquals(2, count($children)); + + $this->assertInstanceOf('Sabre_CardDAV_UserAddressBooks', $children[0]); + $this->assertEquals('user1', $children[0]->getName()); + + } +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AddressBookTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AddressBookTest.php new file mode 100755 index 0000000..552da93 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/AddressBookTest.php @@ -0,0 +1,147 @@ +backend = new Sabre_CardDAV_MockBackend(); + $this->ab = new Sabre_CardDAV_AddressBook( + $this->backend, + array( + 'uri' => 'book1', + 'id' => 'foo', + '{DAV:}displayname' => 'd-name', + 'principaluri' => 'principals/user1', + ) + ); + + } + + function testGetName() { + + $this->assertEquals('book1', $this->ab->getName()); + + } + + function testGetChild() { + + $card = $this->ab->getChild('card1'); + $this->assertInstanceOf('Sabre_CardDAV_Card', $card); + $this->assertEquals('card1', $card->getName()); + + } + + /** + * @expectedException Sabre_DAV_Exception_FileNotFound + */ + function testGetChildNotFound() { + + $card = $this->ab->getChild('card3'); + + } + + function testGetChildren() { + + $cards = $this->ab->getChildren(); + $this->assertEquals(2, count($cards)); + + $this->assertEquals('card1', $cards[0]->getName()); + $this->assertEquals('card2', $cards[1]->getName()); + + } + + /** + * @expectedException Sabre_DAV_Exception_MethodNotAllowed + */ + function testCreateDirectory() { + + $this->ab->createDirectory('name'); + + } + + function testCreateFile() { + + $file = fopen('php://memory','r+'); + fwrite($file,'foo'); + rewind($file); + $this->ab->createFile('card2',$file); + + $this->assertEquals('foo', $this->backend->cards['foo']['card2']); + + } + + function testDelete() { + + $this->ab->delete(); + $this->assertEquals(array(), $this->backend->addressBooks); + + } + + /** + * @expectedException Sabre_DAV_Exception_MethodNotAllowed + */ + function testSetName() { + + $this->ab->setName('foo'); + + } + + function testGetLastModified() { + + $this->assertNull($this->ab->getLastModified()); + + } + + function testUpdateProperties() { + + $this->assertTrue( + $this->ab->updateProperties(array('{DAV:}displayname' => 'barrr')) + ); + + $this->assertEquals('barrr', $this->backend->addressBooks[0]['{DAV:}displayname']); + + } + + function testGetProperties() { + + $props = $this->ab->getProperties(array('{DAV:}displayname')); + $this->assertEquals(array( + '{DAV:}displayname' => 'd-name', + ), $props); + + } + + function testACLMethods() { + + $this->assertEquals('principals/user1', $this->ab->getOwner()); + $this->assertNull($this->ab->getGroup()); + $this->assertEquals(array( + array( + 'privilege' => '{DAV:}read', + 'principal' => 'principals/user1', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => 'principals/user1', + 'protected' => true, + ), + ), $this->ab->getACL()); + + } + + /** + * @expectedException Sabre_DAV_Exception_MethodNotAllowed + */ + function testSetACL() { + + $this->ab->setACL(array()); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php new file mode 100755 index 0000000..97081a3 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php @@ -0,0 +1,237 @@ +getPDO()); + $this->backend = $backend; + + } + + public function testGetAddressBooksForUser() { + + $result = $this->backend->getAddressBooksForUser('principals/user1'); + + $expected = array( + array( + 'id' => 1, + 'uri' => 'book1', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'book1', + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1', + '{http://calendarserver.org/ns/}getctag' => 1, + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}supported-address-data' => new Sabre_CardDAV_Property_SupportedAddressData(), + ) + ); + + $this->assertEquals($expected, $result); + + } + + public function testUpdateAddressBookInvalidProp() { + + $result = $this->backend->updateAddressBook(1, array( + '{DAV:}displayname' => 'updated', + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' => 'updated', + '{DAV:}foo' => 'bar', + )); + + $this->assertFalse($result); + + $result = $this->backend->getAddressBooksForUser('principals/user1'); + + $expected = array( + array( + 'id' => 1, + 'uri' => 'book1', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'book1', + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1', + '{http://calendarserver.org/ns/}getctag' => 1, + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}supported-address-data' => new Sabre_CardDAV_Property_SupportedAddressData(), + ) + ); + + $this->assertEquals($expected, $result); + + + } + + public function testUpdateAddressBookNoProps() { + + $result = $this->backend->updateAddressBook(1, array()); + + $this->assertFalse($result); + + $result = $this->backend->getAddressBooksForUser('principals/user1'); + + $expected = array( + array( + 'id' => 1, + 'uri' => 'book1', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'book1', + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1', + '{http://calendarserver.org/ns/}getctag' => 1, + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}supported-address-data' => new Sabre_CardDAV_Property_SupportedAddressData(), + ) + ); + + $this->assertEquals($expected, $result); + + + } + + public function testUpdateAddressBookSuccess() { + + $result = $this->backend->updateAddressBook(1, array( + '{DAV:}displayname' => 'updated', + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' => 'updated', + )); + + $this->assertTrue($result); + + $result = $this->backend->getAddressBooksForUser('principals/user1'); + + $expected = array( + array( + 'id' => 1, + 'uri' => 'book1', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'updated', + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' => 'updated', + '{http://calendarserver.org/ns/}getctag' => 2, + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}supported-address-data' => new Sabre_CardDAV_Property_SupportedAddressData(), + ) + ); + + $this->assertEquals($expected, $result); + + + } + + public function testDeleteAddressBook() { + + $this->backend->deleteAddressBook(1); + + $this->assertEquals(array(), $this->backend->getAddressBooksForUser('principals/user1')); + + } + + /** + * @expectedException Sabre_DAV_Exception_BadRequest + */ + public function testCreateAddressBookUnsupportedProp() { + + $this->backend->createAddressBook('principals/user1','book2', array( + '{DAV:}foo' => 'bar', + )); + + } + + public function testCreateAddressBookSuccess() { + + $this->backend->createAddressBook('principals/user1','book2', array( + '{DAV:}displayname' => 'book2', + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 2', + )); + + $expected = array( + array( + 'id' => 1, + 'uri' => 'book1', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'book1', + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1', + '{http://calendarserver.org/ns/}getctag' => 1, + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}supported-address-data' => new Sabre_CardDAV_Property_SupportedAddressData(), + ), + array( + 'id' => 2, + 'uri' => 'book2', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'book2', + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 2', + '{http://calendarserver.org/ns/}getctag' => 1, + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}supported-address-data' => new Sabre_CardDAV_Property_SupportedAddressData(), + ) + ); + $result = $this->backend->getAddressBooksForUser('principals/user1'); + $this->assertEquals($expected, $result); + + } + + public function testGetCards() { + + $result = $this->backend->getCards(1); + + $expected = array( + array( + 'id' => 1, + 'uri' => 'card1', + 'carddata' => 'card1', + 'lastmodified' => 0, + ) + ); + + $this->assertEquals($expected, $result); + + } + + public function testGetCard() { + + $result = $this->backend->getCard(1,'card1'); + + $expected = array( + 'id' => 1, + 'uri' => 'card1', + 'carddata' => 'card1', + 'lastmodified' => 0, + ); + + $this->assertEquals($expected, $result); + + } + + /** + * @depends testGetCard + */ + public function testCreateCard() { + + $this->backend->createCard(1, 'card2', 'data2'); + $result = $this->backend->getCard(1,'card2'); + $this->assertEquals(2, $result['id']); + $this->assertEquals('card2', $result['uri']); + $this->assertEquals('data2', $result['carddata']); + + } + + /** + * @depends testGetCard + */ + public function testUpdateCard() { + + $this->backend->updateCard(1, 'card1', 'newdata'); + $result = $this->backend->getCard(1,'card1'); + $this->assertEquals(1, $result['id']); + $this->assertEquals('newdata', $result['carddata']); + + } + + /** + * @depends testGetCard + */ + public function testDeleteCard() { + + $this->backend->deleteCard(1, 'card1'); + $result = $this->backend->getCard(1,'card1'); + $this->assertFalse($result); + + } +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php new file mode 100755 index 0000000..44411b7 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php @@ -0,0 +1,55 @@ +markTestSkipped('MySQL driver is not available, or not properly configured'); + + $pdo = Sabre_TestUtil::getMySQLDB(); + if (!$pdo) $this->markTestSkipped('Could not connect to MySQL database'); + + $pdo->query("DROP TABLE IF EXISTS addressbooks"); + $pdo->query("DROP TABLE IF EXISTS cards"); + $pdo->query(" +CREATE TABLE addressbooks ( + id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + principaluri VARCHAR(255), + displayname VARCHAR(255), + uri VARCHAR(100), + description TEXT, + ctag INT(11) UNSIGNED NOT NULL DEFAULT '1' +); +"); + + $pdo->query(" +INSERT INTO addressbooks + (principaluri, displayname, uri, description, ctag) +VALUES + ('principals/user1', 'book1', 'book1', 'addressbook 1', 1); +"); + + $pdo->query(" +CREATE TABLE cards ( + id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + addressbookid INT(11) UNSIGNED NOT NULL, + carddata TEXT, + uri VARCHAR(100), + lastmodified INT(11) UNSIGNED +); +"); + + $pdo->query(" +INSERT INTO cards + (addressbookid, carddata, uri, lastmodified) +VALUES + (1, 'card1', 'card1', 0); +"); + return $pdo; + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/Backend/PDOSqliteTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/Backend/PDOSqliteTest.php new file mode 100755 index 0000000..9bfa824 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/Backend/PDOSqliteTest.php @@ -0,0 +1,64 @@ +markTestSkipped('SQLite driver is not available'); + $pdo = new PDO('sqlite:'.SABRE_TEMPDIR.'/pdobackend'); + $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); + + $pdo->query("DROP TABLE IF EXISTS addressbooks"); + $pdo->query("DROP TABLE IF EXISTS cards"); + $pdo->query(" +CREATE TABLE addressbooks ( + id integer primary key asc, + principaluri text, + displayname text, + uri text, + description text, + ctag integer +); + +"); + + $pdo->query(" +INSERT INTO addressbooks + (principaluri, displayname, uri, description, ctag) +VALUES + ('principals/user1', 'book1', 'book1', 'addressbook 1', 1); +"); + + $pdo->query(" + +CREATE TABLE cards ( + id integer primary key asc, + addressbookid integer, + carddata text, + uri text, + lastmodified integer +); + +"); + $pdo->query(" +INSERT INTO cards + (addressbookid, carddata, uri, lastmodified) +VALUES + (1, 'card1', 'card1', 0); +"); + + return $pdo; + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/CardTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/CardTest.php new file mode 100755 index 0000000..525ffc1 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/CardTest.php @@ -0,0 +1,128 @@ +backend = new Sabre_CardDAV_MockBackend(); + $this->card = new Sabre_CardDAV_Card( + $this->backend, + array( + 'uri' => 'book1', + 'id' => 'foo', + 'principaluri' => 'principals/user1', + ), + array( + 'uri' => 'card1', + 'addressbookid' => 'foo', + 'carddata' => 'card', + ) + ); + + } + + function testGet() { + + $result = $this->card->get(); + $this->assertEquals('card', $result); + + } + + + /** + * @depends testGet + */ + function testPut() { + + $file = fopen('php://memory','r+'); + fwrite($file, 'newdata'); + rewind($file); + $this->card->put($file); + $result = $this->card->get(); + $this->assertEquals('newdata', $result); + + } + + + function testDelete() { + + $this->card->delete(); + $this->assertEquals(1, count($this->backend->cards['foo'])); + + } + + function testGetContentType() { + + $this->assertEquals('text/x-vcard', $this->card->getContentType()); + + } + + function testGetETag() { + + $this->assertEquals('"' . md5('card') . '"' , $this->card->getETag()); + + } + + function testGetETag2() { + + $card = new Sabre_CardDAV_Card( + $this->backend, + array( + 'uri' => 'book1', + 'id' => 'foo', + 'principaluri' => 'principals/user1', + ), + array( + 'uri' => 'card1', + 'addressbookid' => 'foo', + 'carddata' => 'card', + 'etag' => '"blabla"', + ) + ); + $this->assertEquals('"blabla"' , $card->getETag()); + + } + + function testGetLastModified() { + + $this->assertEquals(null, $this->card->getLastModified()); + + } + + function testGetSize() { + + $this->assertEquals(4, $this->card->getSize()); + + } + + function testACLMethods() { + + $this->assertEquals('principals/user1', $this->card->getOwner()); + $this->assertNull($this->card->getGroup()); + $this->assertEquals(array( + array( + 'privilege' => '{DAV:}read', + 'principal' => 'principals/user1', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => 'principals/user1', + 'protected' => true, + ), + ), $this->card->getACL()); + + } + + /** + * @expectedException Sabre_DAV_Exception_MethodNotAllowed + */ + function testSetACL() { + + $this->card->setACL(array()); + + } +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/IDirectoryTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/IDirectoryTest.php new file mode 100755 index 0000000..0e1cd46 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/IDirectoryTest.php @@ -0,0 +1,25 @@ +addPlugin($plugin); + + $props = $server->getProperties('directory', array('{DAV:}resourcetype')); + $this->assertTrue($props['{DAV:}resourcetype']->is('{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}directory')); + + } + +} + +class Sabre_CardDAV_DirectoryMock extends Sabre_DAV_SimpleDirectory implements Sabre_CardDAV_IDirectory { + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/MockBackend.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/MockBackend.php new file mode 100755 index 0000000..5710165 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/MockBackend.php @@ -0,0 +1,121 @@ +addressBooks = array( + array( + 'id' => 'foo', + 'uri' => 'book1', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'd-name', + ), + ); + + $this->cards = array( + 'foo' => array( + 'card1' => "BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD", + 'card2' => "BEGIN:VCARD\nVERSION:3.0\nUID:45678\nEND:VCARD", + ), + ); + + } + + + function getAddressBooksForUser($principalUri) { + + $books = array(); + foreach($this->addressBooks as $book) { + if ($book['principaluri'] === $principalUri) { + $books[] = $book; + } + } + + return $books; + + } + + function updateAddressBook($addressBookId, array $mutations) { + + foreach($this->addressBooks as &$book) { + if ($book['id'] !== $addressBookId) + continue; + + foreach($mutations as $key=>$value) { + $book[$key] = $value; + } + return true; + } + return false; + + } + + function createAddressBook($principalUri, $url, array $properties) { + + $this->addressBooks[] = array_merge($properties, array( + 'id' => $url, + 'uri' => $url, + 'principaluri' => $principalUri, + )); + + } + + function deleteAddressBook($addressBookId) { + + foreach($this->addressBooks as $key=>$value) { + if ($value['id'] === $addressBookId) + unset($this->addressBooks[$key]); + } + unset($this->cards[$addressBookId]); + + } + + function getCards($addressBookId) { + + $cards = array(); + foreach($this->cards[$addressBookId] as $uri=>$data) { + $cards[] = array( + 'uri' => $uri, + 'carddata' => $data, + ); + } + return $cards; + + } + + function getCard($addressBookId, $cardUri) { + + if (!isset($this->cards[$addressBookId][$cardUri])) { + return false; + } + + return array( + 'uri' => $cardUri, + 'carddata' => $this->cards[$addressBookId][$cardUri], + ); + + } + + function createCard($addressBookId, $cardUri, $cardData) { + + $this->cards[$addressBookId][$cardUri] = $cardData; + + } + + function updateCard($addressBookId, $cardUri, $cardData) { + + $this->cards[$addressBookId][$cardUri] = $cardData; + + } + + function deleteCard($addressBookId, $cardUri) { + + unset($this->cards[$addressBookId][$cardUri]); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/MultiGetTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/MultiGetTest.php new file mode 100755 index 0000000..50301c6 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/MultiGetTest.php @@ -0,0 +1,50 @@ + 'REPORT', + 'REQUEST_URI' => '/addressbooks/user1/book1', + )); + + $request->setBody( +' + + + + + + /addressbooks/user1/book1/card1 +' + ); + + $response = new Sabre_HTTP_ResponseMock(); + + $this->server->httpRequest = $request; + $this->server->httpResponse = $response; + + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 207 Multi-Status', $response->status, 'Incorrect status code. Full response body:' . $response->body); + + // using the client for parsing + $client = new Sabre_DAV_Client(array('baseUri'=>'/')); + + $result = $client->parseMultiStatus($response->body); + + $this->assertEquals(array( + '/addressbooks/user1/book1/card1' => array( + 200 => array( + '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', + '{urn:ietf:params:xml:ns:carddav}address-data' => "BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD", + ) + ) + ), $result); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/PluginTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/PluginTest.php new file mode 100755 index 0000000..7a03744 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/PluginTest.php @@ -0,0 +1,59 @@ +assertEquals('card', $this->server->xmlNamespaces[Sabre_CardDAV_Plugin::NS_CARDDAV]); + $this->assertEquals('{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook', $this->server->resourceTypeMapping['Sabre_CardDAV_IAddressBook']); + + $this->assertTrue(in_array('addressbook', $this->plugin->getFeatures())); + + } + + function testSupportedReportSet() { + + $this->assertEquals(array( + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-multiget', + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-query', + ), $this->plugin->getSupportedReportSet('addressbooks/user1/book1')); + + } + + function testSupportedReportSetEmpty() { + + $this->assertEquals(array( + ), $this->plugin->getSupportedReportSet('')); + + } + + function testAddressBookHomeSet() { + + $result = $this->server->getProperties('principals/user1', array('{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-home-set')); + + $this->assertEquals(1, count($result)); + $this->assertTrue(isset($result['{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-home-set'])); + $this->assertEquals('addressbooks/user1/', $result['{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-home-set']->getHref()); + + } + + function testDirectoryGateway() { + + $result = $this->server->getProperties('principals/user1', array('{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}directory-gateway')); + + $this->assertEquals(1, count($result)); + $this->assertTrue(isset($result['{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}directory-gateway'])); + $this->assertEquals(array('directory'), $result['{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}directory-gateway']->getHrefs()); + + } + + function testReportPassThrough() { + + $this->assertNull($this->plugin->report('{DAV:}foo', new DomDocument())); + + } + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/Property/SupportedAddressDataTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/Property/SupportedAddressDataTest.php new file mode 100755 index 0000000..d1e78e9 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/Property/SupportedAddressDataTest.php @@ -0,0 +1,39 @@ +createElementNS(Sabre_CardDAV_Plugin::NS_CARDDAV, 'card:root'); + $root->setAttribute('xmlns:d','DAV:'); + + $doc->appendChild($root); + $server = new Sabre_DAV_Server(); + + $property->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' +' . +'' . +'' . +' +', $xml); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/UserAddressBooksTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/UserAddressBooksTest.php new file mode 100755 index 0000000..d0d6ea4 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/UserAddressBooksTest.php @@ -0,0 +1,151 @@ +backend = new Sabre_CardDAV_MockBackend(); + $this->s = new Sabre_CardDAV_UserAddressBooks( + $this->backend, + 'principals/user1' + ); + + } + + function testGetName() { + + $this->assertEquals('user1', $this->s->getName()); + + } + + /** + * @expectedException Sabre_DAV_Exception_MethodNotAllowed + */ + function testSetName() { + + $this->s->setName('user2'); + + } + + /** + * @expectedException Sabre_DAV_Exception_MethodNotAllowed + */ + function testDelete() { + + $this->s->delete(); + + } + + function testGetLastModified() { + + $this->assertNull($this->s->getLastModified()); + + } + + /** + * @expectedException Sabre_DAV_Exception_MethodNotAllowed + */ + function testCreateFile() { + + $this->s->createFile('bla'); + + } + + /** + * @expectedException Sabre_DAV_Exception_MethodNotAllowed + */ + function testCreateDirectory() { + + $this->s->createDirectory('bla'); + + } + + function testGetChild() { + + $child = $this->s->getChild('book1'); + $this->assertInstanceOf('Sabre_CardDAV_AddressBook', $child); + $this->assertEquals('book1', $child->getName()); + + } + + /** + * @expectedException Sabre_DAV_Exception_FileNotFound + */ + function testGetChild404() { + + $this->s->getChild('book2'); + + } + + function testGetChildren() { + + $children = $this->s->getChildren(); + $this->assertEquals(1, count($children)); + $this->assertInstanceOf('Sabre_CardDAV_AddressBook', $children[0]); + $this->assertEquals('book1', $children[0]->getName()); + + } + + function testCreateExtendedCollection() { + + $resourceType = array( + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook', + '{DAV:}collection', + ); + $this->s->createExtendedCollection('book2', $resourceType, array('{DAV:}displayname' => 'a-book 2')); + + $this->assertEquals(array( + 'id' => 'book2', + 'uri' => 'book2', + '{DAV:}displayname' => 'a-book 2', + 'principaluri' => 'principals/user1', + ), $this->backend->addressBooks[1]); + + } + + /** + * @expectedException Sabre_DAV_Exception_InvalidResourceType + */ + function testCreateExtendedCollectionInvalid() { + + $resourceType = array( + '{DAV:}collection', + ); + $this->s->createExtendedCollection('book2', $resourceType, array('{DAV:}displayname' => 'a-book 2')); + + } + + + function testACLMethods() { + + $this->assertEquals('principals/user1', $this->s->getOwner()); + $this->assertNull($this->s->getGroup()); + $this->assertEquals(array( + array( + 'privilege' => '{DAV:}read', + 'principal' => 'principals/user1', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => 'principals/user1', + 'protected' => true, + ), + ), $this->s->getACL()); + + } + + /** + * @expectedException Sabre_DAV_Exception_MethodNotAllowed + */ + function testSetACL() { + + $this->s->setACL(array()); + + } +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/ValidateFilterTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/ValidateFilterTest.php new file mode 100755 index 0000000..8314d24 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/ValidateFilterTest.php @@ -0,0 +1,203 @@ +assertTrue($this->plugin->validateFilters($input, $filters, $test), $message); + } else { + $this->assertFalse($this->plugin->validateFilters($input, $filters, $test), $message); + } + + } + + function data() { + + $body1 = << 'title', 'is-not-defined' => false, 'param-filters' => array(), 'text-matches' => array()); + + // Check if FOO is defined + $filter2 = + array('name' => 'foo', 'is-not-defined' => false, 'param-filters' => array(), 'text-matches' => array()); + + // Check if TITLE is not defined + $filter3 = + array('name' => 'title', 'is-not-defined' => true, 'param-filters' => array(), 'text-matches' => array()); + + // Check if FOO is not defined + $filter4 = + array('name' => 'foo', 'is-not-defined' => true, 'param-filters' => array(), 'text-matches' => array()); + + // Check if TEL[TYPE] is defined + $filter5 = + array( + 'name' => 'tel', + 'is-not-defined' => false, + 'test' => 'anyof', + 'param-filters' => array( + array( + 'name' => 'type', + 'is-not-defined' => false, + 'text-match' => null + ), + ), + 'text-matches' => array(), + ); + + // Check if TEL[FOO] is defined + $filter6 = $filter5; + $filter6['param-filters'][0]['name'] = 'FOO'; + + // Check if TEL[TYPE] is not defined + $filter7 = $filter5; + $filter7['param-filters'][0]['is-not-defined'] = true; + + // Check if TEL[FOO] is not defined + $filter8 = $filter5; + $filter8['param-filters'][0]['name'] = 'FOO'; + $filter8['param-filters'][0]['is-not-defined'] = true; + + // Combining property filters + $filter9 = $filter5; + $filter9['param-filters'][] = $filter6['param-filters'][0]; + + $filter10 = $filter5; + $filter10['param-filters'][] = $filter6['param-filters'][0]; + $filter10['test'] = 'allof'; + + // Check if URL contains 'google' + $filter11 = + array( + 'name' => 'url', + 'is-not-defined' => false, + 'test' => 'anyof', + 'param-filters' => array(), + 'text-matches' => array( + array( + 'match-type' => 'contains', + 'value' => 'google', + 'negate-condition' => false, + 'collation' => 'i;octet', + ), + ), + ); + + // Check if URL contains 'bing' + $filter12 = $filter11; + $filter12['text-matches'][0]['value'] = 'bing'; + + // Check if URL does not contain 'google' + $filter13 = $filter11; + $filter13['text-matches'][0]['negate-condition'] = true; + + // Check if URL does not contain 'bing' + $filter14 = $filter11; + $filter14['text-matches'][0]['value'] = 'bing'; + $filter14['text-matches'][0]['negate-condition'] = true; + + // Param filter with text + $filter15 = $filter5; + $filter15['param-filters'][0]['text-match'] = array( + 'match-type' => 'contains', + 'value' => 'WORK', + 'collation' => 'i;octet', + 'negate-condition' => false, + ); + $filter16 = $filter15; + $filter16['param-filters'][0]['text-match']['negate-condition'] = true; + + + // Param filter + text filter + $filter17 = $filter5; + $filter17['test'] = 'anyof'; + $filter17['text-matches'][] = array( + 'match-type' => 'contains', + 'value' => '444', + 'collation' => 'i;octet', + 'negate-condition' => false, + ); + + $filter18 = $filter17; + $filter18['text-matches'][0]['negate-condition'] = true; + + $filter18 = $filter18; + $filter18['test'] = 'allof'; + + return array( + + // Basic filters + array($body1, array($filter1), 'anyof',true), + array($body1, array($filter2), 'anyof',false), + array($body1, array($filter3), 'anyof',false), + array($body1, array($filter4), 'anyof',true), + + // Combinations + array($body1, array($filter1, $filter2), 'anyof',true), + array($body1, array($filter1, $filter2), 'allof',false), + array($body1, array($filter1, $filter4), 'anyof',true), + array($body1, array($filter1, $filter4), 'allof',true), + array($body1, array($filter2, $filter3), 'anyof',false), + array($body1, array($filter2, $filter3), 'allof',false), + + // Basic parameters + array($body1, array($filter5), 'anyof', true, 'TEL;TYPE is defined, so this should return true'), + array($body1, array($filter6), 'anyof', false, 'TEL;FOO is not defined, so this should return false'), + + array($body1, array($filter7), 'anyof', false, 'TEL;TYPE is defined, so this should return false'), + array($body1, array($filter8), 'anyof', true, 'TEL;TYPE is not defined, so this should return true'), + + // Combined parameters + array($body1, array($filter9), 'anyof', true), + array($body1, array($filter10), 'anyof', false), + + // Text-filters + array($body1, array($filter11), 'anyof', true), + array($body1, array($filter12), 'anyof', false), + array($body1, array($filter13), 'anyof', false), + array($body1, array($filter14), 'anyof', true), + + // Param filter with text-match + array($body1, array($filter15), 'anyof', true), + array($body1, array($filter16), 'anyof', false), + + // Param filter + text filter + array($body1, array($filter17), 'anyof', true), + array($body1, array($filter18), 'anyof', false), + array($body1, array($filter18), 'anyof', false), + ); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/VersionTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/VersionTest.php new file mode 100755 index 0000000..caec571 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/CardDAV/VersionTest.php @@ -0,0 +1,15 @@ +assertEquals(-1, version_compare('0.1',$v)); + + $s = Sabre_CardDAV_Version::STABILITY; + $this->assertTrue($s == 'alpha' || $s == 'beta' || $s =='stable'); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/AbstractServer.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/AbstractServer.php new file mode 100755 index 0000000..ad877e4 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/AbstractServer.php @@ -0,0 +1,56 @@ +response = new Sabre_HTTP_ResponseMock(); + $this->server = new Sabre_DAV_Server($this->getRootNode()); + $this->server->httpResponse = $this->response; + $this->server->debugExceptions = true; + file_put_contents(SABRE_TEMPDIR . '/test.txt', 'Test contents'); + mkdir(SABRE_TEMPDIR . '/dir'); + file_put_contents(SABRE_TEMPDIR . '/dir/child.txt', 'Child contents'); + + + } + + function tearDown() { + + $this->deleteTree(SABRE_TEMPDIR,false); + + } + + protected function getRootNode() { + + return new Sabre_DAV_FS_Directory(SABRE_TEMPDIR); + + } + + private function deleteTree($path,$deleteRoot = true) { + + foreach(scandir($path) as $node) { + + if ($node=='.' || $node=='.svn' || $node=='..') continue; + $myPath = $path.'/'. $node; + if (is_file($myPath)) { + unlink($myPath); + } else { + $this->deleteTree($myPath); + } + + } + if ($deleteRoot) rmdir($path); + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php new file mode 100755 index 0000000..e9b2bac --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php @@ -0,0 +1,77 @@ +httpResponse = $response; + + $backend = new Sabre_DAV_Auth_Backend_AbstractBasicMock(); + $backend->authenticate($server,'myRealm'); + + } + + /** + * @expectedException Sabre_DAV_Exception_NotAuthenticated + */ + public function testAuthenticateUnknownUser() { + + $response = new Sabre_HTTP_ResponseMock(); + $tree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('bla')); + $server = new Sabre_DAV_Server($tree); + $server->httpResponse = $response; + + $request = new Sabre_HTTP_Request(array( + 'PHP_AUTH_USER' => 'username', + 'PHP_AUTH_PW' => 'wrongpassword', + )); + $server->httpRequest = $request; + + $backend = new Sabre_DAV_Auth_Backend_AbstractBasicMock(); + $backend->authenticate($server,'myRealm'); + + } + + public function testAuthenticate() { + + $response = new Sabre_HTTP_ResponseMock(); + $tree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('bla')); + $server = new Sabre_DAV_Server($tree); + $server->httpResponse = $response; + + $request = new Sabre_HTTP_Request(array( + 'PHP_AUTH_USER' => 'username', + 'PHP_AUTH_PW' => 'password', + )); + $server->httpRequest = $request; + + $backend = new Sabre_DAV_Auth_Backend_AbstractBasicMock(); + $this->assertTrue($backend->authenticate($server,'myRealm')); + + $result = $backend->getCurrentUser(); + + $this->assertEquals('username', $result); + + } + + +} + + +class Sabre_DAV_Auth_Backend_AbstractBasicMock extends Sabre_DAV_Auth_Backend_AbstractBasic { + + function validateUserPass($username, $password) { + + return ($username == 'username' && $password == 'password'); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php new file mode 100755 index 0000000..ac1b798 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php @@ -0,0 +1,150 @@ +httpResponse = $response; + + $backend = new Sabre_DAV_Auth_Backend_AbstractDigestMock(); + $backend->authenticate($server,'myRealm'); + + } + + /** + * @expectedException Sabre_DAV_Exception + */ + public function testAuthenticateBadGetUserInfoResponse() { + + $response = new Sabre_HTTP_ResponseMock(); + $tree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('bla')); + $server = new Sabre_DAV_Server($tree); + $server->httpResponse = $response; + + $header = 'username=null, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1'; + $request = new Sabre_HTTP_Request(array( + 'PHP_AUTH_DIGEST' => $header, + )); + $server->httpRequest = $request; + + $backend = new Sabre_DAV_Auth_Backend_AbstractDigestMock(); + $backend->authenticate($server,'myRealm'); + + } + + /** + * @expectedException Sabre_DAV_Exception + */ + public function testAuthenticateBadGetUserInfoResponse2() { + + $response = new Sabre_HTTP_ResponseMock(); + $tree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('bla')); + $server = new Sabre_DAV_Server($tree); + $server->httpResponse = $response; + + $header = 'username=array, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1'; + $request = new Sabre_HTTP_Request(array( + 'PHP_AUTH_DIGEST' => $header, + )); + $server->httpRequest = $request; + + $backend = new Sabre_DAV_Auth_Backend_AbstractDigestMock(); + $backend->authenticate($server,'myRealm'); + + } + + /** + * @expectedException Sabre_DAV_Exception_NotAuthenticated + */ + public function testAuthenticateUnknownUser() { + + $response = new Sabre_HTTP_ResponseMock(); + $tree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('bla')); + $server = new Sabre_DAV_Server($tree); + $server->httpResponse = $response; + + $header = 'username=false, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1'; + $request = new Sabre_HTTP_Request(array( + 'PHP_AUTH_DIGEST' => $header, + )); + $server->httpRequest = $request; + + $backend = new Sabre_DAV_Auth_Backend_AbstractDigestMock(); + $backend->authenticate($server,'myRealm'); + + } + + /** + * @expectedException Sabre_DAV_Exception_NotAuthenticated + */ + public function testAuthenticateBadPassword() { + + $response = new Sabre_HTTP_ResponseMock(); + $tree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('bla')); + $server = new Sabre_DAV_Server($tree); + $server->httpResponse = $response; + + $header = 'username=user, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1'; + $request = new Sabre_HTTP_Request(array( + 'PHP_AUTH_DIGEST' => $header, + 'REQUEST_METHOD' => 'PUT', + )); + $server->httpRequest = $request; + + $backend = new Sabre_DAV_Auth_Backend_AbstractDigestMock(); + $backend->authenticate($server,'myRealm'); + + } + + public function testAuthenticate() { + + $response = new Sabre_HTTP_ResponseMock(); + $tree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('bla')); + $server = new Sabre_DAV_Server($tree); + $server->httpResponse = $response; + + $digestHash = md5('HELLO:12345:1:1:auth:' . md5('GET:/')); + $header = 'username=user, realm=myRealm, nonce=12345, uri=/, response='.$digestHash.', opaque=1, qop=auth, nc=1, cnonce=1'; + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'GET', + 'PHP_AUTH_DIGEST' => $header, + 'REQUEST_URI' => '/', + )); + $server->httpRequest = $request; + + $backend = new Sabre_DAV_Auth_Backend_AbstractDigestMock(); + $this->assertTrue($backend->authenticate($server,'myRealm')); + + $result = $backend->getCurrentUser(); + + $this->assertEquals('user', $result); + $this->assertEquals('HELLO', $backend->getDigestHash('myRealm', $result)); + + } + + +} + + +class Sabre_DAV_Auth_Backend_AbstractDigestMock extends Sabre_DAV_Auth_Backend_AbstractDigest { + + function getDigestHash($realm, $userName) { + + switch($userName) { + case 'null' : return null; + case 'false' : return false; + case 'array' : return array(); + case 'user' : return 'HELLO'; + } + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php new file mode 100755 index 0000000..1b99206 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php @@ -0,0 +1,31 @@ +getPDO(); + $backend = new Sabre_DAV_Auth_Backend_PDO($pdo); + $this->assertTrue($backend instanceof Sabre_DAV_Auth_Backend_PDO); + + } + + /** + * @depends testConstruct + */ + function testUserInfo() { + + $pdo = $this->getPDO(); + $backend = new Sabre_DAV_Auth_Backend_PDO($pdo); + + $this->assertNull($backend->getDigestHash('realm','blabla')); + + $expected = 'hash'; + + $this->assertEquals($expected, $backend->getDigestHash('realm','user')); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/ApacheTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/ApacheTest.php new file mode 100755 index 0000000..63a5507 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/ApacheTest.php @@ -0,0 +1,40 @@ +authenticate($server,'Realm'); + + } + + function testRemoteUser() { + + $backend = new Sabre_DAV_Auth_Backend_Apache(); + + $server = new Sabre_DAV_Server(); + $request = new Sabre_HTTP_Request(array( + 'REMOTE_USER' => 'username', + )); + $server->httpRequest = $request; + + $this->assertTrue($backend->authenticate($server, 'Realm')); + + $userInfo = 'username'; + + $this->assertEquals($userInfo, $backend->getCurrentUser()); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/FileTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/FileTest.php new file mode 100755 index 0000000..9b5f1cd --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/FileTest.php @@ -0,0 +1,40 @@ +assertTrue($file instanceof Sabre_DAV_Auth_Backend_File); + + } + + /** + * @expectedException Sabre_DAV_Exception + */ + function testLoadFileBroken() { + + file_put_contents(SABRE_TEMPDIR . '/backend','user:realm:hash'); + $file = new Sabre_DAV_Auth_Backend_File(); + $file->loadFile(SABRE_TEMPDIR .'/backend'); + + } + + function testLoadFile() { + + file_put_contents(SABRE_TEMPDIR . '/backend','user:realm:' . md5('user:realm:password')); + $file = new Sabre_DAV_Auth_Backend_File(); + $file->loadFile(SABRE_TEMPDIR . '/backend'); + + $this->assertFalse($file->getDigestHash('realm','blabla')); + $this->assertEquals(md5('user:realm:password'), $file->getDigesthash('realm','user')); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php new file mode 100755 index 0000000..c35cb69 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php @@ -0,0 +1,29 @@ +markTestSkipped('MySQL driver is not available, or not properly configured'); + $pdo = Sabre_TestUtil::getMySQLDB(); + if (!$pdo) $this->markTestSkipped('Could not connect to MySQL database'); + $pdo->query("DROP TABLE IF EXISTS users"); + $pdo->query(" +create table users ( + id integer unsigned not null primary key auto_increment, + username varchar(50), + digesta1 varchar(32), + email varchar(80), + displayname varchar(80), + unique(username) +);"); + + $pdo->query("INSERT INTO users (username,digesta1,email,displayname) VALUES ('user','hash','user@example.org','User')"); + + return $pdo; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php new file mode 100755 index 0000000..bc84c4f --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php @@ -0,0 +1,26 @@ +markTestSkipped('SQLite driver is not available'); + $pdo = new PDO('sqlite:'.SABRE_TEMPDIR.'/pdobackend'); + $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); + $pdo->query('CREATE TABLE users (username TEXT, digesta1 TEXT, email VARCHAR(80), displayname VARCHAR(80))'); + $pdo->query('INSERT INTO users VALUES ("user","hash","user@example.org","User")'); + + return $pdo; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/MockBackend.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/MockBackend.php new file mode 100755 index 0000000..913ab81 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/MockBackend.php @@ -0,0 +1,27 @@ +currentUser = 'admin'; + + } + + function setCurrentUser($user) { + + $this->currentUser = $user; + + } + + function getCurrentUser() { + + return $this->currentUser; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/PluginTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/PluginTest.php new file mode 100755 index 0000000..3a4dbb3 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Auth/PluginTest.php @@ -0,0 +1,80 @@ +assertTrue($plugin instanceof Sabre_DAV_Auth_Plugin); + $fakeServer->addPlugin($plugin); + $this->assertEquals($plugin, $fakeServer->getPlugin('auth')); + + } + + /** + * @depends testInit + */ + function testAuthenticate() { + + $fakeServer = new Sabre_DAV_Server(new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('bla'))); + $plugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(),'realm'); + $fakeServer->addPlugin($plugin); + $fakeServer->broadCastEvent('beforeMethod',array('GET','/')); + + } + + + + /** + * @depends testInit + * @expectedException Sabre_DAV_Exception_NotAuthenticated + */ + function testAuthenticateFail() { + + $fakeServer = new Sabre_DAV_Server(new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('bla'))); + $plugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(),'failme'); + $fakeServer->addPlugin($plugin); + $fakeServer->broadCastEvent('beforeMethod',array('GET','/')); + + } + + function testReportPassThrough() { + + $fakeServer = new Sabre_DAV_Server(new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('bla'))); + $plugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(),'realm'); + $fakeServer->addPlugin($plugin); + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'REPORT', + 'HTTP_CONTENT_TYPE' => 'application/xml', + 'REQUEST_URI' => '/', + )); + $request->setBody(''); + + $fakeServer->httpRequest = $request; + $fakeServer->httpResponse = new Sabre_HTTP_ResponseMock(); + $fakeServer->exec(); + + $this->assertEquals('HTTP/1.1 501 Not Implemented', $fakeServer->httpResponse->status); + + } + + /** + * @depends testInit + */ + function testGetCurrentUserPrincipal() { + + $fakeServer = new Sabre_DAV_Server(new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('bla'))); + $plugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(),'realm'); + $fakeServer->addPlugin($plugin); + $fakeServer->broadCastEvent('beforeMethod',array('GET','/')); + $this->assertEquals('admin', $plugin->getCurrentUser()); + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/BasicNodeTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/BasicNodeTest.php new file mode 100755 index 0000000..ffc6766 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/BasicNodeTest.php @@ -0,0 +1,232 @@ +put('hi'); + + } + + /** + * @expectedException Sabre_DAV_Exception_Forbidden + */ + public function testGet() { + + $file = new Sabre_DAV_FileMock(); + $file->get(); + + } + + public function testGetSize() { + + $file = new Sabre_DAV_FileMock(); + $this->assertEquals(0,$file->getSize()); + + } + + + public function testGetETag() { + + $file = new Sabre_DAV_FileMock(); + $this->assertNull($file->getETag()); + + } + + public function testGetContentType() { + + $file = new Sabre_DAV_FileMock(); + $this->assertNull($file->getContentType()); + + } + + /** + * @expectedException Sabre_DAV_Exception_Forbidden + */ + public function testDelete() { + + $file = new Sabre_DAV_FileMock(); + $file->delete(); + + } + + /** + * @expectedException Sabre_DAV_Exception_Forbidden + */ + public function testSetName() { + + $file = new Sabre_DAV_FileMock(); + $file->setName('hi'); + + } + + public function testGetLastModified() { + + $file = new Sabre_DAV_FileMock(); + // checking if lastmod is within the range of a few seconds + $lastMod = $file->getLastModified(); + $compareTime = ($lastMod + 1)-time(); + $this->assertTrue($compareTime < 3); + + } + + public function testGetChild() { + + $dir = new Sabre_DAV_DirectoryMock(); + $file = $dir->getChild('mockfile'); + $this->assertTrue($file instanceof Sabre_DAV_FileMock); + + } + + public function testChildExists() { + + $dir = new Sabre_DAV_DirectoryMock(); + $this->assertTrue($dir->childExists('mockfile')); + + } + + public function testChildExistsFalse() { + + $dir = new Sabre_DAV_DirectoryMock(); + $this->assertFalse($dir->childExists('mockfile2')); + + } + + /** + * @expectedException Sabre_DAV_Exception_FileNotFound + */ + public function testGetChild404() { + + $dir = new Sabre_DAV_DirectoryMock(); + $file = $dir->getChild('blabla'); + + } + + /** + * @expectedException Sabre_DAV_Exception_Forbidden + */ + public function testCreateFile() { + + $dir = new Sabre_DAV_DirectoryMock(); + $dir->createFile('hello','data'); + + } + + /** + * @expectedException Sabre_DAV_Exception_Forbidden + */ + public function testCreateDirectory() { + + $dir = new Sabre_DAV_DirectoryMock(); + $dir->createDirectory('hello'); + + } + + public function testSimpleDirectoryConstruct() { + + $dir = new Sabre_DAV_SimpleDirectory('simpledir',array()); + + } + + /** + * @depends testSimpleDirectoryConstruct + */ + public function testSimpleDirectoryConstructChild() { + + $file = new Sabre_DAV_FileMock(); + $dir = new Sabre_DAV_SimpleDirectory('simpledir',array($file)); + $file2 = $dir->getChild('mockfile'); + + $this->assertEquals($file,$file2); + + } + + /** + * @expectedException Sabre_DAV_Exception + * @depends testSimpleDirectoryConstruct + */ + public function testSimpleDirectoryBadParam() { + + $dir = new Sabre_DAV_SimpleDirectory('simpledir',array('string shouldn\'t be here')); + + } + + /** + * @depends testSimpleDirectoryConstruct + */ + public function testSimpleDirectoryAddChild() { + + $file = new Sabre_DAV_FileMock(); + $dir = new Sabre_DAV_SimpleDirectory('simpledir'); + $dir->addChild($file); + $file2 = $dir->getChild('mockfile'); + + $this->assertEquals($file,$file2); + + } + + /** + * @depends testSimpleDirectoryConstruct + * @depends testSimpleDirectoryAddChild + */ + public function testSimpleDirectoryGetChildren() { + + $file = new Sabre_DAV_FileMock(); + $dir = new Sabre_DAV_SimpleDirectory('simpledir'); + $dir->addChild($file); + + $this->assertEquals(array($file),$dir->getChildren()); + + } + + /* + * @depends testSimpleDirectoryConstruct + */ + public function testSimpleDirectoryGetName() { + + $dir = new Sabre_DAV_SimpleDirectory('simpledir'); + $this->assertEquals('simpledir',$dir->getName()); + + } + + /** + * @depends testSimpleDirectoryConstruct + * @expectedException Sabre_DAV_Exception_FileNotFound + */ + public function testSimpleDirectoryGetChild404() { + + $dir = new Sabre_DAV_SimpleDirectory('simpledir'); + $dir->getChild('blabla'); + + } +} + +class Sabre_DAV_DirectoryMock extends Sabre_DAV_Directory { + + function getName() { + + return 'mockdir'; + + } + + function getChildren() { + + return array(new Sabre_DAV_FileMock()); + + } + +} + +class Sabre_DAV_FileMock extends Sabre_DAV_File { + + function getName() { + + return 'mockfile'; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Browser/GuessContentTypeTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Browser/GuessContentTypeTest.php new file mode 100755 index 0000000..3fc45fc --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Browser/GuessContentTypeTest.php @@ -0,0 +1,64 @@ +server->getPropertiesForPath('/somefile.jpg',$properties); + $this->assertArrayHasKey(0,$result); + $this->assertArrayHasKey(404,$result[0]); + $this->assertArrayHasKey('{DAV:}getcontenttype',$result[0][404]); + + } + + /** + * @depends testGetProperties + */ + function testGetPropertiesPluginEnabled() { + + $this->server->addPlugin(new Sabre_DAV_Browser_GuessContentType()); + $properties = array( + '{DAV:}getcontenttype', + ); + $result = $this->server->getPropertiesForPath('/somefile.jpg',$properties); + $this->assertArrayHasKey(0,$result); + $this->assertArrayHasKey(200,$result[0]); + $this->assertArrayHasKey('{DAV:}getcontenttype',$result[0][200]); + $this->assertEquals('image/jpeg',$result[0][200]['{DAV:}getcontenttype']); + + } + + /** + * @depends testGetPropertiesPluginEnabled + */ + function testGetPropertiesUnknown() { + + $this->server->addPlugin(new Sabre_DAV_Browser_GuessContentType()); + $properties = array( + '{DAV:}getcontenttype', + ); + $result = $this->server->getPropertiesForPath('/somefile.hoi',$properties); + $this->assertArrayHasKey(0,$result); + $this->assertArrayHasKey(404,$result[0]); + $this->assertArrayHasKey('{DAV:}getcontenttype',$result[0][404]); + + } +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php new file mode 100755 index 0000000..5f42d93 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php @@ -0,0 +1,38 @@ +server->addPlugin(new Sabre_DAV_Browser_MapGetToPropFind()); + + } + + function testCollectionGet() { + + $serverVars = array( + 'REQUEST_URI' => '/', + 'REQUEST_METHOD' => 'GET', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(''); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + 'DAV' => '1, 3, extended-mkcol', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'Incorrect status response received. Full response body: ' . $this->response->body); + + } + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Browser/PluginTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Browser/PluginTest.php new file mode 100755 index 0000000..0bd3226 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Browser/PluginTest.php @@ -0,0 +1,35 @@ +server->addPlugin(new Sabre_DAV_Browser_Plugin()); + + } + + function testCollectionGet() { + + $serverVars = array( + 'REQUEST_URI' => '/', + 'REQUEST_METHOD' => 'GET', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + $this->assertEquals(array( + 'Content-Type' => 'text/html; charset=utf-8', + ), + $this->response->headers + ); + + } + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ClientMock.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ClientMock.php new file mode 100755 index 0000000..2f3983c --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ClientMock.php @@ -0,0 +1,27 @@ +url = $url; + $this->curlSettings = $curlSettings; + return $this->response; + + } + + /** + * Just making this method public + */ + public function getAbsoluteUrl($url) { + + return parent::getAbsoluteUrl($url); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ClientTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ClientTest.php new file mode 100755 index 0000000..8098a64 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ClientTest.php @@ -0,0 +1,514 @@ + '/', + )); + + } + + /** + * @expectedException InvalidArgumentException + */ + function testConstructNoBaseUri() { + + $client = new Sabre_DAV_ClientMock(array()); + + } + + function testRequest() { + + $client = new Sabre_DAV_ClientMock(array( + 'baseUri' => 'http://example.org/foo/bar/', + )); + + $responseBlob = array( + "HTTP/1.1 200 OK", + "Content-Type: text/plain", + "", + "Hello there!" + ); + + $client->response = array( + implode("\r\n", $responseBlob), + array( + 'header_size' => 45, + 'http_code' => 200, + ), + 0, + "" + ); + + $result = $client->request('POST', 'baz', 'sillybody', array('Content-Type' => 'text/plain')); + + $this->assertEquals('http://example.org/foo/bar/baz', $client->url); + $this->assertEquals(array( + CURLOPT_RETURNTRANSFER => true, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS => 'sillybody', + CURLOPT_HEADER => true, + CURLOPT_HTTPHEADER => array('Content-Type: text/plain'), + ), $client->curlSettings); + + $this->assertEquals(array( + 'statusCode' => 200, + 'headers' => array( + 'content-type' => 'text/plain', + ), + 'body' => 'Hello there!' + ), $result); + + + } + + + function testRequestProxy() { + + $client = new Sabre_DAV_ClientMock(array( + 'baseUri' => 'http://example.org/foo/bar/', + 'proxy' => 'http://localhost:8000/', + )); + + $responseBlob = array( + "HTTP/1.1 200 OK", + "Content-Type: text/plain", + "", + "Hello there!" + ); + + $client->response = array( + implode("\r\n", $responseBlob), + array( + 'header_size' => 45, + 'http_code' => 200, + ), + 0, + "" + ); + + $result = $client->request('POST', 'baz', 'sillybody', array('Content-Type' => 'text/plain')); + + $this->assertEquals('http://example.org/foo/bar/baz', $client->url); + $this->assertEquals(array( + CURLOPT_RETURNTRANSFER => true, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS => 'sillybody', + CURLOPT_HEADER => true, + CURLOPT_HTTPHEADER => array('Content-Type: text/plain'), + CURLOPT_PROXY => 'http://localhost:8000/', + ), $client->curlSettings); + + $this->assertEquals(array( + 'statusCode' => 200, + 'headers' => array( + 'content-type' => 'text/plain', + ), + 'body' => 'Hello there!' + ), $result); + + } + + + function testRequestAuth() { + + $client = new Sabre_DAV_ClientMock(array( + 'baseUri' => 'http://example.org/foo/bar/', + 'userName' => 'user', + 'password' => 'password', + )); + + $responseBlob = array( + "HTTP/1.1 200 OK", + "Content-Type: text/plain", + "", + "Hello there!" + ); + + $client->response = array( + implode("\r\n", $responseBlob), + array( + 'header_size' => 45, + 'http_code' => 200, + ), + 0, + "" + ); + + $result = $client->request('POST', 'baz', 'sillybody', array('Content-Type' => 'text/plain')); + + $this->assertEquals('http://example.org/foo/bar/baz', $client->url); + $this->assertEquals(array( + CURLOPT_RETURNTRANSFER => true, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS => 'sillybody', + CURLOPT_HEADER => true, + CURLOPT_HTTPHEADER => array('Content-Type: text/plain'), + CURLOPT_HTTPAUTH => CURLAUTH_BASIC | CURLAUTH_DIGEST, + CURLOPT_USERPWD => 'user:password' + ), $client->curlSettings); + + $this->assertEquals(array( + 'statusCode' => 200, + 'headers' => array( + 'content-type' => 'text/plain', + ), + 'body' => 'Hello there!' + ), $result); + + } + + function testRequestError() { + + $client = new Sabre_DAV_ClientMock(array( + 'baseUri' => 'http://example.org/foo/bar/', + )); + + $responseBlob = array( + "HTTP/1.1 200 OK", + "Content-Type: text/plain", + "", + "Hello there!" + ); + + $client->response = array( + implode("\r\n", $responseBlob), + array( + 'header_size' => 45, + 'http_code' => 200, + ), + CURLE_COULDNT_CONNECT, + "Could not connect, or something" + ); + + $caught = false; + try { + $client->request('POST', 'baz', 'sillybody', array('Content-Type' => 'text/plain')); + } catch (Sabre_DAV_Exception $e) { + $caught = true; + } + if (!$caught) { + $this->markTestFailed('Exception was not thrown'); + } + + } + + function testRequestHTTPError() { + + $client = new Sabre_DAV_ClientMock(array( + 'baseUri' => 'http://example.org/foo/bar/', + )); + + $responseBlob = array( + "HTTP/1.1 400 Bad Request", + "Content-Type: text/plain", + "", + "Hello there!" + ); + + $client->response = array( + implode("\r\n", $responseBlob), + array( + 'header_size' => 45, + 'http_code' => 400, + ), + 0, + "" + ); + + $caught = false; + try { + $client->request('POST', 'baz', 'sillybody', array('Content-Type' => 'text/plain')); + } catch (Sabre_DAV_Exception $e) { + $caught = true; + } + if (!$caught) { + $this->fail('Exception was not thrown'); + } + + } + + function testGetAbsoluteUrl() { + + $client = new Sabre_DAV_ClientMock(array( + 'baseUri' => 'http://example.org/foo/', + )); + + $this->assertEquals( + 'http://example.org/foo/bar', + $client->getAbsoluteUrl('bar') + ); + + $this->assertEquals( + 'http://example.org/bar', + $client->getAbsoluteUrl('/bar') + ); + + $this->assertEquals( + 'http://example.com/bar', + $client->getAbsoluteUrl('http://example.com/bar') + ); + + } + + function testOptions() { + + $client = new Sabre_DAV_ClientMock(array( + 'baseUri' => 'http://example.org/foo/bar/', + )); + + $responseBlob = array( + "HTTP/1.1 200 OK", + "DAV: feature1, feature2", + "", + ); + + $client->response = array( + implode("\r\n", $responseBlob), + array( + 'header_size' => 40, + 'http_code' => 200, + ), + 0, + "" + ); + + $result = $client->options(); + $this->assertEquals( + array('feature1', 'feature2'), + $result + ); + + } + + function testOptionsNoDav() { + + $client = new Sabre_DAV_ClientMock(array( + 'baseUri' => 'http://example.org/foo/bar/', + )); + + $responseBlob = array( + "HTTP/1.1 200 OK", + "", + ); + + $client->response = array( + implode("\r\n", $responseBlob), + array( + 'header_size' => 20, + 'http_code' => 200, + ), + 0, + "" + ); + + $result = $client->options(); + $this->assertEquals( + array(), + $result + ); + + } + + /** + * @expectedException InvalidArgumentException + */ + function testPropFindNoXML() { + + $client = new Sabre_DAV_ClientMock(array( + 'baseUri' => 'http://example.org/foo/bar/', + )); + + $responseBlob = array( + "HTTP/1.1 200 OK", + "", + ); + + $client->response = array( + implode("\r\n", $responseBlob), + array( + 'header_size' => 20, + 'http_code' => 200, + ), + 0, + "" + ); + + $client->propfind('', array('{DAV:}foo','{DAV:}bar')); + + } + + function testPropFind() { + + $client = new Sabre_DAV_ClientMock(array( + 'baseUri' => 'http://example.org/foo/bar/', + )); + + $responseBlob = array( + "HTTP/1.1 200 OK", + "", + "", + "", + " ", + " /foo/bar/", + " ", + " ", + " hello", + " ", + " HTTP/1.1 200 OK", + " ", + " ", + " ", + " ", + " ", + " HTTP/1.1 404 Not Found", + " ", + " ", + "", + ); + + $client->response = array( + implode("\r\n", $responseBlob), + array( + 'header_size' => 19, + 'http_code' => 200, + ), + 0, + "" + ); + + $result = $client->propfind('', array('{DAV:}foo','{DAV:}bar')); + + $this->assertEquals(array( + '{DAV:}foo' => 'hello', + ), $result); + + $requestBody = array( + '', + '', + ' ', + ' ', + ' ', + ' ', + '' + ); + $requestBody = implode("\n", $requestBody); + + $this->assertEquals($requestBody, $client->curlSettings[CURLOPT_POSTFIELDS]); + + } + + function testPropFindDepth1CustomProp() { + + $client = new Sabre_DAV_ClientMock(array( + 'baseUri' => 'http://example.org/foo/bar/', + )); + + $responseBlob = array( + "HTTP/1.1 200 OK", + "", + "", + "", + " ", + " /foo/bar/", + " ", + " ", + " hello", + " world", + " ", + " HTTP/1.1 200 OK", + " ", + " ", + "", + ); + + $client->response = array( + implode("\r\n", $responseBlob), + array( + 'header_size' => 19, + 'http_code' => 200, + ), + 0, + "" + ); + + $result = $client->propfind('', array('{DAV:}foo','{urn:custom}bar'),1); + + $this->assertEquals(array( + "/foo/bar/" => array( + '{DAV:}foo' => 'hello', + '{urn:custom}bar' => 'world', + ), + ), $result); + + $requestBody = array( + '', + '', + ' ', + ' ', + ' ', + ' ', + '' + ); + $requestBody = implode("\n", $requestBody); + + $this->assertEquals($requestBody, $client->curlSettings[CURLOPT_POSTFIELDS]); + + } + + function testPropPatch() { + + $client = new Sabre_DAV_ClientMock(array( + 'baseUri' => 'http://example.org/foo/bar/', + )); + + $responseBlob = array( + "HTTP/1.1 200 OK", + "", + ); + + $client->response = array( + implode("\r\n", $responseBlob), + array( + 'header_size' => 20, + 'http_code' => 200, + ), + 0, + "" + ); + + $client->proppatch('', array( + '{DAV:}foo' => 'newvalue', + '{urn:custom}foo' => 'newvalue2', + '{DAV:}bar' => null, + '{urn:custom}bar' => null, + )); + + $requestBody = array( + '', + '', + '', + ' newvalue', + '', + '', + ' newvalue2', + '', + '', + ' ', + '', + '', + ' ', + '', + '' + ); + $requestBody = implode("\n", $requestBody); + + $this->assertEquals($requestBody, $client->curlSettings[CURLOPT_POSTFIELDS]); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ExceptionTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ExceptionTest.php new file mode 100755 index 0000000..6841327 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ExceptionTest.php @@ -0,0 +1,28 @@ +assertEquals(500,$e->getHTTPCode()); + + } + + function testExceptionStatuses() { + + $c = array( + 'Sabre_DAV_Exception_NotAuthenticated' => 401, + 'Sabre_DAV_Exception_InsufficientStorage' => 507, + ); + + foreach($c as $class=>$status) { + + $obj = new $class(); + $this->assertEquals($status, $obj->getHTTPCode()); + + } + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/FSExt/FileTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/FSExt/FileTest.php new file mode 100755 index 0000000..9614d56 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/FSExt/FileTest.php @@ -0,0 +1,65 @@ +put('New contents'); + + $this->assertEquals('New contents',file_get_contents(SABRE_TEMPDIR . '/file.txt')); + + } + + function testGet() { + + $file = new Sabre_DAV_FSExt_File(SABRE_TEMPDIR . '/file.txt'); + $this->assertEquals('Contents',stream_get_contents($file->get())); + + } + + function testDelete() { + + $file = new Sabre_DAV_FSExt_File(SABRE_TEMPDIR . '/file.txt'); + $file->delete(); + + $this->assertFalse(file_exists(SABRE_TEMPDIR . '/file.txt')); + + } + + function testGetETag() { + + $file = new Sabre_DAV_FSExt_File(SABRE_TEMPDIR . '/file.txt'); + $this->assertEquals('"' . md5('Contents') . '"',$file->getETag()); + + } + + function testGetContentType() { + + $file = new Sabre_DAV_FSExt_File(SABRE_TEMPDIR . '/file.txt'); + $this->assertNull($file->getContentType()); + + } + + function testGetSize() { + + $file = new Sabre_DAV_FSExt_File(SABRE_TEMPDIR . '/file.txt'); + $this->assertEquals(8,$file->getSize()); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/FSExt/NodeTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/FSExt/NodeTest.php new file mode 100755 index 0000000..a15ea37 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/FSExt/NodeTest.php @@ -0,0 +1,307 @@ +assertEquals(array(),$file->getLocks()); + + } + + function testLock() { + + $file = new Sabre_DAV_FSExt_File(SABRE_TEMPDIR . '/dir/file.txt'); + $lockInfo = new Sabre_DAV_Locks_LockInfo(); + $lockInfo->owner = 'me'; + $lockInfo->token = 'SOMERANDOMSTRING'; + $file->lock($lockInfo); + + $result = $file->getLocks(); + $this->assertEquals(1,count($result)); + + $this->assertEquals('me',$result[0]->owner); + $this->assertEquals('SOMERANDOMSTRING',$result[0]->token); + + } + + + /** + * @depends testLock + */ + function testLockAgain() { + + $file = new Sabre_DAV_FSExt_File(SABRE_TEMPDIR . '/dir/file.txt'); + $lockInfo = new Sabre_DAV_Locks_LockInfo(); + $lockInfo->owner = 'me'; + $lockInfo->token = 'SOMERANDOMSTRING'; + $file->lock($lockInfo); + + $lockInfo->owner = 'me2'; + $lockInfo->token = 'SOMERANDOMSTRING2'; + $file->lock($lockInfo); + + $result = $file->getLocks(); + $this->assertEquals(2,count($result)); + + $this->assertEquals('me',$result[0]->owner); + $this->assertEquals('SOMERANDOMSTRING',$result[0]->token); + + $this->assertEquals('me2',$result[1]->owner); + $this->assertEquals('SOMERANDOMSTRING2',$result[1]->token); + + } + + /** + * @depends testLock + */ + function testLockRefresh() { + + $file = new Sabre_DAV_FSExt_File(SABRE_TEMPDIR . '/dir/file.txt'); + $lockInfo = new Sabre_DAV_Locks_LockInfo(); + $lockInfo->owner = 'me'; + $lockInfo->token = 'SOMERANDOMSTRING'; + $file->lock($lockInfo); + + $lockInfo->owner = 'you'; + $lockInfo->token = 'SOMERANDOMSTRING'; + $file->lock($lockInfo); + + $result = $file->getLocks(); + $this->assertEquals(1,count($result)); + list($result) = $result; + + $this->assertEquals('you',$result->owner,'Wrong owner. We received: ' . print_r($result,true)); + $this->assertEquals('SOMERANDOMSTRING',$result->token); + + + } + + /** + * @depends testLock + */ + function testUnlock() { + + $file = new Sabre_DAV_FSExt_File(SABRE_TEMPDIR . '/dir/file.txt'); + $lockInfo = new Sabre_DAV_Locks_LockInfo(); + $lockInfo->owner = 'me'; + $lockInfo->token = 'SOMERANDOMSTRING'; + + $file->lock($lockInfo); + + $result = $file->getLocks(); + $this->assertEquals(1,count($result)); + + $file->unlock($lockInfo); + $result = $file->getLocks(); + $this->assertEquals(0,count($result)); + + } + + /** + * @depends testUnlock + */ + function testUnlockNotFound() { + + $file = new Sabre_DAV_FSExt_File(SABRE_TEMPDIR . '/dir/file.txt'); + $lockInfo = new Sabre_DAV_Locks_LockInfo(); + $lockInfo->owner = 'me'; + $lockInfo->token = 'SOMERANDOMSTRING'; + + $result = $file->unlock($lockInfo); + $this->assertFalse($result); + + } + + function testUpdateProperties() { + + $file = new Sabre_DAV_FSExt_File(SABRE_TEMPDIR . '/dir/file.txt'); + $properties = array( + '{http://sabredav.org/NS/2010}test1' => 'foo', + '{http://sabredav.org/NS/2010}test2' => 'bar', + ); + + $result = $file->updateProperties($properties); + $expected = true; + + $this->assertEquals($expected, $result); + + $getProperties = $file->getProperties(array_keys($properties)); + + $this->assertEquals($properties, $getProperties); + + } + + /** + * @depends testUpdateProperties + */ + function testUpdatePropertiesAgain() { + + $file = new Sabre_DAV_FSExt_File(SABRE_TEMPDIR . '/dir/file.txt'); + $mutations = array( + '{http://sabredav.org/NS/2010}test1' => 'foo', + '{http://sabredav.org/NS/2010}test2' => 'bar', + ); + + $result = $file->updateProperties($mutations); + + $this->assertEquals(true, $result); + + $mutations = array( + '{http://sabredav.org/NS/2010}test1' => 'foo', + '{http://sabredav.org/NS/2010}test3' => 'baz', + ); + + $result = $file->updateProperties($mutations); + + $this->assertEquals(true, $result); + } + + /** + * @depends testUpdateProperties + */ + function testUpdatePropertiesDelete() { + + $file = new Sabre_DAV_FSExt_File(SABRE_TEMPDIR . '/dir/file.txt'); + + $mutations = array( + '{http://sabredav.org/NS/2010}test1' => 'foo', + '{http://sabredav.org/NS/2010}test2' => 'bar', + ); + + $result = $file->updateProperties($mutations); + + $this->assertEquals(true, $result); + + $mutations = array( + '{http://sabredav.org/NS/2010}test1' => null, + '{http://sabredav.org/NS/2010}test3' => null + ); + + $result = $file->updateProperties($mutations); + + $this->assertEquals(true, $result); + + $properties = $file->getProperties(array('http://sabredav.org/NS/2010}test1','{http://sabredav.org/NS/2010}test2','{http://sabredav.org/NS/2010}test3')); + + $this->assertEquals(array( + '{http://sabredav.org/NS/2010}test2' => 'bar', + ), $properties); + } + + /** + * @depends testUpdateProperties + */ + function testUpdatePropertiesMove() { + + $file = new Sabre_DAV_FSExt_File(SABRE_TEMPDIR . '/dir/file.txt'); + + $mutations = array( + '{http://sabredav.org/NS/2010}test1' => 'foo', + '{http://sabredav.org/NS/2010}test2' => 'bar', + ); + + $result = $file->updateProperties($mutations); + + $this->assertEquals(true, $result); + + $properties = $file->getProperties(array('{http://sabredav.org/NS/2010}test1','{http://sabredav.org/NS/2010}test2','{http://sabredav.org/NS/2010}test3')); + + $this->assertEquals(array( + '{http://sabredav.org/NS/2010}test1' => 'foo', + '{http://sabredav.org/NS/2010}test2' => 'bar', + ), $properties); + + // Renaming + $file->setName('file3.txt'); + + $this->assertFalse(file_exists(SABRE_TEMPDIR . '/dir/file.txt')); + $this->assertTrue(file_exists(SABRE_TEMPDIR . '/dir/file3.txt')); + $this->assertEquals('file3.txt',$file->getName()); + + $newFile = new Sabre_DAV_FSExt_File(SABRE_TEMPDIR . '/dir/file3.txt'); + $this->assertEquals('file3.txt',$newFile->getName()); + + $properties = $newFile->getProperties(array('{http://sabredav.org/NS/2010}test1','{http://sabredav.org/NS/2010}test2','{http://sabredav.org/NS/2010}test3')); + + $this->assertEquals(array( + '{http://sabredav.org/NS/2010}test1' => 'foo', + '{http://sabredav.org/NS/2010}test2' => 'bar', + ), $properties); + } + + /** + * @depends testUpdatePropertiesMove + */ + function testUpdatePropertiesDeleteBleed() { + + $file = new Sabre_DAV_FSExt_File(SABRE_TEMPDIR . '/dir/file.txt'); + $mutations = array( + '{http://sabredav.org/NS/2010}test1' => 'foo', + '{http://sabredav.org/NS/2010}test2' => 'bar', + ); + + $result = $file->updateProperties($mutations); + + $this->assertEquals(true, $result); + + $properties = $file->getProperties(array('{http://sabredav.org/NS/2010}test1','{http://sabredav.org/NS/2010}test2','{http://sabredav.org/NS/2010}test3')); + + $this->assertEquals(array( + '{http://sabredav.org/NS/2010}test1' => 'foo', + '{http://sabredav.org/NS/2010}test2' => 'bar', + ), $properties); + + // Deleting + $file->delete(); + + $this->assertFalse(file_exists(SABRE_TEMPDIR . '/dir/file.txt')); + + // Creating it again + file_put_contents(SABRE_TEMPDIR . '/dir/file.txt','New Contents'); + $file = new Sabre_DAV_FSExt_File(SABRE_TEMPDIR . '/dir/file.txt'); + + $properties = $file->getProperties(array('http://sabredav.org/NS/2010}test1','{http://sabredav.org/NS/2010}test2','{http://sabredav.org/NS/2010}test3')); + + $this->assertEquals(array(), $properties); + + } + + /** + * @depends testLock + */ + function testMultipleFilesInDir() { + + $file1 = new Sabre_DAV_FSExt_File(SABRE_TEMPDIR . '/dir/file.txt'); + $lockInfo = new Sabre_DAV_Locks_LockInfo(); + $lockInfo->owner = 'me'; + $lockInfo->token = 'SOMERANDOMSTRING'; + $file1->lock($lockInfo); + + // What we're testing is, to make sure that changing resourcedata + // from one file does not mess with resourcedata from another + + $file2 = new Sabre_DAV_FSExt_File(SABRE_TEMPDIR . '/dir/file2.txt'); + $result = $file2->getLocks(); + + $this->assertEquals(array(), $result); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/FSExt/ServerTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/FSExt/ServerTest.php new file mode 100755 index 0000000..949f067 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/FSExt/ServerTest.php @@ -0,0 +1,222 @@ +tempDir); + + } + + function testGet() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'GET', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/octet-stream', + 'Content-Length' => 13, + 'Last-Modified' => date(DateTime::RFC1123,filemtime($this->tempDir . '/test.txt')), + 'ETag' => '"' .md5_file($this->tempDir . '/test.txt') . '"', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + $this->assertEquals('Test contents', stream_get_contents($this->response->body)); + + } + + function testHEAD() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'HEAD', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/octet-stream', + 'Content-Length' => 13, + 'Last-Modified' => date(DateTime::RFC1123,filemtime($this->tempDir . '/test.txt')), + 'ETag' => '"' . md5_file($this->tempDir . '/test.txt') . '"', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + $this->assertEquals('', $this->response->body); + + } + + function testPut() { + + $serverVars = array( + 'REQUEST_URI' => '/testput.txt', + 'REQUEST_METHOD' => 'PUT', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody('Testing new file'); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Length' => '0', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status); + $this->assertEquals('', $this->response->body); + $this->assertEquals('Testing new file',file_get_contents($this->tempDir . '/testput.txt')); + + } + + function testPutAlreadyExists() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'PUT', + 'HTTP_IF_NONE_MATCH' => '*', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody('Testing new file'); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 412 Precondition failed',$this->response->status); + $this->assertNotEquals('Testing new file',file_get_contents($this->tempDir . '/test.txt')); + + } + + function testMkcol() { + + $serverVars = array( + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(""); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Length' => '0', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status); + $this->assertEquals('', $this->response->body); + $this->assertTrue(is_dir($this->tempDir . '/testcol')); + + } + + function testPutUpdate() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'PUT', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody('Testing updated file'); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Length' => '0', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status); + $this->assertEquals('', $this->response->body); + $this->assertEquals('Testing updated file',file_get_contents($this->tempDir . '/test.txt')); + + } + + function testDelete() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'DELETE', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Length' => '0', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status); + $this->assertEquals('', $this->response->body); + $this->assertFalse(file_exists($this->tempDir . '/test.txt')); + + } + + function testDeleteDirectory() { + + $serverVars = array( + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'DELETE', + ); + + mkdir($this->tempDir.'/testcol'); + file_put_contents($this->tempDir.'/testcol/test.txt','Hi! I\'m a file with a short lifespan'); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Length' => '0', + ),$this->response->headers); + $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status); + $this->assertEquals('', $this->response->body); + $this->assertFalse(file_exists($this->tempDir . '/col')); + + } + + function testOptions() { + + $serverVars = array( + 'REQUEST_URI' => '/', + 'REQUEST_METHOD' => 'OPTIONS', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'DAV' => '1, 3, extended-mkcol', + 'MS-Author-Via' => 'DAV', + 'Allow' => 'OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT', + 'Accept-Ranges' => 'bytes', + 'Content-Length' => '0', + 'X-Sabre-Version'=> Sabre_DAV_Version::VERSION, + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + $this->assertEquals('', $this->response->body); + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Issue33Test.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Issue33Test.php new file mode 100755 index 0000000..9453398 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Issue33Test.php @@ -0,0 +1,102 @@ +setBaseUri('/webdav/'); + + $serverVars = array( + 'REQUEST_URI' => '/webdav/foo', + 'HTTP_DESTINATION' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3', + 'HTTP_OVERWRITE' => 'F', + ); + + $request = new Sabre_HTTP_Request($serverVars); + + $server->httpRequest = $request; + + $info = $server->getCopyAndMoveInfo(); + + $this->assertEquals('%C3%A0fo%C3%B3', urlencode($info['destination'])); + $this->assertFalse($info['destinationExists']); + $this->assertFalse($info['destinationNode']); + + } + + function testTreeMove() { + + mkdir(SABRE_TEMPDIR . '/issue33'); + $dir = new Sabre_DAV_FS_Directory(SABRE_TEMPDIR . '/issue33'); + + $dir->createDirectory('foo'); + + $tree = new Sabre_DAV_ObjectTree($dir); + $tree->move('foo',urldecode('%C3%A0fo%C3%B3')); + + $node = $tree->getNodeForPath(urldecode('%C3%A0fo%C3%B3')); + $this->assertEquals(urldecode('%C3%A0fo%C3%B3'),$node->getName()); + + } + + function testDirName() { + + $dirname1 = 'foo'; + $dirname2 = urlencode('%C3%A0fo%C3%B3');; + + $this->assertTrue(dirname($dirname1)==dirname($dirname2)); + + } + + /** + * @depends testTreeMove + * @depends testCopyMoveInfo + */ + function testEverything() { + + // Request object + $serverVars = array( + 'REQUEST_METHOD' => 'MOVE', + 'REQUEST_URI' => '/webdav/foo', + 'HTTP_DESTINATION' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3', + 'HTTP_OVERWRITE' => 'F', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(''); + + $response = new Sabre_HTTP_ResponseMock(); + + // Server setup + mkdir(SABRE_TEMPDIR . '/issue33'); + $dir = new Sabre_DAV_FS_Directory(SABRE_TEMPDIR . '/issue33'); + + $dir->createDirectory('foo'); + + $tree = new Sabre_DAV_ObjectTree($dir); + + $server = new Sabre_DAV_Server($tree); + $server->setBaseUri('/webdav/'); + + $server->httpRequest = $request; + $server->httpResponse = $response; + $server->exec(); + + $this->assertTrue(file_exists(SABRE_TEMPDIR . '/issue33/' . urldecode('%C3%A0fo%C3%B3'))); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/Backend/AbstractTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/Backend/AbstractTest.php new file mode 100755 index 0000000..39f1b68 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/Backend/AbstractTest.php @@ -0,0 +1,188 @@ +getBackend(); + $this->assertInstanceOf('Sabre_DAV_Locks_Backend_Abstract', $backend); + + } + + /** + * @depends testSetup + */ + function testGetLocks() { + + $backend = $this->getBackend(); + + $lock = new Sabre_DAV_Locks_LockInfo(); + $lock->owner = 'Sinterklaas'; + $lock->timeout = 60; + $lock->created = time(); + $lock->token = 'MY-UNIQUE-TOKEN'; + $lock->uri ='someuri'; + + $this->assertTrue($backend->lock('someuri', $lock)); + + $locks = $backend->getLocks('someuri', false); + + $this->assertEquals(1,count($locks)); + $this->assertEquals('Sinterklaas',$locks[0]->owner); + $this->assertEquals('someuri',$locks[0]->uri); + + } + + /** + * @depends testGetLocks + */ + function testGetLocksParent() { + + $backend = $this->getBackend(); + + $lock = new Sabre_DAV_Locks_LockInfo(); + $lock->owner = 'Sinterklaas'; + $lock->timeout = 60; + $lock->created = time(); + $lock->depth = Sabre_DAV_Server::DEPTH_INFINITY; + $lock->token = 'MY-UNIQUE-TOKEN'; + + $this->assertTrue($backend->lock('someuri', $lock)); + + $locks = $backend->getLocks('someuri/child', false); + + $this->assertEquals(1,count($locks)); + $this->assertEquals('Sinterklaas',$locks[0]->owner); + $this->assertEquals('someuri',$locks[0]->uri); + + } + + + /** + * @depends testGetLocks + */ + function testGetLocksParentDepth0() { + + $backend = $this->getBackend(); + + $lock = new Sabre_DAV_Locks_LockInfo(); + $lock->owner = 'Sinterklaas'; + $lock->timeout = 60; + $lock->created = time(); + $lock->depth = 0; + $lock->token = 'MY-UNIQUE-TOKEN'; + + $this->assertTrue($backend->lock('someuri', $lock)); + + $locks = $backend->getLocks('someuri/child', false); + + $this->assertEquals(0,count($locks)); + + } + + function testGetLocksChildren() { + + $backend = $this->getBackend(); + + $lock = new Sabre_DAV_Locks_LockInfo(); + $lock->owner = 'Sinterklaas'; + $lock->timeout = 60; + $lock->created = time(); + $lock->depth = 0; + $lock->token = 'MY-UNIQUE-TOKEN'; + + $this->assertTrue($backend->lock('someuri/child', $lock)); + + $locks = $backend->getLocks('someuri/child', false); + $this->assertEquals(1,count($locks)); + + $locks = $backend->getLocks('someuri', false); + $this->assertEquals(0,count($locks)); + + $locks = $backend->getLocks('someuri', true); + $this->assertEquals(1,count($locks)); + + } + + /** + * @depends testGetLocks + */ + function testLockRefresh() { + + $backend = $this->getBackend(); + + $lock = new Sabre_DAV_Locks_LockInfo(); + $lock->owner = 'Sinterklaas'; + $lock->timeout = 60; + $lock->created = time(); + $lock->token = 'MY-UNIQUE-TOKEN'; + + $this->assertTrue($backend->lock('someuri', $lock)); + /* Second time */ + + $lock->owner = 'Santa Clause'; + $this->assertTrue($backend->lock('someuri', $lock)); + + $locks = $backend->getLocks('someuri', false); + + $this->assertEquals(1,count($locks)); + + $this->assertEquals('Santa Clause',$locks[0]->owner); + $this->assertEquals('someuri',$locks[0]->uri); + + } + + /** + * @depends testGetLocks + */ + function testUnlock() { + + $backend = $this->getBackend(); + + $lock = new Sabre_DAV_Locks_LockInfo(); + $lock->owner = 'Sinterklaas'; + $lock->timeout = 60; + $lock->created = time(); + $lock->token = 'MY-UNIQUE-TOKEN'; + + $this->assertTrue($backend->lock('someuri', $lock)); + + $locks = $backend->getLocks('someuri', false); + $this->assertEquals(1,count($locks)); + + $this->assertTrue($backend->unlock('someuri',$lock)); + + $locks = $backend->getLocks('someuri', false); + $this->assertEquals(0,count($locks)); + + } + + /** + * @depends testUnlock + */ + function testUnlockUnknownToken() { + + $backend = $this->getBackend(); + + $lock = new Sabre_DAV_Locks_LockInfo(); + $lock->owner = 'Sinterklaas'; + $lock->timeout = 60; + $lock->created = time(); + $lock->token = 'MY-UNIQUE-TOKEN'; + + $this->assertTrue($backend->lock('someuri', $lock)); + + $locks = $backend->getLocks('someuri', false); + $this->assertEquals(1,count($locks)); + + $lock->token = 'SOME-OTHER-TOKEN'; + $this->assertFalse($backend->unlock('someuri',$lock)); + + $locks = $backend->getLocks('someuri', false); + $this->assertEquals(1,count($locks)); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/Backend/FSTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/Backend/FSTest.php new file mode 100755 index 0000000..ddf4f50 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/Backend/FSTest.php @@ -0,0 +1,29 @@ +markTestSkipped('MySQL driver is not available, or it was not properly configured'); + $pdo = Sabre_TestUtil::getMySQLDB(); + if (!$pdo) $this->markTestSkipped('Could not connect to MySQL database'); + $pdo->query('DROP TABLE IF EXISTS locks;'); + $pdo->query(" +CREATE TABLE locks ( + id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + owner VARCHAR(100), + timeout INTEGER UNSIGNED, + created INTEGER, + token VARCHAR(100), + scope TINYINT, + depth TINYINT, + uri text +);"); + + $backend = new Sabre_DAV_Locks_Backend_PDO($pdo); + return $backend; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/Backend/PDOTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/Backend/PDOTest.php new file mode 100755 index 0000000..5aebc6b --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/Backend/PDOTest.php @@ -0,0 +1,27 @@ +markTestSkipped('SQLite driver is not available'); + Sabre_TestUtil::clearTempDir(); + mkdir(SABRE_TEMPDIR . '/pdolocks'); + $pdo = new PDO('sqlite:' . SABRE_TEMPDIR . '/pdolocks/db.sqlite'); + $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); + $pdo->query('CREATE TABLE locks ( id integer primary key asc, owner text, timeout text, created integer, token text, scope integer, depth integer, uri text)'); + $backend = new Sabre_DAV_Locks_Backend_PDO($pdo); + return $backend; + + } + + function tearDown() { + + Sabre_TestUtil::clearTempDir(); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/GetIfConditionsTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/GetIfConditionsTest.php new file mode 100755 index 0000000..0763d73 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/GetIfConditionsTest.php @@ -0,0 +1,369 @@ +server->addPlugin($locksPlugin); + $this->locksPlugin = $locksPlugin; + + } + + function testNoConditions() { + + $serverVars = array( + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + + $conditions = $this->locksPlugin->getIfConditions(); + $this->assertEquals(array(),$conditions); + + } + + function testLockToken() { + + $serverVars = array( + 'HTTP_IF' => '()', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + + $conditions = $this->locksPlugin->getIfConditions(); + + $compare = array( + + array( + 'uri' => '', + 'tokens' => array( + array( + 1, + 'opaquelocktoken:token1', + '', + ), + ), + + ), + + ); + + $this->assertEquals($compare,$conditions); + + } + + function testNotLockToken() { + + $serverVars = array( + 'HTTP_IF' => '(Not )', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + + $conditions = $this->locksPlugin->getIfConditions(); + + $compare = array( + + array( + 'uri' => '', + 'tokens' => array( + array( + 0, + 'opaquelocktoken:token1', + '', + ), + ), + + ), + + ); + $this->assertEquals($compare,$conditions); + + } + + function testLockTokenUrl() { + + $serverVars = array( + 'HTTP_IF' => ' ()', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + + $conditions = $this->locksPlugin->getIfConditions(); + + $compare = array( + + array( + 'uri' => 'http://www.example.com/', + 'tokens' => array( + array( + 1, + 'opaquelocktoken:token1', + '', + ), + ), + + ), + + ); + $this->assertEquals($compare,$conditions); + + } + + function test2LockTokens() { + + $serverVars = array( + 'HTTP_IF' => '() (Not )', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + + $conditions = $this->locksPlugin->getIfConditions(); + + $compare = array( + + array( + 'uri' => '', + 'tokens' => array( + array( + 1, + 'opaquelocktoken:token1', + '', + ), + array( + 0, + 'opaquelocktoken:token2', + '', + ), + ), + + ), + + ); + $this->assertEquals($compare,$conditions); + + } + + function test2UriLockTokens() { + + $serverVars = array( + 'HTTP_IF' => ' () (Not )', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + + $conditions = $this->locksPlugin->getIfConditions(); + + $compare = array( + + array( + 'uri' => 'http://www.example.org/node1', + 'tokens' => array( + array( + 1, + 'opaquelocktoken:token1', + '', + ), + ), + ), + array( + 'uri' => 'http://www.example.org/node2', + 'tokens' => array( + array( + 0, + 'opaquelocktoken:token2', + '', + ), + ), + + ), + + ); + $this->assertEquals($compare,$conditions); + + } + + function test2UriMultiLockTokens() { + + $serverVars = array( + 'HTTP_IF' => ' () () (Not )', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + + $conditions = $this->locksPlugin->getIfConditions(); + + $compare = array( + + array( + 'uri' => 'http://www.example.org/node1', + 'tokens' => array( + array( + 1, + 'opaquelocktoken:token1', + '', + ), + array( + 1, + 'opaquelocktoken:token2', + '', + ), + ), + ), + array( + 'uri' => 'http://www.example.org/node2', + 'tokens' => array( + array( + 0, + 'opaquelocktoken:token3', + '', + ), + ), + + ), + + ); + $this->assertEquals($compare,$conditions); + + } + + function testEtag() { + + $serverVars = array( + 'HTTP_IF' => '([etag1])', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + + $conditions = $this->locksPlugin->getIfConditions(); + + $compare = array( + + array( + 'uri' => '', + 'tokens' => array( + array( + 1, + '', + 'etag1', + ), + ), + ), + + ); + $this->assertEquals($compare,$conditions); + + } + + function test2Etags() { + + $serverVars = array( + 'HTTP_IF' => ' ([etag1]) ([etag2])', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + + $conditions = $this->locksPlugin->getIfConditions(); + + $compare = array( + + array( + 'uri' => 'http://www.example.org/', + 'tokens' => array( + array( + 1, + '', + 'etag1', + ), + array( + 1, + '', + 'etag2', + ), + ), + ), + + ); + $this->assertEquals($compare,$conditions); + + } + + function testComplexIf() { + + $serverVars = array( + 'HTTP_IF' => ' ( [etag1]) ' . + '(Not ) ([etag2]) ' . + '() (Not ) ([etag3])', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + + $conditions = $this->locksPlugin->getIfConditions(); + + $compare = array( + + array( + 'uri' => 'http://www.example.org/node1', + 'tokens' => array( + array( + 1, + 'opaquelocktoken:token1', + 'etag1', + ), + array( + 0, + 'opaquelocktoken:token2', + '', + ), + array( + 1, + '', + 'etag2', + ), + ), + ), + array( + 'uri' => 'http://www.example.org/node2', + 'tokens' => array( + array( + 1, + 'opaquelocktoken:token3', + '', + ), + array( + 0, + 'opaquelocktoken:token4', + '', + ), + array( + 1, + '', + 'etag3', + ), + ), + ), + + ); + $this->assertEquals($compare,$conditions); + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/MSWordTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/MSWordTest.php new file mode 100755 index 0000000..41317fe --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/MSWordTest.php @@ -0,0 +1,118 @@ +debugExceptions = true; + $locksBackend = new Sabre_DAV_Locks_Backend_File(SABRE_TEMPDIR . '/locksdb'); + $locksPlugin = new Sabre_DAV_Locks_Plugin($locksBackend); + $server->addPlugin($locksPlugin); + + $response1 = new Sabre_HTTP_ResponseMock(); + + $server->httpRequest = $this->getLockRequest(); + $server->httpResponse = $response1; + $server->exec(); + + $this->assertEquals('HTTP/1.1 201 Created', $server->httpResponse->status); + $this->assertTrue(isset($server->httpResponse->headers['Lock-Token'])); + $lockToken = $server->httpResponse->headers['Lock-Token']; + + //sleep(10); + + $response2 = new Sabre_HTTP_ResponseMock(); + + $server->httpRequest = $this->getLockRequest2(); + $server->httpResponse = $response2; + $server->exec(); + + $this->assertEquals('HTTP/1.1 201 Created', $server->httpResponse->status); + $this->assertTrue(isset($server->httpResponse->headers['Lock-Token'])); + + //sleep(10); + + $response3 = new Sabre_HTTP_ResponseMock(); + $server->httpRequest = $this->getPutRequest($lockToken); + $server->httpResponse = $response3; + $server->exec(); + + $this->assertEquals('HTTP/1.1 204 No Content', $server->httpResponse->status); + + } + + function tearDown() { + + Sabre_TestUtil::clearTempDir(); + + } + + function getLockRequest() { + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'LOCK', + 'HTTP_CONTENT_TYPE' => 'application/xml', + 'HTTP_TIMEOUT' => 'Second-3600', + 'REQUEST_URI' => '/Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', + )); + + $request->setBody(' + + + + + + + + PC-Vista\User + +'); + + return $request; + + } + function getLockRequest2() { + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'LOCK', + 'HTTP_CONTENT_TYPE' => 'application/xml', + 'HTTP_TIMEOUT' => 'Second-3600', + 'REQUEST_URI' => '/~$Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', + )); + + $request->setBody(' + + + + + + + + PC-Vista\User + +'); + + return $request; + + } + + function getPutRequest($lockToken) { + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'PUT', + 'REQUEST_URI' => '/Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', + 'HTTP_IF' => 'If: ('.$lockToken.')', + )); + $request->setBody('FAKE BODY'); + return $request; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/PluginTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/PluginTest.php new file mode 100755 index 0000000..adea10e --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Locks/PluginTest.php @@ -0,0 +1,958 @@ +server->addPlugin($locksPlugin); + $this->locksPlugin = $locksPlugin; + + } + + function testGetFeatures() { + + $this->assertEquals(array(2),$this->locksPlugin->getFeatures()); + + } + + function testGetHTTPMethods() { + + $this->assertEquals(array('LOCK','UNLOCK'),$this->locksPlugin->getHTTPMethods('')); + + } + + function testGetHTTPMethodsNoBackend() { + + $locksPlugin = new Sabre_DAV_Locks_Plugin(); + $this->server->addPlugin($locksPlugin); + $this->assertEquals(array(),$locksPlugin->getHTTPMethods('')); + + } + + function testUnknownMethodPassthough() { + + $this->assertNull($this->locksPlugin->unknownMethod('BLA','/')); + + } + + function testLockNoBody() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'LOCK', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(''); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 400 Bad request',$this->response->status); + + } + + function testLock() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'LOCK', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + + http://example.org/~ejw/contact.html + +'); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + $this->assertTrue(preg_match('/^$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')'); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status,'Got an incorrect status back. Response body: ' . $this->response->body); + + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/","xmlns\\1=\"urn:DAV\"",$this->response->body); + $xml = simplexml_load_string($body); + $xml->registerXPathNamespace('d','urn:DAV'); + + $elements = array( + '/d:prop', + '/d:prop/d:lockdiscovery', + '/d:prop/d:lockdiscovery/d:activelock', + '/d:prop/d:lockdiscovery/d:activelock/d:locktype', + '/d:prop/d:lockdiscovery/d:activelock/d:lockroot', + '/d:prop/d:lockdiscovery/d:activelock/d:lockroot/d:href', + '/d:prop/d:lockdiscovery/d:activelock/d:locktype/d:write', + '/d:prop/d:lockdiscovery/d:activelock/d:lockscope', + '/d:prop/d:lockdiscovery/d:activelock/d:lockscope/d:exclusive', + '/d:prop/d:lockdiscovery/d:activelock/d:depth', + '/d:prop/d:lockdiscovery/d:activelock/d:owner', + '/d:prop/d:lockdiscovery/d:activelock/d:timeout', + '/d:prop/d:lockdiscovery/d:activelock/d:locktoken', + '/d:prop/d:lockdiscovery/d:activelock/d:locktoken/d:href', + ); + + foreach($elements as $elem) { + $data = $xml->xpath($elem); + $this->assertEquals(1,count($data),'We expected 1 match for the xpath expression "' . $elem . '". ' . count($data) . ' were found. Full response body: ' . $this->response->body); + } + + $depth = $xml->xpath('/d:prop/d:lockdiscovery/d:activelock/d:depth'); + $this->assertEquals('infinity',(string)$depth[0]); + + $token = $xml->xpath('/d:prop/d:lockdiscovery/d:activelock/d:locktoken/d:href'); + $this->assertEquals($this->response->headers['Lock-Token'],'<' . (string)$token[0] . '>','Token in response body didn\'t match token in response header.'); + + } + + /** + * @depends testLock + */ + function testDoubleLock() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'LOCK', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + + http://example.org/~ejw/contact.html + +'); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->response = new Sabre_HTTP_ResponseMock(); + $this->server->httpResponse = $this->response; + + $this->server->exec(); + + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + + $this->assertEquals('HTTP/1.1 423 Locked',$this->response->status); + + } + + /** + * @depends testLock + */ + function testLockRefresh() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'LOCK', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + + http://example.org/~ejw/contact.html + +'); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $lockToken = $this->response->headers['Lock-Token']; + + $this->response = new Sabre_HTTP_ResponseMock(); + $this->server->httpResponse = $this->response; + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'LOCK', + 'HTTP_IF' => '(' . $lockToken . ')', + ); + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(''); + $this->server->httpRequest = $request; + + $this->server->exec(); + + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status,'We received an incorrect status code. Full response body: ' . $this->response->body); + + } + + /** + * @depends testLock + */ + function testLockNoFile() { + + $serverVars = array( + 'REQUEST_URI' => '/notfound.txt', + 'REQUEST_METHOD' => 'LOCK', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + + http://example.org/~ejw/contact.html + +'); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + $this->assertTrue(preg_match('/^$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')'); + + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status); + + } + + /** + * @depends testLock + */ + function testUnlockNoToken() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'UNLOCK', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 400 Bad request',$this->response->status); + + } + + /** + * @depends testLock + */ + function testUnlockBadToken() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'UNLOCK', + 'HTTP_LOCK_TOKEN' => '', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 409 Conflict',$this->response->status,'Got an incorrect status code. Full response body: ' . $this->response->body); + + } + + /** + * @depends testLock + */ + function testLockPutNoToken() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'LOCK', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + + http://example.org/~ejw/contact.html + +'); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + $this->assertTrue(preg_match('/^$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')'); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'PUT', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody('newbody'); + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + $this->assertTrue(preg_match('/^$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')'); + + $this->assertEquals('HTTP/1.1 423 Locked',$this->response->status); + + } + + /** + * @depends testLock + */ + function testUnlock() { + + $request = new Sabre_HTTP_Request(array()); + $this->server->httpRequest = $request; + + $request->setBody(' + + + + + http://example.org/~ejw/contact.html + +'); + + $this->server->invokeMethod('LOCK','test.txt'); + $lockToken = $this->server->httpResponse->headers['Lock-Token']; + + $serverVars = array( + 'HTTP_LOCK_TOKEN' => $lockToken, + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->httpResponse = new Sabre_HTTP_ResponseMock(); + $this->server->invokeMethod('UNLOCK', 'test.txt'); + + $this->assertEquals('HTTP/1.1 204 No Content',$this->server->httpResponse->status,'Got an incorrect status code. Full response body: ' . $this->response->body); + $this->assertEquals(array( + 'Content-Length' => '0', + ), + $this->server->httpResponse->headers + ); + + + } + + /** + * @depends testLock + */ + function testUnlockWindowsBug() { + + $request = new Sabre_HTTP_Request(array()); + $this->server->httpRequest = $request; + + $request->setBody(' + + + + + http://example.org/~ejw/contact.html + +'); + + $this->server->invokeMethod('LOCK','test.txt'); + $lockToken = $this->server->httpResponse->headers['Lock-Token']; + + // See Issue 123 + $lockToken = trim($lockToken,'<>'); + + $serverVars = array( + 'HTTP_LOCK_TOKEN' => $lockToken, + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->httpResponse = new Sabre_HTTP_ResponseMock(); + $this->server->invokeMethod('UNLOCK', 'test.txt'); + + $this->assertEquals('HTTP/1.1 204 No Content',$this->server->httpResponse->status,'Got an incorrect status code. Full response body: ' . $this->response->body); + $this->assertEquals(array( + 'Content-Length' => '0', + ), + $this->server->httpResponse->headers + ); + + + } + + /** + * @depends testLock + */ + function testLockRetainOwner() { + + $request = new Sabre_HTTP_Request(array()); + $this->server->httpRequest = $request; + + $request->setBody(' + + + + Evert +'); + + $this->server->invokeMethod('LOCK','test.txt'); + $lockToken = $this->server->httpResponse->headers['Lock-Token']; + + $locks = $this->locksPlugin->getLocks('test.txt'); + $this->assertEquals(1,count($locks)); + $this->assertEquals('Evert',$locks[0]->owner); + + + } + + /** + * @depends testLock + */ + function testLockPutBadToken() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'LOCK', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + + http://example.org/~ejw/contact.html + +'); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + $this->assertTrue(preg_match('/^$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')'); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'PUT', + 'HTTP_IF' => '()', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody('newbody'); + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + $this->assertTrue(preg_match('/^$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')'); + + $this->assertEquals('HTTP/1.1 412 Precondition failed',$this->response->status); + + } + + /** + * @depends testLock + */ + function testLockDeleteParent() { + + $serverVars = array( + 'REQUEST_URI' => '/dir/child.txt', + 'REQUEST_METHOD' => 'LOCK', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + + http://example.org/~ejw/contact.html + +'); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + $this->assertTrue(preg_match('/^$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')'); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + + $serverVars = array( + 'REQUEST_URI' => '/dir', + 'REQUEST_METHOD' => 'DELETE', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 423 Locked',$this->response->status); + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + + } + /** + * @depends testLock + */ + function testLockDeleteSucceed() { + + $serverVars = array( + 'REQUEST_URI' => '/dir/child.txt', + 'REQUEST_METHOD' => 'LOCK', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + + http://example.org/~ejw/contact.html + +'); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + $this->assertTrue(preg_match('/^$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')'); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + + $serverVars = array( + 'REQUEST_URI' => '/dir/child.txt', + 'REQUEST_METHOD' => 'DELETE', + 'HTTP_IF' => '(' . $this->response->headers['Lock-Token'] . ')', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status); + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + + } + + /** + * @depends testLock + */ + function testLockCopyLockSource() { + + $serverVars = array( + 'REQUEST_URI' => '/dir/child.txt', + 'REQUEST_METHOD' => 'LOCK', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + + http://example.org/~ejw/contact.html + +'); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + $this->assertTrue(preg_match('/^$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')'); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + + $serverVars = array( + 'REQUEST_URI' => '/dir/child.txt', + 'REQUEST_METHOD' => 'COPY', + 'HTTP_DESTINATION' => '/dir/child2.txt', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status,'Copy must succeed if only the source is locked, but not the destination'); + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + + } + /** + * @depends testLock + */ + function testLockCopyLockDestination() { + + $serverVars = array( + 'REQUEST_URI' => '/dir/child2.txt', + 'REQUEST_METHOD' => 'LOCK', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + + http://example.org/~ejw/contact.html + +'); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + $this->assertTrue(preg_match('/^$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')'); + + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status); + + $serverVars = array( + 'REQUEST_URI' => '/dir/child.txt', + 'REQUEST_METHOD' => 'COPY', + 'HTTP_DESTINATION' => '/dir/child2.txt', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 423 Locked',$this->response->status,'Copy must succeed if only the source is locked, but not the destination'); + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + + } + + /** + * @depends testLock + */ + function testLockMoveLockSourceLocked() { + + $serverVars = array( + 'REQUEST_URI' => '/dir/child.txt', + 'REQUEST_METHOD' => 'LOCK', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + + http://example.org/~ejw/contact.html + +'); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + $this->assertTrue(preg_match('/^$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')'); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + + $serverVars = array( + 'REQUEST_URI' => '/dir/child.txt', + 'REQUEST_METHOD' => 'MOVE', + 'HTTP_DESTINATION' => '/dir/child2.txt', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 423 Locked',$this->response->status,'Copy must succeed if only the source is locked, but not the destination'); + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + + } + + /** + * @depends testLock + */ + function testLockMoveLockSourceSucceed() { + + $serverVars = array( + 'REQUEST_URI' => '/dir/child.txt', + 'REQUEST_METHOD' => 'LOCK', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + + http://example.org/~ejw/contact.html + +'); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + $this->assertTrue(preg_match('/^$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')'); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + + $serverVars = array( + 'REQUEST_URI' => '/dir/child.txt', + 'REQUEST_METHOD' => 'MOVE', + 'HTTP_DESTINATION' => '/dir/child2.txt', + 'HTTP_IF' => '(' . $this->response->headers['Lock-Token'] . ')', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status,'A valid lock-token was provided for the source, so this MOVE operation must succeed. Full response body: ' . $this->response->body); + + } + + /** + * @depends testLock + */ + function testLockMoveLockDestination() { + + $serverVars = array( + 'REQUEST_URI' => '/dir/child2.txt', + 'REQUEST_METHOD' => 'LOCK', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + + http://example.org/~ejw/contact.html + +'); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + $this->assertTrue(preg_match('/^$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')'); + + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status); + + $serverVars = array( + 'REQUEST_URI' => '/dir/child.txt', + 'REQUEST_METHOD' => 'MOVE', + 'HTTP_DESTINATION' => '/dir/child2.txt', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 423 Locked',$this->response->status,'Copy must succeed if only the source is locked, but not the destination'); + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + + } + /** + * @depends testLock + */ + function testLockMoveLockParent() { + + $serverVars = array( + 'REQUEST_URI' => '/dir', + 'REQUEST_METHOD' => 'LOCK', + 'HTTP_DEPTH' => 'infinite', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + + http://example.org/~ejw/contact.html + +'); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + $this->assertTrue(preg_match('/^$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')'); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + + $serverVars = array( + 'REQUEST_URI' => '/dir/child.txt', + 'REQUEST_METHOD' => 'MOVE', + 'HTTP_DESTINATION' => '/dir/child2.txt', + 'HTTP_IF' => ' (' . $this->response->headers['Lock-Token'] . ')', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status,'We locked the parent of both the source and destination, but the move didn\'t succeed.'); + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + + } + + /** + * @depends testLock + */ + function testLockPutGoodToken() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'LOCK', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + + http://example.org/~ejw/contact.html + +'); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + $this->assertTrue(preg_match('/^$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')'); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'PUT', + 'HTTP_IF' => '('.$this->response->headers['Lock-Token'].')', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody('newbody'); + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + $this->assertTrue(preg_match('/^$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')'); + + $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status); + + } + + function testPutWithIncorrectETag() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'PUT', + 'HTTP_IF' => '(["etag1"])', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody('newbody'); + $this->server->httpRequest = $request; + $this->server->exec(); + $this->assertEquals('HTTP/1.1 412 Precondition failed',$this->response->status); + + } + + /** + * @depends testPutWithIncorrectETag + */ + function testPutWithCorrectETag() { + + // We need an etag-enabled file node. + $tree = new Sabre_DAV_ObjectTree(new Sabre_DAV_FSExt_Directory(SABRE_TEMPDIR)); + $this->server->tree = $tree; + + $etag = md5(file_get_contents(SABRE_TEMPDIR . '/test.txt')); + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'PUT', + 'HTTP_IF' => '(["'.$etag.'"])', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody('newbody'); + $this->server->httpRequest = $request; + $this->server->exec(); + $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status); + + } + + function testGetTimeoutHeader() { + + $request = new Sabre_HTTP_Request(array( + 'HTTP_TIMEOUT' => 'second-100', + )); + + $this->server->httpRequest = $request; + $this->assertEquals(100, $this->locksPlugin->getTimeoutHeader()); + + } + + + function testGetTimeoutHeaderNotSet() { + + $request = new Sabre_HTTP_Request(array( + )); + + $this->server->httpRequest = $request; + $this->assertEquals(0, $this->locksPlugin->getTimeoutHeader()); + + } + + + function testGetTimeoutHeaderInfinite() { + + $request = new Sabre_HTTP_Request(array( + 'HTTP_TIMEOUT' => 'infinite', + )); + + $this->server->httpRequest = $request; + $this->assertEquals(Sabre_DAV_Locks_LockInfo::TIMEOUT_INFINITE, $this->locksPlugin->getTimeoutHeader()); + + } + + /** + * @expectedException Sabre_DAV_Exception_BadRequest + */ + function testGetTimeoutHeaderInvalid() { + + $request = new Sabre_HTTP_Request(array( + 'HTTP_TIMEOUT' => 'yourmom', + )); + + $this->server->httpRequest = $request; + $this->locksPlugin->getTimeoutHeader(); + + } + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Mount/PluginTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Mount/PluginTest.php new file mode 100755 index 0000000..21f3108 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Mount/PluginTest.php @@ -0,0 +1,53 @@ +server->addPlugin(new Sabre_DAV_Mount_Plugin()); + + } + + function testPassThrough() { + + $serverVars = array( + 'REQUEST_URI' => '/', + 'REQUEST_METHOD' => 'GET', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 501 Not Implemented',$this->response->status,'We expected GET to not be implemented for Directories. Response body: ' . $this->response->body); + + } + + function testMountResponse() { + + $serverVars = array( + 'REQUEST_URI' => '/?mount', + 'REQUEST_METHOD' => 'GET', + 'QUERY_STRING' => 'mount', + 'HTTP_HOST' => 'example.org', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + + $xml = simplexml_load_string($this->response->body); + $this->assertTrue($xml==true,'Response was not a valid xml document'); + + $xml->registerXPathNamespace('dm','http://purl.org/NET/webdav/mount'); + $url = $xml->xpath('//dm:url'); + $this->assertEquals('http://example.org/',(string)$url[0]); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ObjectTreeTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ObjectTreeTest.php new file mode 100755 index 0000000..9059cef --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ObjectTreeTest.php @@ -0,0 +1,98 @@ +tree = new Sabre_DAV_ObjectTree($rootNode); + + } + + function teardown() { + + Sabre_TestUtil::clearTempDir(); + + } + + function testGetRootNode() { + + $root = $this->tree->getNodeForPath(''); + $this->assertInstanceOf('Sabre_DAV_FSExt_Directory',$root); + + } + + function testGetSubDir() { + + $root = $this->tree->getNodeForPath('subdir'); + $this->assertInstanceOf('Sabre_DAV_FSExt_Directory',$root); + + } + + function testCopyFile() { + + $this->tree->copy('file.txt','file2.txt'); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/file2.txt')); + $this->assertEquals('contents',file_get_contents(SABRE_TEMPDIR.'/root/file2.txt')); + + } + + /** + * @depends testCopyFile + */ + function testCopyDirectory() { + + $this->tree->copy('subdir','subdir2'); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2')); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); + $this->assertEquals('subcontents',file_get_contents(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); + + } + + /** + * @depends testCopyFile + */ + function testMoveFile() { + + $this->tree->move('file.txt','file2.txt'); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/file2.txt')); + $this->assertFalse(file_exists(SABRE_TEMPDIR.'/root/file.txt')); + $this->assertEquals('contents',file_get_contents(SABRE_TEMPDIR.'/root/file2.txt')); + + } + + /** + * @depends testMoveFile + */ + function testMoveFileNewParent() { + + $this->tree->move('file.txt','subdir/file2.txt'); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir/file2.txt')); + $this->assertFalse(file_exists(SABRE_TEMPDIR.'/root/file.txt')); + $this->assertEquals('contents',file_get_contents(SABRE_TEMPDIR.'/root/subdir/file2.txt')); + + } + + /** + * @depends testCopyDirectory + */ + function testMoveDirectory() { + + $this->tree->move('subdir','subdir2'); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2')); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); + $this->assertFalse(file_exists(SABRE_TEMPDIR.'/root/subdir')); + $this->assertEquals('subcontents',file_get_contents(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/GetLastModifiedTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/GetLastModifiedTest.php new file mode 100755 index 0000000..90de13a --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/GetLastModifiedTest.php @@ -0,0 +1,63 @@ +assertEquals($dt->format(DateTime::ATOM), $lastMod->getTime()->format(DateTime::ATOM)); + + } + + function testConstructString() { + + $dt = new DateTime('2010-03-14 16:35', new DateTimeZone('UTC')); + $lastMod = new Sabre_DAV_Property_GetLastModified('2010-03-14 16:35'); + $this->assertEquals($dt->format(DateTime::ATOM), $lastMod->getTime()->format(DateTime::ATOM)); + + } + + function testConstructInt() { + + $dt = new DateTime('2010-03-14 16:35', new DateTimeZone('UTC')); + $lastMod = new Sabre_DAV_Property_GetLastModified((int)$dt->format('U')); + $this->assertEquals($dt->format(DateTime::ATOM), $lastMod->getTime()->format(DateTime::ATOM)); + + } + + function testSerialize() { + + $dt = new DateTime('2010-03-14 16:35', new DateTimeZone('UTC')); + $lastMod = new Sabre_DAV_Property_GetLastModified($dt); + + $doc = new DOMDocument(); + $root = $doc->createElement('d:getlastmodified'); + $root->setAttribute('xmlns:d','DAV:'); + + $doc->appendChild($root); + $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('rootdir')); + $server = new Sabre_DAV_Server($objectTree); + + $lastMod->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' +' . +$dt->format(DateTime::RFC1123) . +' +', $xml); + + $ok = false; + try { + Sabre_DAV_Property_GetLastModified::unserialize(Sabre_DAV_XMLUtil::loadDOMDocument($xml)->firstChild); + } catch (Sabre_DAV_Exception $e) { + $ok = true; + } + if (!$ok) $this->markTestFailed('Unserialize should not be supported'); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/HrefListTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/HrefListTest.php new file mode 100755 index 0000000..d740436 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/HrefListTest.php @@ -0,0 +1,88 @@ +assertEquals(array('foo','bar'),$href->getHrefs()); + + } + + function testSerialize() { + + $href = new Sabre_DAV_Property_HrefList(array('foo','bar')); + $this->assertEquals(array('foo','bar'),$href->getHrefs()); + + $doc = new DOMDocument(); + $root = $doc->createElement('d:anything'); + $root->setAttribute('xmlns:d','DAV:'); + + $doc->appendChild($root); + $server = new Sabre_DAV_Server(); + $server->setBaseUri('/bla/'); + + $href->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' +/bla/foo/bla/bar +', $xml); + + } + + function testSerializeNoPrefix() { + + $href = new Sabre_DAV_Property_HrefList(array('foo','bar'), false); + $this->assertEquals(array('foo','bar'),$href->getHrefs()); + + $doc = new DOMDocument(); + $root = $doc->createElement('d:anything'); + $root->setAttribute('xmlns:d','DAV:'); + + $doc->appendChild($root); + $server = new Sabre_DAV_Server(); + $server->setBaseUri('/bla/'); + + $href->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' +foobar +', $xml); + + } + + function testUnserialize() { + + $xml = ' +/bla/foo/bla/bar +'; + + $dom = new DOMDocument(); + $dom->loadXML($xml); + + $href = Sabre_DAV_Property_HrefList::unserialize($dom->firstChild); + $this->assertEquals(array('/bla/foo','/bla/bar'),$href->getHrefs()); + + } + + function testUnserializeIncompatible() { + + $xml = ' +/bla/foo +'; + + $dom = new DOMDocument(); + $dom->loadXML($xml); + + $href = Sabre_DAV_Property_HrefList::unserialize($dom->firstChild); + $this->assertEquals(array(), $href->getHrefs()); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/HrefTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/HrefTest.php new file mode 100755 index 0000000..99b8df4 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/HrefTest.php @@ -0,0 +1,88 @@ +assertEquals('path',$href->getHref()); + + } + + function testSerialize() { + + $href = new Sabre_DAV_Property_Href('path'); + $this->assertEquals('path',$href->getHref()); + + $doc = new DOMDocument(); + $root = $doc->createElement('d:anything'); + $root->setAttribute('xmlns:d','DAV:'); + + $doc->appendChild($root); + $server = new Sabre_DAV_Server(); + $server->setBaseUri('/bla/'); + + $href->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' +/bla/path +', $xml); + + } + + function testSerializeNoPrefix() { + + $href = new Sabre_DAV_Property_Href('path',false); + $this->assertEquals('path',$href->getHref()); + + $doc = new DOMDocument(); + $root = $doc->createElement('d:anything'); + $root->setAttribute('xmlns:d','DAV:'); + + $doc->appendChild($root); + $server = new Sabre_DAV_Server(); + $server->setBaseUri('/bla/'); + + $href->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' +path +', $xml); + + } + + function testUnserialize() { + + $xml = ' +/bla/path +'; + + $dom = new DOMDocument(); + $dom->loadXML($xml); + + $href = Sabre_DAV_Property_Href::unserialize($dom->firstChild); + $this->assertEquals('/bla/path',$href->getHref()); + + } + + function testUnserializeIncompatible() { + + $xml = ' +/bla/path +'; + + $dom = new DOMDocument(); + $dom->loadXML($xml); + + $href = Sabre_DAV_Property_Href::unserialize($dom->firstChild); + $this->assertNull($href); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/ResourceTypeTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/ResourceTypeTest.php new file mode 100755 index 0000000..93ced30 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/ResourceTypeTest.php @@ -0,0 +1,107 @@ +assertEquals(array('{DAV:}collection'),$resourceType->getValue()); + + $resourceType = new Sabre_DAV_Property_ResourceType(Sabre_DAV_Server::NODE_FILE); + $this->assertEquals(array(),$resourceType->getValue()); + + $resourceType = new Sabre_DAV_Property_ResourceType(Sabre_DAV_Server::NODE_DIRECTORY); + $this->assertEquals(array('{DAV:}collection'),$resourceType->getValue()); + + $resourceType = new Sabre_DAV_Property_ResourceType('{DAV:}principal'); + $this->assertEquals(array('{DAV:}principal'),$resourceType->getValue()); + + } + + /** + * @depends testConstruct + */ + function testSerialize() { + + $resourceType = new Sabre_DAV_Property_ResourceType(array('{DAV:}collection','{DAV:}principal')); + + $doc = new DOMDocument(); + $root = $doc->createElement('d:anything'); + $root->setAttribute('xmlns:d','DAV:'); + + $doc->appendChild($root); + $server = new Sabre_DAV_Server(); + $resourceType->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' + +', $xml); + + } + + /** + * @depends testSerialize + */ + function testSerializeCustomNS() { + + $resourceType = new Sabre_DAV_Property_ResourceType(array('{http://example.org/NS}article')); + + $doc = new DOMDocument(); + $root = $doc->createElement('d:anything'); + $root->setAttribute('xmlns:d','DAV:'); + + $doc->appendChild($root); + $server = new Sabre_DAV_Server(); + $resourceType->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' + +', $xml); + + } + + /** + * @depends testConstruct + */ + function testIs() { + + $resourceType = new Sabre_DAV_Property_ResourceType(array('{DAV:}collection','{DAV:}principal')); + $this->assertTrue($resourceType->is('{DAV:}collection')); + $this->assertFalse($resourceType->is('{DAV:}blabla')); + + } + + /** + * @depends testConstruct + */ + function testAdd() { + + $resourceType = new Sabre_DAV_Property_ResourceType(array('{DAV:}collection','{DAV:}principal')); + $resourceType->add('{DAV:}foo'); + $this->assertEquals(array('{DAV:}collection','{DAV:}principal','{DAV:}foo'), $resourceType->getValue()); + + } + + /** + * @depends testConstruct + */ + function testUnserialize() { + + $xml =' + +'; + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml); + + $resourceType = Sabre_DAV_Property_ResourceType::unserialize($dom->firstChild); + $this->assertEquals(array('{DAV:}collection','{DAV:}principal'),$resourceType->getValue()); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/ResponseTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/ResponseTest.php new file mode 100755 index 0000000..58ac16c --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/ResponseTest.php @@ -0,0 +1,231 @@ + array( + '{DAV:}displayname' => 'my file', + ), + 404 => array( + '{DAV:}owner' => null, + ) + ); + + $property = new Sabre_DAV_Property_Response('uri',$innerProps); + + $this->assertEquals('uri',$property->getHref()); + $this->assertEquals($innerProps,$property->getResponseProperties()); + + + } + + /** + * @depends testSimple + */ + function testSerialize() { + + $innerProps = array( + 200 => array( + '{DAV:}displayname' => 'my file', + ), + 404 => array( + '{DAV:}owner' => null, + ) + ); + + $property = new Sabre_DAV_Property_Response('uri',$innerProps); + + $doc = new DOMDocument(); + $root = $doc->createElement('d:root'); + $root->setAttribute('xmlns:d','DAV:'); + + $doc->appendChild($root); + $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('rootdir')); + $server = new Sabre_DAV_Server($objectTree); + + $property->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' +' . +'' . +'/uri' . +'' . +'' . +'my file' . +'' . +'HTTP/1.1 200 OK' . +'' . +'' . +'' . +'' . +'' . +'HTTP/1.1 404 Not Found' . +'' . +'' . +' +', $xml); + + } + + /** + * This one is specifically for testing properties with no namespaces, which is legal xml + * + * @depends testSerialize + */ + function testSerializeEmptyNamespace() { + + $innerProps = array( + 200 => array( + '{}propertyname' => 'value', + ), + ); + + $property = new Sabre_DAV_Property_Response('uri',$innerProps); + + $doc = new DOMDocument(); + $root = $doc->createElement('d:root'); + $root->setAttribute('xmlns:d','DAV:'); + + $doc->appendChild($root); + $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('rootdir')); + $server = new Sabre_DAV_Server($objectTree); + + $property->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' +' . +'' . +'/uri' . +'' . +'' . +'value' . +'' . +'HTTP/1.1 200 OK' . +'' . +'' . +' +', $xml); + + } + + /** + * This one is specifically for testing properties with no namespaces, which is legal xml + * + * @depends testSerialize + */ + function testSerializeCustomNamespace() { + + $innerProps = array( + 200 => array( + '{http://sabredav.org/NS/example}propertyname' => 'value', + ), + ); + + $property = new Sabre_DAV_Property_Response('uri',$innerProps); + + $doc = new DOMDocument(); + $root = $doc->createElement('d:root'); + $root->setAttribute('xmlns:d','DAV:'); + + $doc->appendChild($root); + $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('rootdir')); + $server = new Sabre_DAV_Server($objectTree); + + $property->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' +' . +'' . +'/uri' . +'' . +'' . +'value' . +'' . +'HTTP/1.1 200 OK' . +'' . +'' . +' +', $xml); + + } + + /** + * @depends testSerialize + */ + function testSerializeComplexProperty() { + + $innerProps = array( + 200 => array( + '{DAV:}link' => new Sabre_DAV_Property_Href('http://sabredav.org/', false) + ), + ); + + $property = new Sabre_DAV_Property_Response('uri',$innerProps); + + $doc = new DOMDocument(); + $root = $doc->createElement('d:root'); + $root->setAttribute('xmlns:d','DAV:'); + + $doc->appendChild($root); + $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('rootdir')); + $server = new Sabre_DAV_Server($objectTree); + + $property->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' +' . +'' . +'/uri' . +'' . +'' . +'http://sabredav.org/' . +'' . +'HTTP/1.1 200 OK' . +'' . +'' . +' +', $xml); + + } + + /** + * @depends testSerialize + * @expectedException Sabre_DAV_Exception + */ + function testSerializeBreak() { + + $innerProps = array( + 200 => array( + '{DAV:}link' => new STDClass() + ), + ); + + $property = new Sabre_DAV_Property_Response('uri',$innerProps); + + $doc = new DOMDocument(); + $root = $doc->createElement('d:root'); + $root->setAttribute('xmlns:d','DAV:'); + + $doc->appendChild($root); + $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('rootdir')); + $server = new Sabre_DAV_Server($objectTree); + + $property->serialize($server, $root); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/SupportedReportSetTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/SupportedReportSetTest.php new file mode 100755 index 0000000..ba2ac4d --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Property/SupportedReportSetTest.php @@ -0,0 +1,123 @@ + '/', + 'REQUEST_METHOD' => 'PROPFIND', + 'HTTP_DEPTH' => '0', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody($body); + + $this->server->httpRequest = ($request); + $this->server->exec(); + + } + + /** + * @covers Sabre_DAV_Property_SupportedReportSet + */ + function testNoReports() { + + $xml = ' + + + + +'; + + $this->sendPROPFIND($xml); + + $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'We expected a multi-status response. Full response body: ' . $this->response->body); + + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/","xmlns\\1=\"urn:DAV\"",$this->response->body); + $xml = simplexml_load_string($body); + $xml->registerXPathNamespace('d','urn:DAV'); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop'); + $this->assertEquals(1,count($data),'We expected 1 \'d:prop\' element'); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supported-report-set'); + $this->assertEquals(1,count($data),'We expected 1 \'d:supported-report-set\' element'); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:status'); + $this->assertEquals(1,count($data),'We expected 1 \'d:status\' element'); + + $this->assertEquals('HTTP/1.1 200 OK',(string)$data[0],'The status for this property should have been 200'); + + } + + /** + * @covers Sabre_DAV_Property_SupportedReportSet + * @depends testNoReports + */ + function testCustomReport() { + + // Intercepting the report property + $this->server->subscribeEvent('afterGetProperties',array($this,'addProp')); + + $xml = ' + + + + +'; + + $this->sendPROPFIND($xml); + + $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'We expected a multi-status response. Full response body: ' . $this->response->body); + + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/","xmlns\\1=\"urn:DAV\"",$this->response->body); + $xml = simplexml_load_string($body); + $xml->registerXPathNamespace('d','urn:DAV'); + $xml->registerXPathNamespace('x','http://www.rooftopsolutions.nl/testnamespace'); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop'); + $this->assertEquals(1,count($data),'We expected 1 \'d:prop\' element'); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supported-report-set'); + $this->assertEquals(1,count($data),'We expected 1 \'d:supported-report-set\' element'); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supported-report-set/d:supported-report'); + $this->assertEquals(2,count($data),'We expected 2 \'d:supported-report\' elements'); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supported-report-set/d:supported-report/d:report'); + $this->assertEquals(2,count($data),'We expected 2 \'d:report\' elements'); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supported-report-set/d:supported-report/d:report/x:myreport'); + $this->assertEquals(1,count($data),'We expected 1 \'x:myreport\' element. Full body: ' . $this->response->body); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supported-report-set/d:supported-report/d:report/d:anotherreport'); + $this->assertEquals(1,count($data),'We expected 1 \'d:anotherreport\' element. Full body: ' . $this->response->body); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:status'); + $this->assertEquals(1,count($data),'We expected 1 \'d:status\' element'); + + $this->assertEquals('HTTP/1.1 200 OK',(string)$data[0],'The status for this property should have been 200'); + + } + + /** + * This method is used as a callback for afterGetProperties + */ + function addProp($path,&$properties) { + + if (isset($properties[200]['{DAV:}supported-report-set'])) { + $properties[200]['{DAV:}supported-report-set']->addReport('{http://www.rooftopsolutions.nl/testnamespace}myreport'); + $properties[200]['{DAV:}supported-report-set']->addReport('{DAV:}anotherreport'); + } + + } + + + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerCopyMoveTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerCopyMoveTest.php new file mode 100755 index 0000000..ea2e069 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerCopyMoveTest.php @@ -0,0 +1,264 @@ +response = new Sabre_HTTP_ResponseMock(); + $dir = new Sabre_DAV_FS_Directory(SABRE_TEMPDIR); + $tree = new Sabre_DAV_ObjectTree($dir); + $this->server = new Sabre_DAV_Server($tree); + $this->server->debugExceptions = true; + $this->server->httpResponse = $this->response; + file_put_contents(SABRE_TEMPDIR . '/test.txt', 'Test contents'); + file_put_contents(SABRE_TEMPDIR . '/test2.txt', 'Test contents2'); + mkdir(SABRE_TEMPDIR . '/col'); + file_put_contents(SABRE_TEMPDIR . 'col/test.txt', 'Test contents'); + + } + + function tearDown() { + + $cleanUp = array('test.txt','testput.txt','testcol','test2.txt','test3.txt','col/test.txt','col','col2/test.txt','col2'); + foreach($cleanUp as $file) { + $tmpFile = SABRE_TEMPDIR . '/' . $file; + if (file_exists($tmpFile)) { + + if (is_dir($tmpFile)) { + rmdir($tmpFile); + } else { + unlink($tmpFile); + } + + } + } + + } + + + function testCopyOverWrite() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'COPY', + 'HTTP_DESTINATION' => '/test2.txt', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status,'Received an incorrect HTTP status. Full body inspection: ' . $this->response->body); + $this->assertEquals(array( + 'Content-Length' => '0', + ), + $this->response->headers + ); + + $this->assertEquals('Test contents',file_get_contents(SABRE_TEMPDIR. '/test2.txt')); + + } + + function testCopyToSelf() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'COPY', + 'HTTP_DESTINATION' => '/test.txt', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 403 Forbidden',$this->response->status,'Received an incorrect HTTP status. Full body inspection: ' . $this->response->body); + $this->assertEquals('Test contents',file_get_contents(SABRE_TEMPDIR. '/test.txt')); + + } + + function testMoveToSelf() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'MOVE', + 'HTTP_DESTINATION' => '/test.txt', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 403 Forbidden',$this->response->status,'Received an incorrect HTTP status. Full body inspection: ' . $this->response->body); + $this->assertEquals('Test contents',file_get_contents(SABRE_TEMPDIR. '/test.txt')); + + } + + function testMoveOverWrite() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'MOVE', + 'HTTP_DESTINATION' => '/test2.txt', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Length' => 0, + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status); + $this->assertEquals('Test contents',file_get_contents(SABRE_TEMPDIR . '/test2.txt')); + $this->assertFalse(file_exists(SABRE_TEMPDIR . '/test.txt'),'The sourcefile test.txt should no longer exist at this point'); + + } + + function testBlockedOverWrite() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'COPY', + 'HTTP_DESTINATION' => '/test2.txt', + 'HTTP_OVERWRITE' => 'F', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 412 Precondition failed',$this->response->status); + $this->assertEquals('Test contents2',file_get_contents(SABRE_TEMPDIR . '/test2.txt')); + + + } + + function testNonExistantParent() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'COPY', + 'HTTP_DESTINATION' => '/testcol2/test2.txt', + 'HTTP_OVERWRITE' => 'F', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 409 Conflict',$this->response->status); + + } + + function testRandomOverwriteHeader() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'COPY', + 'HTTP_DESTINATION' => '/testcol2/test2.txt', + 'HTTP_OVERWRITE' => 'SURE!', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 400 Bad request',$this->response->status); + + } + + function testCopyDirectory() { + + $serverVars = array( + 'REQUEST_URI' => '/col', + 'REQUEST_METHOD' => 'COPY', + 'HTTP_DESTINATION' => '/col2', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Length' => '0', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status); + $this->assertEquals('Test contents',file_get_contents(SABRE_TEMPDIR . '/col2/test.txt')); + + } + + function testSimpleCopyFile() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'COPY', + 'HTTP_DESTINATION' => '/test3.txt', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Length' => '0', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status); + $this->assertEquals('Test contents',file_get_contents(SABRE_TEMPDIR . '/test3.txt')); + + } + + function testSimpleCopyCollection() { + + $serverVars = array( + 'REQUEST_URI' => '/col', + 'REQUEST_METHOD' => 'COPY', + 'HTTP_DESTINATION' => '/col2', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status,'Incorrect status received. Full response body: ' . $this->response->body); + + $this->assertEquals(array( + 'Content-Length' => '0', + ), + $this->response->headers + ); + + + $this->assertEquals('Test contents',file_get_contents(SABRE_TEMPDIR . '/col2/test.txt')); + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerEventsTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerEventsTest.php new file mode 100755 index 0000000..dd66e9b --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerEventsTest.php @@ -0,0 +1,53 @@ +server->subscribeEvent('afterBind',array($this,'afterBindHandler')); + $newPath = 'afterBind'; + + $this->tempPath = ''; + $this->server->createFile($newPath,'body'); + $this->assertEquals($newPath, $this->tempPath); + + } + + function afterBindHandler($path) { + + $this->tempPath = $path; + + } + + function testBeforeBindCancel() { + + $this->server->subscribeEvent('beforeBind', array($this,'beforeBindCancelHandler')); + $this->assertFalse($this->server->createFile('bla','body')); + + // Also testing put() + $req = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'PUT', + 'REQUEST_URI' => '/foobar', + )); + + $this->server->httpRequest = $req; + $this->server->exec(); + + $this->assertEquals('',$this->server->httpResponse->status); + + } + + function beforeBindCancelHandler() { + + return false; + + } + + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerFinderBlockTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerFinderBlockTest.php new file mode 100755 index 0000000..6e63d2a --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerFinderBlockTest.php @@ -0,0 +1,54 @@ + '/testput.txt', + 'REQUEST_METHOD' => 'PUT', + 'HTTP_X_EXPECTED_ENTITY_LENGTH' => '20', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody('Testing finder'); + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('', $this->response->body); + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status); + $this->assertEquals(array( + 'Content-Length' => '0', + ),$this->response->headers); + + $this->assertEquals('Testing finder',file_get_contents(SABRE_TEMPDIR . '/testput.txt')); + + } + + function testPutFail() { + + $serverVars = array( + 'REQUEST_URI' => '/testput.txt', + 'REQUEST_METHOD' => 'PUT', + 'HTTP_X_EXPECTED_ENTITY_LENGTH' => '20', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(''); + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 403 Forbidden',$this->response->status); + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ),$this->response->headers); + + $this->assertFalse(file_exists(SABRE_TEMPDIR . '/testput.txt')); + } +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerMKCOLTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerMKCOLTest.php new file mode 100755 index 0000000..fbf2e1b --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerMKCOLTest.php @@ -0,0 +1,338 @@ + '/testcol', + 'REQUEST_METHOD' => 'MKCOL', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(""); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Length' => '0', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status); + $this->assertEquals('', $this->response->body); + $this->assertTrue(is_dir($this->tempDir . '/testcol')); + + } + + /** + * @depends testMkcol + */ + function testMKCOLUnknownBody() { + + $serverVars = array( + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody("Hello"); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 415 Unsupported Media Type',$this->response->status); + + } + + /** + * @depends testMkcol + */ + function testMKCOLBrokenXML() { + + $serverVars = array( + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', + 'HTTP_CONTENT_TYPE' => 'application/xml', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody("Hello"); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 400 Bad request',$this->response->status); + + } + + /** + * @depends testMkcol + */ + function testMKCOLUnknownXML() { + + $serverVars = array( + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', + 'HTTP_CONTENT_TYPE' => 'application/xml', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(''); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 415 Unsupported Media Type',$this->response->status); + + } + + /** + * @depends testMkcol + */ + function testMKCOLNoResourceType() { + + $serverVars = array( + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', + 'HTTP_CONTENT_TYPE' => 'application/xml', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + Evert + + +'); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 400 Bad request',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body); + + } + + /** + * @depends testMKCOLNoResourceType + */ + function testMKCOLIncorrectResourceType() { + + $serverVars = array( + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', + 'HTTP_CONTENT_TYPE' => 'application/xml', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + + + +'); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 403 Forbidden',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body); + + } + + /** + * @depends testMKCOLIncorrectResourceType + */ + function testMKCOLIncorrectResourceType2() { + + $serverVars = array( + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', + 'HTTP_CONTENT_TYPE' => 'application/xml', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + + + +'); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 403 Forbidden',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body); + + } + + + /** + * @depends testMKCOLIncorrectResourceType2 + */ + function testMKCOLSuccess() { + + $serverVars = array( + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', + 'HTTP_CONTENT_TYPE' => 'application/xml', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + + + +'); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Length' => '0', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body); + + } + + + /** + * @depends testMKCOLIncorrectResourceType2 + */ + function testMKCOLNoParent() { + + $serverVars = array( + 'REQUEST_URI' => '/testnoparent/409me', + 'REQUEST_METHOD' => 'MKCOL', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(''); + + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 409 Conflict',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body); + + } + + /** + * @depends testMKCOLIncorrectResourceType2 + */ + function testMKCOLParentIsNoCollection() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt/409me', + 'REQUEST_METHOD' => 'MKCOL', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(''); + + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 409 Conflict',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body); + + } + + /** + * @depends testMKCOLIncorrectResourceType2 + */ + function testMKCOLAlreadyExists() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'MKCOL', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(''); + + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + 'Allow' => 'OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 405 Method Not Allowed',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body); + + } + + /** + * @depends testMKCOLSuccess + * @depends testMKCOLAlreadyExists + */ + function testMKCOLAndProps() { + + $serverVars = array( + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', + 'HTTP_CONTENT_TYPE' => 'application/xml', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(' + + + + + my new collection + + +'); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ),$this->response->headers); + + + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerPluginTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerPluginTest.php new file mode 100755 index 0000000..f3184cc --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerPluginTest.php @@ -0,0 +1,94 @@ +server->addPlugin($testPlugin); + $this->testPlugin = $testPlugin; + + } + + /** + * @covers Sabre_DAV_ServerPlugin + */ + function testBaseClass() { + + $p = new Sabre_DAV_ServerPluginMock(); + $this->assertEquals(array(),$p->getFeatures()); + $this->assertEquals(array(),$p->getHTTPMethods('')); + + } + + function testOptions() { + + $serverVars = array( + 'REQUEST_URI' => '/', + 'REQUEST_METHOD' => 'OPTIONS', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'DAV' => '1, 3, extended-mkcol, drinking', + 'MS-Author-Via' => 'DAV', + 'Allow' => 'OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT, BEER, WINE', + 'Accept-Ranges' => 'bytes', + 'Content-Length' => '0', + 'X-Sabre-Version' => Sabre_DAV_Version::VERSION, + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + $this->assertEquals('', $this->response->body); + $this->assertEquals('OPTIONS',$this->testPlugin->beforeMethod); + + + } + + function testGetPlugin() { + + $this->assertEquals($this->testPlugin,$this->server->getPlugin(get_class($this->testPlugin))); + + } + + function testUnknownPlugin() { + + $this->assertNull($this->server->getPlugin('SomeRandomClassName')); + + } + + function testGetSupportedReportSet() { + + $this->assertEquals(array(), $this->testPlugin->getSupportedReportSet('/')); + + } + + function testGetPlugins() { + + $this->assertEquals( + array(get_class($this->testPlugin) => $this->testPlugin), + $this->server->getPlugins() + ); + + } + + +} + +class Sabre_DAV_ServerPluginMock extends Sabre_DAV_ServerPlugin { + + function initialize(Sabre_DAV_Server $s) { } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerPreconditionTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerPreconditionTest.php new file mode 100755 index 0000000..2fa9656 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerPreconditionTest.php @@ -0,0 +1,368 @@ + '*', + 'REQUEST_URI' => '/bar' + )); + $server->httpRequest = $httpRequest; + + $server->checkPreconditions(); + + } + + /** + * @covers Sabre_DAV_Server::checkPreconditions + */ + function testIfMatchHasNode() { + + $root = new Sabre_DAV_SimpleDirectory('root',array(new Sabre_DAV_ServerPreconditionsNode())); + $server = new Sabre_DAV_Server($root); + $httpRequest = new Sabre_HTTP_Request(array( + 'HTTP_IF_MATCH' => '*', + 'REQUEST_URI' => '/foo' + )); + $server->httpRequest = $httpRequest; + + $this->assertTrue($server->checkPreconditions()); + + } + + /** + * @covers Sabre_DAV_Server::checkPreconditions + * @expectedException Sabre_DAV_Exception_PreconditionFailed + */ + function testIfMatchWrongEtag() { + + $root = new Sabre_DAV_SimpleDirectory('root',array(new Sabre_DAV_ServerPreconditionsNode())); + $server = new Sabre_DAV_Server($root); + $httpRequest = new Sabre_HTTP_Request(array( + 'HTTP_IF_MATCH' => '1234', + 'REQUEST_URI' => '/foo' + )); + $server->httpRequest = $httpRequest; + + $server->checkPreconditions(); + + } + + /** + * @covers Sabre_DAV_Server::checkPreconditions + */ + function testIfMatchCorrectEtag() { + + $root = new Sabre_DAV_SimpleDirectory('root',array(new Sabre_DAV_ServerPreconditionsNode())); + $server = new Sabre_DAV_Server($root); + $httpRequest = new Sabre_HTTP_Request(array( + 'HTTP_IF_MATCH' => '"abc123"', + 'REQUEST_URI' => '/foo' + )); + $server->httpRequest = $httpRequest; + + $this->assertTrue($server->checkPreconditions()); + + } + + /** + * @covers Sabre_DAV_Server::checkPreconditions + */ + function testIfMatchMultiple() { + + $root = new Sabre_DAV_SimpleDirectory('root',array(new Sabre_DAV_ServerPreconditionsNode())); + $server = new Sabre_DAV_Server($root); + $httpRequest = new Sabre_HTTP_Request(array( + 'HTTP_IF_MATCH' => '"hellothere", "abc123"', + 'REQUEST_URI' => '/foo' + )); + $server->httpRequest = $httpRequest; + + $this->assertTrue($server->checkPreconditions()); + + } + + /** + * @covers Sabre_DAV_Server::checkPreconditions + */ + function testIfNoneMatchNoNode() { + + $root = new Sabre_DAV_SimpleDirectory('root',array(new Sabre_DAV_ServerPreconditionsNode())); + $server = new Sabre_DAV_Server($root); + $httpRequest = new Sabre_HTTP_Request(array( + 'HTTP_IF_NONE_MATCH' => '*', + 'REQUEST_URI' => '/bar' + )); + $server->httpRequest = $httpRequest; + + $this->assertTrue($server->checkPreconditions()); + + } + + /** + * @covers Sabre_DAV_Server::checkPreconditions + * @expectedException Sabre_DAV_Exception_PreconditionFailed + */ + function testIfNoneMatchHasNode() { + + $root = new Sabre_DAV_SimpleDirectory('root',array(new Sabre_DAV_ServerPreconditionsNode())); + $server = new Sabre_DAV_Server($root); + $httpRequest = new Sabre_HTTP_Request(array( + 'HTTP_IF_NONE_MATCH' => '*', + 'REQUEST_URI' => '/foo' + )); + $server->httpRequest = $httpRequest; + + $server->checkPreconditions(); + + } + + /** + * @covers Sabre_DAV_Server::checkPreconditions + */ + function testIfNoneMatchWrongEtag() { + + $root = new Sabre_DAV_SimpleDirectory('root',array(new Sabre_DAV_ServerPreconditionsNode())); + $server = new Sabre_DAV_Server($root); + $httpRequest = new Sabre_HTTP_Request(array( + 'HTTP_IF_NONE_MATCH' => '"1234"', + 'REQUEST_URI' => '/foo' + )); + $server->httpRequest = $httpRequest; + + $this->assertTrue($server->checkPreconditions()); + + } + + /** + * @covers Sabre_DAV_Server::checkPreconditions + */ + function testIfNoneMatchWrongEtagMultiple() { + + $root = new Sabre_DAV_SimpleDirectory('root',array(new Sabre_DAV_ServerPreconditionsNode())); + $server = new Sabre_DAV_Server($root); + $httpRequest = new Sabre_HTTP_Request(array( + 'HTTP_IF_NONE_MATCH' => '"1234", "5678"', + 'REQUEST_URI' => '/foo' + )); + $server->httpRequest = $httpRequest; + + $this->assertTrue($server->checkPreconditions()); + + } + + /** + * @covers Sabre_DAV_Server::checkPreconditions + * @expectedException Sabre_DAV_Exception_PreconditionFailed + */ + public function testIfNoneMatchCorrectEtag() { + + $root = new Sabre_DAV_SimpleDirectory('root',array(new Sabre_DAV_ServerPreconditionsNode())); + $server = new Sabre_DAV_Server($root); + $httpRequest = new Sabre_HTTP_Request(array( + 'HTTP_IF_NONE_MATCH' => '"abc123"', + 'REQUEST_URI' => '/foo' + )); + $server->httpRequest = $httpRequest; + + $server->checkPreconditions(); + + } + + /** + * @covers Sabre_DAV_Server::checkPreconditions + * @expectedException Sabre_DAV_Exception_PreconditionFailed + */ + public function testIfNoneMatchCorrectEtagMultiple() { + + $root = new Sabre_DAV_SimpleDirectory('root',array(new Sabre_DAV_ServerPreconditionsNode())); + $server = new Sabre_DAV_Server($root); + $httpRequest = new Sabre_HTTP_Request(array( + 'HTTP_IF_NONE_MATCH' => '"1234", "abc123"', + 'REQUEST_URI' => '/foo' + )); + $server->httpRequest = $httpRequest; + + $server->checkPreconditions(); + + } + + /** + * @covers Sabre_DAV_Server::checkPreconditions + */ + public function testIfNoneMatchCorrectEtagAsGet() { + + $root = new Sabre_DAV_SimpleDirectory('root',array(new Sabre_DAV_ServerPreconditionsNode())); + $server = new Sabre_DAV_Server($root); + $httpRequest = new Sabre_HTTP_Request(array( + 'HTTP_IF_NONE_MATCH' => '"abc123"', + 'REQUEST_URI' => '/foo' + )); + $server->httpRequest = $httpRequest; + $server->httpResponse = new Sabre_HTTP_ResponseMock(); + + $this->assertFalse($server->checkPreconditions(true)); + $this->assertEquals('HTTP/1.1 304 Not Modified',$server->httpResponse->status); + + } + + /** + * @covers Sabre_DAV_Server::checkPreconditions + */ + public function testIfModifiedSinceUnModified() { + + $root = new Sabre_DAV_SimpleDirectory('root',array(new Sabre_DAV_ServerPreconditionsNode())); + $server = new Sabre_DAV_Server($root); + $httpRequest = new Sabre_HTTP_Request(array( + 'HTTP_IF_MODIFIED_SINCE' => 'Sun, 06 Nov 1994 08:49:37 GMT', + 'REQUEST_URI' => '/foo' + )); + $server->httpRequest = $httpRequest; + $server->httpResponse = new Sabre_HTTP_ResponseMock(); + $this->assertFalse($server->checkPreconditions()); + + $this->assertEquals('HTTP/1.1 304 Not Modified',$server->httpResponse->status); + + } + + + /** + * @covers Sabre_DAV_Server::checkPreconditions + */ + public function testIfModifiedSinceModified() { + + $root = new Sabre_DAV_SimpleDirectory('root',array(new Sabre_DAV_ServerPreconditionsNode())); + $server = new Sabre_DAV_Server($root); + $httpRequest = new Sabre_HTTP_Request(array( + 'HTTP_IF_MODIFIED_SINCE' => 'Tue, 06 Nov 1984 08:49:37 GMT', + 'REQUEST_URI' => '/foo' + )); + $server->httpRequest = $httpRequest; + $server->httpResponse = new Sabre_HTTP_ResponseMock(); + $this->assertTrue($server->checkPreconditions()); + + } + + /** + * @covers Sabre_DAV_Server::checkPreconditions + */ + public function testIfModifiedSinceInvalidDate() { + + $root = new Sabre_DAV_SimpleDirectory('root',array(new Sabre_DAV_ServerPreconditionsNode())); + $server = new Sabre_DAV_Server($root); + $httpRequest = new Sabre_HTTP_Request(array( + 'HTTP_IF_MODIFIED_SINCE' => 'Your mother', + 'REQUEST_URI' => '/foo' + )); + $server->httpRequest = $httpRequest; + $server->httpResponse = new Sabre_HTTP_ResponseMock(); + + // Invalid dates must be ignored, so this should return true + $this->assertTrue($server->checkPreconditions()); + + } + + /** + * @covers Sabre_DAV_Server::checkPreconditions + */ + public function testIfModifiedSinceInvalidDate2() { + + $root = new Sabre_DAV_SimpleDirectory('root',array(new Sabre_DAV_ServerPreconditionsNode())); + $server = new Sabre_DAV_Server($root); + $httpRequest = new Sabre_HTTP_Request(array( + 'HTTP_IF_MODIFIED_SINCE' => 'Sun, 06 Nov 1994 08:49:37 EST', + 'REQUEST_URI' => '/foo' + )); + $server->httpRequest = $httpRequest; + $server->httpResponse = new Sabre_HTTP_ResponseMock(); + $this->assertTrue($server->checkPreconditions()); + + } + + + /** + * @covers Sabre_DAV_Server::checkPreconditions + */ + public function testIfUnmodifiedSinceUnModified() { + + $root = new Sabre_DAV_SimpleDirectory('root',array(new Sabre_DAV_ServerPreconditionsNode())); + $server = new Sabre_DAV_Server($root); + $httpRequest = new Sabre_HTTP_Request(array( + 'HTTP_IF_UNMODIFIED_SINCE' => 'Sun, 06 Nov 1994 08:49:37 GMT', + 'REQUEST_URI' => '/foo' + )); + $server->httpRequest = $httpRequest; + $this->assertTrue($server->checkPreconditions()); + + } + + + /** + * @covers Sabre_DAV_Server::checkPreconditions + * @expectedException Sabre_DAV_Exception_PreconditionFailed + */ + public function testIfUnmodifiedSinceModified() { + + $root = new Sabre_DAV_SimpleDirectory('root',array(new Sabre_DAV_ServerPreconditionsNode())); + $server = new Sabre_DAV_Server($root); + $httpRequest = new Sabre_HTTP_Request(array( + 'HTTP_IF_UNMODIFIED_SINCE' => 'Tue, 06 Nov 1984 08:49:37 GMT', + 'REQUEST_URI' => '/foo' + )); + $server->httpRequest = $httpRequest; + $server->httpResponse = new Sabre_HTTP_ResponseMock(); + $server->checkPreconditions(); + + } + + /** + * @covers Sabre_DAV_Server::checkPreconditions + */ + public function testIfUnmodifiedSinceInvalidDate() { + + $root = new Sabre_DAV_SimpleDirectory('root',array(new Sabre_DAV_ServerPreconditionsNode())); + $server = new Sabre_DAV_Server($root); + $httpRequest = new Sabre_HTTP_Request(array( + 'HTTP_IF_UNMODIFIED_SINCE' => 'Sun, 06 Nov 1984 08:49:37 CET', + 'REQUEST_URI' => '/foo' + )); + $server->httpRequest = $httpRequest; + $server->httpResponse = new Sabre_HTTP_ResponseMock(); + $this->assertTrue($server->checkPreconditions()); + + } + + +} + +class Sabre_DAV_ServerPreconditionsNode extends Sabre_DAV_File { + + function getETag() { + + return '"abc123"'; + + } + + function getLastModified() { + + /* my birthday & time, I believe */ + return strtotime('1985-04-07 01:30 +02:00'); + + } + + function getName() { + + return 'foo'; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerPropsTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerPropsTest.php new file mode 100755 index 0000000..3773acb --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerPropsTest.php @@ -0,0 +1,395 @@ +server->addPlugin(new Sabre_DAV_Locks_Plugin()); + + } + + function tearDown() { + + parent::tearDown(); + if (file_exists(SABRE_TEMPDIR.'../.sabredav')) unlink(SABRE_TEMPDIR.'../.sabredav'); + + } + + private function sendRequest($body) { + + $serverVars = array( + 'REQUEST_URI' => '/', + 'REQUEST_METHOD' => 'PROPFIND', + 'HTTP_DEPTH' => '0', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody($body); + + $this->server->httpRequest = ($request); + $this->server->exec(); + + } + + public function testPropFindEmptyBody() { + + $this->sendRequest(""); + + $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + 'DAV' => '1, 3, extended-mkcol, 2', + ), + $this->response->headers + ); + + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/","xmlns\\1=\"urn:DAV\"",$this->response->body); + $xml = simplexml_load_string($body); + $xml->registerXPathNamespace('d','urn:DAV'); + + list($data) = $xml->xpath('/d:multistatus/d:response/d:href'); + $this->assertEquals('/',(string)$data,'href element should have been /'); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:resourcetype'); + $this->assertEquals(1,count($data)); + + } + + function testSupportedLocks() { + + $xml = ' + + + + +'; + + $this->sendRequest($xml); + + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/","xmlns\\1=\"urn:DAV\"",$this->response->body); + $xml = simplexml_load_string($body); + $xml->registerXPathNamespace('d','urn:DAV'); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry'); + $this->assertEquals(2,count($data),'We expected two \'d:lockentry\' tags'); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:lockscope'); + $this->assertEquals(2,count($data),'We expected two \'d:lockscope\' tags'); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:locktype'); + $this->assertEquals(2,count($data),'We expected two \'d:locktype\' tags'); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:lockscope/d:shared'); + $this->assertEquals(1,count($data),'We expected a \'d:shared\' tag'); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:lockscope/d:exclusive'); + $this->assertEquals(1,count($data),'We expected a \'d:exclusive\' tag'); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:locktype/d:write'); + $this->assertEquals(2,count($data),'We expected two \'d:write\' tags'); + } + + function testLockDiscovery() { + + $xml = ' + + + + +'; + + $this->sendRequest($xml); + + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/","xmlns\\1=\"urn:DAV\"",$this->response->body); + $xml = simplexml_load_string($body); + $xml->registerXPathNamespace('d','urn:DAV'); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:lockdiscovery'); + $this->assertEquals(1,count($data),'We expected a \'d:lockdiscovery\' tag'); + + } + + function testUnknownProperty() { + + $xml = ' + + + + +'; + + $this->sendRequest($xml); + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/","xmlns\\1=\"urn:DAV\"",$this->response->body); + $xml = simplexml_load_string($body); + $xml->registerXPathNamespace('d','urn:DAV'); + $pathTests = array( + '/d:multistatus', + '/d:multistatus/d:response', + '/d:multistatus/d:response/d:propstat', + '/d:multistatus/d:response/d:propstat/d:status', + '/d:multistatus/d:response/d:propstat/d:prop', + '/d:multistatus/d:response/d:propstat/d:prop/d:macaroni', + ); + foreach($pathTests as $test) { + $this->assertTrue(count($xml->xpath($test))==true,'We expected the ' . $test . ' element to appear in the response, we got: ' . $body); + } + + $val = $xml->xpath('/d:multistatus/d:response/d:propstat/d:status'); + $this->assertEquals(1,count($val),$body); + $this->assertEquals('HTTP/1.1 404 Not Found',(string)$val[0]); + + } + + /** + * @covers Sabre_DAV_Server::parsePropPatchRequest + */ + public function testParsePropPatchRequest() { + + $body = ' + + somevalue + + removeme + +'; + + $result = $this->server->parsePropPatchRequest($body); + $this->assertEquals(array( + '{http://sabredav.org/NS/test}someprop' => 'somevalue', + '{http://sabredav.org/NS/test}someprop2' => null, + '{http://sabredav.org/NS/test}someprop3' => null, + ), $result); + + } + + /** + * @covers Sabre_DAV_Server::updateProperties + */ + public function testUpdateProperties() { + + $props = array( + '{http://sabredav.org/NS/test}someprop' => 'somevalue', + ); + + $result = $this->server->updateProperties('/test2.txt',$props); + + $this->assertEquals(array( + '200' => array('{http://sabredav.org/NS/test}someprop' => null), + 'href' => '/test2.txt', + ), $result); + + } + + /** + * @covers Sabre_DAV_Server::updateProperties + * @depends testUpdateProperties + */ + public function testUpdatePropertiesProtected() { + + $props = array( + '{http://sabredav.org/NS/test}someprop' => 'somevalue', + '{DAV:}getcontentlength' => 50, + ); + + $result = $this->server->updateProperties('/test2.txt',$props); + + $this->assertEquals(array( + '424' => array('{http://sabredav.org/NS/test}someprop' => null), + '403' => array('{DAV:}getcontentlength' => null), + 'href' => '/test2.txt', + ), $result); + + } + + /** + * @covers Sabre_DAV_Server::updateProperties + * @depends testUpdateProperties + */ + public function testUpdatePropertiesFail1() { + + $dir = new Sabre_DAV_PropTestDirMock('updatepropsfalse'); + $objectTree = new Sabre_DAV_ObjectTree($dir); + $this->server->tree = $objectTree; + + $props = array( + '{http://sabredav.org/NS/test}someprop' => 'somevalue', + ); + + $result = $this->server->updateProperties('/',$props); + + $this->assertEquals(array( + '403' => array('{http://sabredav.org/NS/test}someprop' => null), + 'href' => '/', + ), $result); + + } + + /** + * @covers Sabre_DAV_Server::updateProperties + * @depends testUpdateProperties + */ + public function testUpdatePropertiesFail2() { + + $dir = new Sabre_DAV_PropTestDirMock('updatepropsarray'); + $objectTree = new Sabre_DAV_ObjectTree($dir); + $this->server->tree = $objectTree; + + $props = array( + '{http://sabredav.org/NS/test}someprop' => 'somevalue', + ); + + $result = $this->server->updateProperties('/',$props); + + $this->assertEquals(array( + '402' => array('{http://sabredav.org/NS/test}someprop' => null), + 'href' => '/', + ), $result); + + } + + /** + * @covers Sabre_DAV_Server::updateProperties + * @depends testUpdateProperties + * @expectedException Sabre_DAV_Exception + */ + public function testUpdatePropertiesFail3() { + + $dir = new Sabre_DAV_PropTestDirMock('updatepropsobj'); + $objectTree = new Sabre_DAV_ObjectTree($dir); + $this->server->tree = $objectTree; + + $props = array( + '{http://sabredav.org/NS/test}someprop' => 'somevalue', + ); + + $result = $this->server->updateProperties('/',$props); + + } + + /** + * @depends testParsePropPatchRequest + * @depends testUpdateProperties + * @covers Sabre_DAV_Server::httpPropPatch + */ + public function testPropPatch() { + + $serverVars = array( + 'REQUEST_URI' => '/', + 'REQUEST_METHOD' => 'PROPPATCH', + ); + + $body = ' + + somevalue +'; + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody($body); + + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'We got the wrong status. Full XML response: ' . $this->response->body); + + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/","xmlns\\1=\"urn:DAV\"",$this->response->body); + $xml = simplexml_load_string($body); + $xml->registerXPathNamespace('d','urn:DAV'); + $xml->registerXPathNamespace('bla','http://www.rooftopsolutions.nl/testnamespace'); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop'); + $this->assertEquals(1,count($data),'We expected one \'d:prop\' element. Response body: ' . $body); + + $data = $xml->xpath('//bla:someprop'); + $this->assertEquals(1,count($data),'We expected one \'s:someprop\' element. Response body: ' . $body); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:status'); + $this->assertEquals(1,count($data),'We expected one \'s:status\' element. Response body: ' . $body); + + $this->assertEquals('HTTP/1.1 200 OK',(string)$data[0]); + + } + + /** + * @depends testPropPatch + */ + public function testPropPatchAndFetch() { + + $this->testPropPatch(); + $xml = ' + + + + +'; + + $this->sendRequest($xml); + + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/","xmlns\\1=\"urn:DAV\"",$this->response->body); + $xml = simplexml_load_string($body); + $xml->registerXPathNamespace('d','urn:DAV'); + $xml->registerXPathNamespace('bla','http://www.rooftopsolutions.nl/testnamespace'); + + $xpath='//bla:someprop'; + $result = $xml->xpath($xpath); + $this->assertEquals(1,count($result),'We couldn\'t find our new property in the response. Full response body:' . "\n" . $body); + $this->assertEquals('somevalue',(string)$result[0],'We couldn\'t find our new property in the response. Full response body:' . "\n" . $body); + + } + +} + +class Sabre_DAV_PropTestDirMock extends Sabre_DAV_SimpleDirectory implements Sabre_DAV_IProperties { + + public $type; + + function __construct($type) { + + $this->type =$type; + parent::__construct('root'); + + } + + function updateProperties($updateProperties) { + + switch($this->type) { + case 'updatepropsfalse' : return false; + case 'updatepropsarray' : + $r = array(402 => array()); + foreach($updateProperties as $k=>$v) $r[402][$k] = null; + return $r; + case 'updatepropsobj' : + return new STDClass(); + } + + } + + function getProperties($requestedPropeties) { + + return array(); + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerRangeTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerRangeTest.php new file mode 100755 index 0000000..4ef3cd3 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerRangeTest.php @@ -0,0 +1,273 @@ + '/test.txt', + 'REQUEST_METHOD' => 'GET', + 'HTTP_RANGE' => 'bytes=2-5', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/octet-stream', + 'Content-Length' => 4, + 'Content-Range' => 'bytes 2-5/13', + 'Last-Modified' => date(DateTime::RFC1123,filemtime($this->tempDir . '/test.txt')), + 'ETag' => '"' . md5(file_get_contents(SABRE_TEMPDIR . '/test.txt')). '"', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 206 Partial Content',$this->response->status); + $this->assertEquals('st c', stream_get_contents($this->response->body)); + + } + + /** + * @depends testRange + */ + function testStartRange() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'GET', + 'HTTP_RANGE' => 'bytes=2-', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/octet-stream', + 'Content-Length' => 11, + 'Content-Range' => 'bytes 2-12/13', + 'Last-Modified' => date(DateTime::RFC1123,filemtime($this->tempDir . '/test.txt')), + 'ETag' => '"' . md5(file_get_contents(SABRE_TEMPDIR . '/test.txt')) . '"', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 206 Partial Content',$this->response->status); + $this->assertEquals('st contents', stream_get_contents($this->response->body)); + + } + + /** + * @depends testRange + */ + function testEndRange() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'GET', + 'HTTP_RANGE' => 'bytes=-8', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/octet-stream', + 'Content-Length' => 8, + 'Content-Range' => 'bytes 5-12/13', + 'Last-Modified' => date(DateTime::RFC1123,filemtime($this->tempDir . '/test.txt')), + 'ETag' => '"' . md5(file_get_contents(SABRE_TEMPDIR . '/test.txt')). '"', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 206 Partial Content',$this->response->status); + $this->assertEquals('contents', stream_get_contents($this->response->body)); + + } + + /** + * @depends testRange + */ + function testTooHighRange() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'GET', + 'HTTP_RANGE' => 'bytes=100-200', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 416 Requested Range Not Satisfiable',$this->response->status); + + } + + /** + * @depends testRange + */ + function testCrazyRange() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'GET', + 'HTTP_RANGE' => 'bytes=8-4', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 416 Requested Range Not Satisfiable',$this->response->status); + + } + + /** + * @depends testRange + * @covers Sabre_DAV_Server::httpGet + */ + function testIfRangeEtag() { + + $node = $this->server->tree->getNodeForPath('test.txt'); + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'GET', + 'HTTP_RANGE' => 'bytes=2-5', + 'HTTP_IF_RANGE' => $node->getETag(), + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/octet-stream', + 'Content-Length' => 4, + 'Content-Range' => 'bytes 2-5/13', + 'Last-Modified' => date(DateTime::RFC1123,filemtime($this->tempDir . '/test.txt')), + 'ETag' => '"' . md5(file_get_contents(SABRE_TEMPDIR . '/test.txt')) . '"', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 206 Partial Content',$this->response->status); + $this->assertEquals('st c', stream_get_contents($this->response->body)); + + } + + /** + * @depends testRange + * @covers Sabre_DAV_Server::httpGet + */ + function testIfRangeEtagIncorrect() { + + $node = $this->server->tree->getNodeForPath('test.txt'); + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'GET', + 'HTTP_RANGE' => 'bytes=2-5', + 'HTTP_IF_RANGE' => $node->getETag() . 'blabla', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/octet-stream', + 'Content-Length' => 13, + 'Last-Modified' => date(DateTime::RFC1123,filemtime($this->tempDir . '/test.txt')), + 'ETag' => '"' . md5(file_get_contents(SABRE_TEMPDIR . '/test.txt')) . '"', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + $this->assertEquals('Test contents', stream_get_contents($this->response->body)); + + } + + /** + * @depends testRange + * @covers Sabre_DAV_Server::httpGet + */ + function testIfRangeModificationDate() { + + $node = $this->server->tree->getNodeForPath('test.txt'); + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'GET', + 'HTTP_RANGE' => 'bytes=2-5', + 'HTTP_IF_RANGE' => 'tomorrow', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/octet-stream', + 'Content-Length' => 4, + 'Content-Range' => 'bytes 2-5/13', + 'Last-Modified' => date(DateTime::RFC1123,filemtime($this->tempDir . '/test.txt')), + 'ETag' => '"' . md5(file_get_contents(SABRE_TEMPDIR . '/test.txt')) . '"', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 206 Partial Content',$this->response->status); + $this->assertEquals('st c', stream_get_contents($this->response->body)); + + } + + /** + * @depends testRange + * @covers Sabre_DAV_Server::httpGet + */ + function testIfRangeModificationDateModified() { + + $node = $this->server->tree->getNodeForPath('test.txt'); + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'GET', + 'HTTP_RANGE' => 'bytes=2-5', + 'HTTP_IF_RANGE' => '-2 years', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/octet-stream', + 'Content-Length' => 13, + 'Last-Modified' => date(DateTime::RFC1123,filemtime($this->tempDir . '/test.txt')), + 'ETag' => '"' . md5(file_get_contents(SABRE_TEMPDIR . '/test.txt')) . '"', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + $this->assertEquals('Test contents', stream_get_contents($this->response->body)); + + } +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerSimpleTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerSimpleTest.php new file mode 100755 index 0000000..28e3cd7 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerSimpleTest.php @@ -0,0 +1,685 @@ +assertEquals($nodes[0], $server->tree->getNodeForPath('hello')); + + } + + /** + * @expectedException Sabre_DAV_Exception + */ + function testConstructIncorrectObj() { + + $nodes = array( + new Sabre_DAV_SimpleDirectory('hello'), + new STDClass(), + ); + + $server = new Sabre_DAV_Server($nodes); + + } + + /** + * @expectedException Sabre_DAV_Exception + */ + function testConstructInvalidArg() { + + $server = new Sabre_DAV_Server(1); + + } + + function testGet() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'GET', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/octet-stream', + 'Content-Length' => 13, + 'Last-Modified' => date(DateTime::RFC1123,filemtime($this->tempDir . '/test.txt')), + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + $this->assertEquals('Test contents', stream_get_contents($this->response->body)); + + } + + function testGetDoesntExist() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt_randomblbla', + 'REQUEST_METHOD' => 'GET', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + $this->assertEquals('HTTP/1.1 404 Not Found',$this->response->status); + + } + + function testGetDoesntExist2() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt/randomblbla', + 'REQUEST_METHOD' => 'GET', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + $this->assertEquals('HTTP/1.1 404 Not Found',$this->response->status); + + } + + /** + * This test should have the exact same result as testGet. + * + * The idea is that double slashes // are converted to single ones / + * + */ + function testGetDoubleSlash() { + + $serverVars = array( + 'REQUEST_URI' => '//test.txt', + 'REQUEST_METHOD' => 'GET', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/octet-stream', + 'Content-Length' => 13, + 'Last-Modified' => date(DateTime::RFC1123,filemtime($this->tempDir . '/test.txt')), + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + $this->assertEquals('Test contents', stream_get_contents($this->response->body)); + + } + + + function testHEAD() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'HEAD', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/octet-stream', + 'Content-Length' => 13, + 'Last-Modified' => date(DateTime::RFC1123,filemtime($this->tempDir . '/test.txt')), + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + $this->assertEquals('', $this->response->body); + + } + + function testPut() { + + $serverVars = array( + 'REQUEST_URI' => '/testput.txt', + 'REQUEST_METHOD' => 'PUT', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody('Testing new file'); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('', $this->response->body); + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status); + $this->assertEquals(array( + 'Content-Length' => '0', + ),$this->response->headers); + + $this->assertEquals('Testing new file',file_get_contents($this->tempDir . '/testput.txt')); + + } + + function testPutAlreadyExists() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'PUT', + 'HTTP_IF_NONE_MATCH' => '*', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody('Testing new file'); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 412 Precondition failed',$this->response->status); + $this->assertNotEquals('Testing new file',file_get_contents($this->tempDir . '/test.txt')); + + } + + function testPutUpdate() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'PUT', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody('Testing updated file'); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Length' => '0', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status); + $this->assertEquals('', $this->response->body); + $this->assertEquals('Testing updated file',file_get_contents($this->tempDir . '/test.txt')); + + } + + function testPutContentRange() { + + $serverVars = array( + 'REQUEST_URI' => '/testput.txt', + 'REQUEST_METHOD' => 'PUT', + 'HTTP_CONTENT_RANGE' => 'bytes/100-200', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody('Testing new file'); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 501 Not Implemented',$this->response->status); + + } + + + function testDelete() { + + $serverVars = array( + 'REQUEST_URI' => '/test.txt', + 'REQUEST_METHOD' => 'DELETE', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Length' => '0', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status); + $this->assertEquals('', $this->response->body); + $this->assertFalse(file_exists($this->tempDir . '/test.txt')); + + } + + function testDeleteDirectory() { + + $serverVars = array( + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'DELETE', + ); + + mkdir($this->tempDir.'/testcol'); + file_put_contents($this->tempDir.'/testcol/test.txt','Hi! I\'m a file with a short lifespan'); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Length' => '0', + ),$this->response->headers); + $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status); + $this->assertEquals('', $this->response->body); + $this->assertFalse(file_exists($this->tempDir . '/col')); + + } + + function testOptions() { + + $serverVars = array( + 'REQUEST_URI' => '/', + 'REQUEST_METHOD' => 'OPTIONS', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'DAV' => '1, 3, extended-mkcol', + 'MS-Author-Via' => 'DAV', + 'Allow' => 'OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT', + 'Accept-Ranges' => 'bytes', + 'Content-Length' => '0', + 'X-Sabre-Version' => Sabre_DAV_Version::VERSION, + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + $this->assertEquals('', $this->response->body); + + + } + function testNonExistantMethod() { + + $serverVars = array( + 'REQUEST_URI' => '/', + 'REQUEST_METHOD' => 'BLABLA', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 501 Not Implemented',$this->response->status); + + + } + + function testGETOnCollection() { + + $serverVars = array( + 'REQUEST_URI' => '/', + 'REQUEST_METHOD' => 'GET', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 501 Not Implemented',$this->response->status); + + } + + function testHEADOnCollection() { + + $serverVars = array( + 'REQUEST_URI' => '/', + 'REQUEST_METHOD' => 'HEAD', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + + } + + function testBaseUri() { + + $serverVars = array( + 'REQUEST_URI' => '/blabla/test.txt', + 'REQUEST_METHOD' => 'GET', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->setBaseUri('/blabla/'); + $this->assertEquals('/blabla/',$this->server->getBaseUri()); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/octet-stream', + 'Content-Length' => 13, + 'Last-Modified' => date(DateTime::RFC1123,filemtime($this->tempDir . '/test.txt')), + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + $this->assertEquals('Test contents', stream_get_contents($this->response->body)); + + } + + function testBaseUriAddSlash() { + + $tests = array( + '/' => '/', + '/foo' => '/foo/', + '/foo/' => '/foo/', + '/foo/bar' => '/foo/bar/', + '/foo/bar/' => '/foo/bar/', + ); + + foreach($tests as $test=>$result) { + $this->server->setBaseUri($test); + + $this->assertEquals($result, $this->server->getBaseUri()); + + } + + } + + function testCalculateUri() { + + $uris = array( + 'http://www.example.org/root/somepath', + '/root/somepath', + '/root/somepath/', + ); + + $this->server->setBaseUri('/root/'); + + foreach($uris as $uri) { + + $this->assertEquals('somepath',$this->server->calculateUri($uri)); + + } + + $this->server->setBaseUri('/root'); + + foreach($uris as $uri) { + + $this->assertEquals('somepath',$this->server->calculateUri($uri)); + + } + + $this->assertEquals('', $this->server->calculateUri('/root')); + + } + + function testCalculateUriSpecialChars() { + + $uris = array( + 'http://www.example.org/root/%C3%A0fo%C3%B3', + '/root/%C3%A0fo%C3%B3', + '/root/%C3%A0fo%C3%B3/' + ); + + $this->server->setBaseUri('/root/'); + + foreach($uris as $uri) { + + $this->assertEquals("\xc3\xa0fo\xc3\xb3",$this->server->calculateUri($uri)); + + } + + $this->server->setBaseUri('/root'); + + foreach($uris as $uri) { + + $this->assertEquals("\xc3\xa0fo\xc3\xb3",$this->server->calculateUri($uri)); + + } + + $this->server->setBaseUri('/'); + + foreach($uris as $uri) { + + $this->assertEquals("root/\xc3\xa0fo\xc3\xb3",$this->server->calculateUri($uri)); + + } + + } + + function testBaseUriCheck() { + + $uris = array( + 'http://www.example.org/root/somepath', + '/root/somepath', + '/root/somepath/' + ); + + try { + + $this->server->setBaseUri('root/'); + $this->server->calculateUri('/root/testuri'); + + $this->fail('Expected an exception'); + + } catch (Sabre_DAV_Exception_Forbidden $e) { + + // This was expected + + } + + } + + /** + * @covers Sabre_DAV_Server::guessBaseUri + */ + function testGuessBaseUri() { + + $serverVars = array( + 'REQUEST_URI' => '/index.php/root', + 'PATH_INFO' => '/root', + ); + + $httpRequest = new Sabre_HTTP_Request($serverVars); + $server = new Sabre_DAV_Server(); + $server->httpRequest = $httpRequest; + + $this->assertEquals('/index.php/', $server->guessBaseUri()); + + } + + /** + * @depends testGuessBaseUri + * @covers Sabre_DAV_Server::guessBaseUri + */ + function testGuessBaseUriPercentEncoding() { + + $serverVars = array( + 'REQUEST_URI' => '/index.php/dir/path2/path%20with%20spaces', + 'PATH_INFO' => '/dir/path2/path with spaces', + ); + + $httpRequest = new Sabre_HTTP_Request($serverVars); + $server = new Sabre_DAV_Server(); + $server->httpRequest = $httpRequest; + + $this->assertEquals('/index.php/', $server->guessBaseUri()); + + } + + /** + * @depends testGuessBaseUri + * @covers Sabre_DAV_Server::guessBaseUri + */ + /* + function testGuessBaseUriPercentEncoding2() { + + $this->markTestIncomplete('This behaviour is not yet implemented'); + $serverVars = array( + 'REQUEST_URI' => '/some%20directory+mixed/index.php/dir/path2/path%20with%20spaces', + 'PATH_INFO' => '/dir/path2/path with spaces', + ); + + $httpRequest = new Sabre_HTTP_Request($serverVars); + $server = new Sabre_DAV_Server(); + $server->httpRequest = $httpRequest; + + $this->assertEquals('/some%20directory+mixed/index.php/', $server->guessBaseUri()); + + }*/ + + function testGuessBaseUri2() { + + $serverVars = array( + 'REQUEST_URI' => '/index.php/root/', + 'PATH_INFO' => '/root/', + ); + + $httpRequest = new Sabre_HTTP_Request($serverVars); + $server = new Sabre_DAV_Server(); + $server->httpRequest = $httpRequest; + + $this->assertEquals('/index.php/', $server->guessBaseUri()); + + } + + function testGuessBaseUriNoPathInfo() { + + $serverVars = array( + 'REQUEST_URI' => '/index.php/root', + ); + + $httpRequest = new Sabre_HTTP_Request($serverVars); + $server = new Sabre_DAV_Server(); + $server->httpRequest = $httpRequest; + + $this->assertEquals('/', $server->guessBaseUri()); + + } + + function testGuessBaseUriNoPathInfo2() { + + $serverVars = array( + 'REQUEST_URI' => '/a/b/c/test.php', + ); + + $httpRequest = new Sabre_HTTP_Request($serverVars); + $server = new Sabre_DAV_Server(); + $server->httpRequest = $httpRequest; + + $this->assertEquals('/', $server->guessBaseUri()); + + } + + + /** + * @covers Sabre_DAV_Server::guessBaseUri + * @depends testGuessBaseUri + */ + function testGuessBaseUriQueryString() { + + $serverVars = array( + 'REQUEST_URI' => '/index.php/root?query_string=blabla', + 'PATH_INFO' => '/root', + ); + + $httpRequest = new Sabre_HTTP_Request($serverVars); + $server = new Sabre_DAV_Server(); + $server->httpRequest = $httpRequest; + + $this->assertEquals('/index.php/', $server->guessBaseUri()); + + } + + function testTriggerException() { + + $this->server->subscribeEvent('beforeMethod',array($this,'exceptionTrigger')); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ),$this->response->headers); + + $this->assertEquals('HTTP/1.1 500 Internal Server Error',$this->response->status); + + } + + function exceptionTrigger() { + + throw new Sabre_DAV_Exception('Hola'); + + } + + function testReportNotFound() { + + $serverVars = array( + 'REQUEST_URI' => '/', + 'REQUEST_METHOD' => 'REPORT', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->httpRequest->setBody(''); + $this->server->exec(); + + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 501 Not Implemented',$this->response->status,'We got an incorrect status back. Full response body follows: ' . $this->response->body); + + } + + function testReportIntercepted() { + + $serverVars = array( + 'REQUEST_URI' => '/', + 'REQUEST_METHOD' => 'REPORT', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->httpRequest->setBody(''); + $this->server->subscribeEvent('report',array($this,'reportHandler')); + $this->server->exec(); + + $this->assertEquals(array( + 'testheader' => 'testvalue', + ), + $this->response->headers + ); + + $this->assertEquals('HTTP/1.1 418 I\'m a teapot',$this->response->status,'We got an incorrect status back. Full response body follows: ' . $this->response->body); + + } + + function reportHandler($reportName) { + + if ($reportName=='{http://www.rooftopsolutions.nl/NS}myreport') { + $this->server->httpResponse->sendStatus(418); + $this->server->httpResponse->setHeader('testheader','testvalue'); + return false; + } + else return; + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerUpdatePropertiesTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerUpdatePropertiesTest.php new file mode 100755 index 0000000..1aedd0d --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/ServerUpdatePropertiesTest.php @@ -0,0 +1,127 @@ +updateProperties('foo', array( + '{DAV:}foo' => 'bar' + )); + + $expected = array( + 'href' => 'foo', + '403' => array( + '{DAV:}foo' => null, + ), + ); + $this->assertEquals($expected, $result); + + } + + function testUpdatePropertiesProtected() { + + $tree = array( + new Sabre_DAV_SimpleDirectory('foo'), + ); + $server = new Sabre_DAV_Server($tree); + + $result = $server->updateProperties('foo', array( + '{DAV:}getetag' => 'bla', + '{DAV:}foo' => 'bar' + )); + + $expected = array( + 'href' => 'foo', + '403' => array( + '{DAV:}getetag' => null, + ), + '424' => array( + '{DAV:}foo' => null, + ), + ); + $this->assertEquals($expected, $result); + + } + + function testUpdatePropertiesEventFail() { + + $tree = array( + new Sabre_DAV_SimpleDirectory('foo'), + ); + $server = new Sabre_DAV_Server($tree); + $server->subscribeEvent('updateProperties', array($this,'updatepropfail')); + + $result = $server->updateProperties('foo', array( + '{DAV:}foo' => 'bar', + '{DAV:}foo2' => 'bla', + )); + + $expected = array( + 'href' => 'foo', + '404' => array( + '{DAV:}foo' => null, + ), + '424' => array( + '{DAV:}foo2' => null, + ), + ); + $this->assertEquals($expected, $result); + + } + + function updatePropFail(&$propertyDelta, &$result, $node) { + + $result[404] = array( + '{DAV:}foo' => null, + ); + unset($propertyDelta['{DAV:}foo']); + return false; + + } + + + function testUpdatePropertiesEventSuccess() { + + $tree = array( + new Sabre_DAV_SimpleDirectory('foo'), + ); + $server = new Sabre_DAV_Server($tree); + $server->subscribeEvent('updateProperties', array($this,'updatepropsuccess')); + + $result = $server->updateProperties('foo', array( + '{DAV:}foo' => 'bar', + '{DAV:}foo2' => 'bla', + )); + + $expected = array( + 'href' => 'foo', + '200' => array( + '{DAV:}foo' => null, + ), + '201' => array( + '{DAV:}foo2' => null, + ), + ); + $this->assertEquals($expected, $result); + + } + + function updatePropSuccess(&$propertyDelta, &$result, $node) { + + $result[200] = array( + '{DAV:}foo' => null, + ); + $result[201] = array( + '{DAV:}foo2' => null, + ); + unset($propertyDelta['{DAV:}foo']); + unset($propertyDelta['{DAV:}foo2']); + return; + + } +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/SimpleFileTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/SimpleFileTest.php new file mode 100755 index 0000000..ae626e8 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/SimpleFileTest.php @@ -0,0 +1,19 @@ +assertEquals('filename.txt', $file->getName()); + $this->assertEquals('contents', $file->get()); + $this->assertEquals('8', $file->getSize()); + $this->assertEquals('"' . md5('contents') . '"', $file->getETag()); + $this->assertEquals('text/plain', $file->getContentType()); + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/StringUtilTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/StringUtilTest.php new file mode 100755 index 0000000..84915e4 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/StringUtilTest.php @@ -0,0 +1,120 @@ +assertEquals($result, Sabre_DAV_StringUtil::textMatch($haystack, $needle, $collation, $matchType)); + + } + + function dataset() { + + return array( + array('FOOBAR', 'FOO', 'i;octet', 'contains', true), + array('FOOBAR', 'foo', 'i;octet', 'contains', false), + array('FÖÖBAR', 'FÖÖ', 'i;octet', 'contains', true), + array('FÖÖBAR', 'föö', 'i;octet', 'contains', false), + array('FOOBAR', 'FOOBAR', 'i;octet', 'equals', true), + array('FOOBAR', 'fooBAR', 'i;octet', 'equals', false), + array('FOOBAR', 'FOO', 'i;octet', 'starts-with', true), + array('FOOBAR', 'foo', 'i;octet', 'starts-with', false), + array('FOOBAR', 'BAR', 'i;octet', 'starts-with', false), + array('FOOBAR', 'bar', 'i;octet', 'starts-with', false), + array('FOOBAR', 'FOO', 'i;octet', 'ends-with', false), + array('FOOBAR', 'foo', 'i;octet', 'ends-with', false), + array('FOOBAR', 'BAR', 'i;octet', 'ends-with', true), + array('FOOBAR', 'bar', 'i;octet', 'ends-with', false), + + array('FOOBAR', 'FOO', 'i;ascii-casemap', 'contains', true), + array('FOOBAR', 'foo', 'i;ascii-casemap', 'contains', true), + array('FÖÖBAR', 'FÖÖ', 'i;ascii-casemap', 'contains', true), + array('FÖÖBAR', 'föö', 'i;ascii-casemap', 'contains', false), + array('FOOBAR', 'FOOBAR', 'i;ascii-casemap', 'equals', true), + array('FOOBAR', 'fooBAR', 'i;ascii-casemap', 'equals', true), + array('FOOBAR', 'FOO', 'i;ascii-casemap', 'starts-with', true), + array('FOOBAR', 'foo', 'i;ascii-casemap', 'starts-with', true), + array('FOOBAR', 'BAR', 'i;ascii-casemap', 'starts-with', false), + array('FOOBAR', 'bar', 'i;ascii-casemap', 'starts-with', false), + array('FOOBAR', 'FOO', 'i;ascii-casemap', 'ends-with', false), + array('FOOBAR', 'foo', 'i;ascii-casemap', 'ends-with', false), + array('FOOBAR', 'BAR', 'i;ascii-casemap', 'ends-with', true), + array('FOOBAR', 'bar', 'i;ascii-casemap', 'ends-with', true), + + array('FOOBAR', 'FOO', 'i;unicode-casemap', 'contains', true), + array('FOOBAR', 'foo', 'i;unicode-casemap', 'contains', true), + array('FÖÖBAR', 'FÖÖ', 'i;unicode-casemap', 'contains', true), + array('FÖÖBAR', 'föö', 'i;unicode-casemap', 'contains', true), + array('FOOBAR', 'FOOBAR', 'i;unicode-casemap', 'equals', true), + array('FOOBAR', 'fooBAR', 'i;unicode-casemap', 'equals', true), + array('FOOBAR', 'FOO', 'i;unicode-casemap', 'starts-with', true), + array('FOOBAR', 'foo', 'i;unicode-casemap', 'starts-with', true), + array('FOOBAR', 'BAR', 'i;unicode-casemap', 'starts-with', false), + array('FOOBAR', 'bar', 'i;unicode-casemap', 'starts-with', false), + array('FOOBAR', 'FOO', 'i;unicode-casemap', 'ends-with', false), + array('FOOBAR', 'foo', 'i;unicode-casemap', 'ends-with', false), + array('FOOBAR', 'BAR', 'i;unicode-casemap', 'ends-with', true), + array('FOOBAR', 'bar', 'i;unicode-casemap', 'ends-with', true), + ); + + } + + /** + * @expectedException Sabre_DAV_Exception_BadRequest + */ + public function testBadCollation() { + + Sabre_DAV_StringUtil::textMatch('foobar','foo','blabla','contains'); + + } + + + /** + * @expectedException Sabre_DAV_Exception_BadRequest + */ + public function testBadMatchType() { + + Sabre_DAV_StringUtil::textMatch('foobar','foo','i;octet','booh'); + + } + + public function testEnsureUTF8_ascii() { + + $inputString = "harkema"; + $outputString = "harkema"; + + $this->assertEquals( + $outputString, + Sabre_DAV_StringUtil::ensureUTF8($inputString) + ); + + } + + public function testEnsureUTF8_latin1() { + + $inputString = "m\xfcnster"; + $outputString = "münster"; + + $this->assertEquals( + $outputString, + Sabre_DAV_StringUtil::ensureUTF8($inputString) + ); + + } + + public function testEnsureUTF8_utf8() { + + $inputString = "m\xc3\xbcnster"; + $outputString = "münster"; + + $this->assertEquals( + $outputString, + Sabre_DAV_StringUtil::ensureUTF8($inputString) + ); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/TemporaryFileFilterTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/TemporaryFileFilterTest.php new file mode 100755 index 0000000..0faddff --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/TemporaryFileFilterTest.php @@ -0,0 +1,250 @@ +server->addPlugin($plugin); + + } + + function testPutNormal() { + + $serverVars = array( + 'REQUEST_URI' => '/testput.txt', + 'REQUEST_METHOD' => 'PUT', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody('Testing new file'); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('', $this->response->body); + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status); + $this->assertEquals(array( + 'Content-Length' => '0', + ),$this->response->headers); + + $this->assertEquals('Testing new file',file_get_contents(SABRE_TEMPDIR . '/testput.txt')); + + } + + function testPutTemp() { + + // mimicking an OS/X resource fork + $serverVars = array( + 'REQUEST_URI' => '/._testput.txt', + 'REQUEST_METHOD' => 'PUT', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody('Testing new file'); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('', $this->response->body); + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status); + $this->assertEquals(array( + 'X-Sabre-Temp' => 'true', + ),$this->response->headers); + + $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testput.txt'),'._testput.txt should not exist in the regular file structure.'); + + } + + function testPutTempIfNoneMatch() { + + // mimicking an OS/X resource fork + $serverVars = array( + 'REQUEST_URI' => '/._testput.txt', + 'REQUEST_METHOD' => 'PUT', + 'HTTP_IF_NONE_MATCH' => '*', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody('Testing new file'); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('', $this->response->body); + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status); + $this->assertEquals(array( + 'X-Sabre-Temp' => 'true', + ),$this->response->headers); + + $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testput.txt'),'._testput.txt should not exist in the regular file structure.'); + + + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 412 Precondition failed',$this->response->status); + $this->assertEquals(array( + 'X-Sabre-Temp' => 'true', + 'Content-Type' => 'application/xml; charset=utf-8', + ),$this->response->headers); + + } + + function testPutGet() { + + // mimicking an OS/X resource fork + $serverVars = array( + 'REQUEST_URI' => '/._testput.txt', + 'REQUEST_METHOD' => 'PUT', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody('Testing new file'); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('', $this->response->body); + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status); + $this->assertEquals(array( + 'X-Sabre-Temp' => 'true', + ),$this->response->headers); + + $serverVars = array( + 'REQUEST_URI' => '/._testput.txt', + 'REQUEST_METHOD' => 'GET', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 200 OK',$this->response->status); + $this->assertEquals(array( + 'X-Sabre-Temp' => 'true', + 'Content-Length' => 16, + 'Content-Type' => 'application/octet-stream', + ),$this->response->headers); + + $this->assertEquals('Testing new file',stream_get_contents($this->response->body)); + + } + + function testLockNonExistant() { + + mkdir(SABRE_TEMPDIR . '/locksdir'); + $locksBackend = new Sabre_DAV_Locks_Backend_FS(SABRE_TEMPDIR . '/locksdir'); + $locksPlugin = new Sabre_DAV_Locks_Plugin($locksBackend); + $this->server->addPlugin($locksPlugin); + + // mimicking an OS/X resource fork + $serverVars = array( + 'REQUEST_URI' => '/._testlock.txt', + 'REQUEST_METHOD' => 'LOCK', + ); + + $request = new Sabre_HTTP_Request($serverVars); + + $request->setBody(' + + + + + http://example.org/~ejw/contact.html + +'); + + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status); + $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']); + $this->assertTrue(preg_match('/^$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')'); + $this->assertEquals('true',$this->response->headers['X-Sabre-Temp']); + + $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testlock.txt'),'._testlock.txt should not exist in the regular file structure.'); + + } + + function testPutDelete() { + + // mimicking an OS/X resource fork + $serverVars = array( + 'REQUEST_URI' => '/._testput.txt', + 'REQUEST_METHOD' => 'PUT', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody('Testing new file'); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('', $this->response->body); + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status); + $this->assertEquals(array( + 'X-Sabre-Temp' => 'true', + ),$this->response->headers); + + $serverVars = array( + 'REQUEST_URI' => '/._testput.txt', + 'REQUEST_METHOD' => 'DELETE', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status, "Incorrect status code received. Full body:\n". $this->response->body); + $this->assertEquals(array( + 'X-Sabre-Temp' => 'true', + ),$this->response->headers); + + $this->assertEquals('',$this->response->body); + + } + + function testPutPropfind() { + + // mimicking an OS/X resource fork + $serverVars = array( + 'REQUEST_URI' => '/._testput.txt', + 'REQUEST_METHOD' => 'PUT', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody('Testing new file'); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('', $this->response->body); + $this->assertEquals('HTTP/1.1 201 Created',$this->response->status); + $this->assertEquals(array( + 'X-Sabre-Temp' => 'true', + ),$this->response->headers); + + $serverVars = array( + 'REQUEST_URI' => '/._testput.txt', + 'REQUEST_METHOD' => 'PROPFIND', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody(''); + $this->server->httpRequest = ($request); + $this->server->exec(); + + $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'Incorrect status code returned. Body: ' . $this->response->body); + $this->assertEquals(array( + 'X-Sabre-Temp' => 'true', + 'Content-Type' => 'application/xml; charset=utf-8', + ),$this->response->headers); + + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/","xmlns\\1=\"urn:DAV\"",$this->response->body); + $xml = simplexml_load_string($body); + $xml->registerXPathNamespace('d','urn:DAV'); + + list($data) = $xml->xpath('/d:multistatus/d:response/d:href'); + $this->assertEquals('/._testput.txt',(string)$data,'href element should have been /._testput.txt'); + + $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:resourcetype'); + $this->assertEquals(1,count($data)); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/TestPlugin.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/TestPlugin.php new file mode 100755 index 0000000..cbd96d9 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/TestPlugin.php @@ -0,0 +1,32 @@ +subscribeEvent('beforeMethod',array($this,'beforeMethod')); + + } + + function beforeMethod($method) { + + $this->beforeMethod = $method; + return true; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Tree/FilesystemTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Tree/FilesystemTest.php new file mode 100755 index 0000000..cf310ec --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/Tree/FilesystemTest.php @@ -0,0 +1,72 @@ +getNodeForPath('file.txt'); + $this->assertTrue($node instanceof Sabre_DAV_FS_File); + + } + + function testGetNodeForPath_Directory() { + + $fs = new Sabre_DAV_Tree_Filesystem(SABRE_TEMPDIR); + $node = $fs->getNodeForPath('dir'); + $this->assertTrue($node instanceof Sabre_DAV_FS_Directory); + + } + + function testCopy() { + + $fs = new Sabre_DAV_Tree_Filesystem(SABRE_TEMPDIR); + $fs->copy('file.txt','file2.txt'); + $this->assertTrue(file_exists(SABRE_TEMPDIR . '/file2.txt')); + $this->assertEquals('Body',file_get_contents(SABRE_TEMPDIR . '/file2.txt')); + + } + + function testCopyDir() { + + $fs = new Sabre_DAV_Tree_Filesystem(SABRE_TEMPDIR); + $fs->copy('dir','dir2'); + $this->assertTrue(file_exists(SABRE_TEMPDIR . '/dir2')); + $this->assertEquals('Body',file_get_contents(SABRE_TEMPDIR . '/dir2/subfile.txt')); + + } + + function testMove() { + + $fs = new Sabre_DAV_Tree_Filesystem(SABRE_TEMPDIR); + $fs->move('file.txt','file2.txt'); + $this->assertTrue(file_exists(SABRE_TEMPDIR . '/file2.txt')); + $this->assertTrue(!file_exists(SABRE_TEMPDIR . '/file.txt')); + $this->assertEquals('Body',file_get_contents(SABRE_TEMPDIR . '/file2.txt')); + + } + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/TreeTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/TreeTest.php new file mode 100755 index 0000000..be42399 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/TreeTest.php @@ -0,0 +1,173 @@ +assertTrue($tree->nodeExists('hi')); + $this->assertFalse($tree->nodeExists('hello')); + + } + + function testCopy() { + + $tree = new Sabre_DAV_TreeMock(); + $tree->copy('hi','hi2'); + + $this->assertArrayHasKey('hi2', $tree->getNodeForPath('')->newDirectories); + $this->assertEquals('foobar', $tree->getNodeForPath('hi/file')->get()); + $this->assertEquals(array('test1'=>'value'), $tree->getNodeForPath('hi/file')->getProperties(array())); + + } + + function testMove() { + + $tree = new Sabre_DAV_TreeMock(); + $tree->move('hi','hi2'); + + $this->assertEquals('hi2', $tree->getNodeForPath('hi')->getName()); + $this->assertTrue($tree->getNodeForPath('hi')->isRenamed); + + } + + function testDeepMove() { + + $tree = new Sabre_DAV_TreeMock(); + $tree->move('hi/sub','hi2'); + + $this->assertArrayHasKey('hi2', $tree->getNodeForPath('')->newDirectories); + $this->assertTrue($tree->getNodeForPath('hi/sub')->isDeleted); + + } + + function testDelete() { + + $tree = new Sabre_DAV_TreeMock(); + $tree->delete('hi'); + $this->assertTrue($tree->getNodeForPath('hi')->isDeleted); + + } + + function testGetChildren() { + + $tree = new Sabre_DAV_TreeMock(); + $children = $tree->getChildren(''); + $this->assertEquals(1,count($children)); + $this->assertEquals('hi', $children[0]->getName()); + + } + +} + +class Sabre_DAV_TreeMock extends Sabre_DAV_Tree { + + private $nodes = array(); + + function __construct() { + + $this->nodes['hi/sub'] = new Sabre_DAV_TreeDirectoryTester('sub'); + $this->nodes['hi/file'] = new Sabre_DAV_TreeFileTester('file'); + $this->nodes['hi/file']->properties = array('test1' => 'value'); + $this->nodes['hi/file']->data = 'foobar'; + $this->nodes['hi'] = new Sabre_DAV_TreeDirectoryTester('hi',array($this->nodes['hi/sub'], $this->nodes['hi/file'])); + $this->nodes[''] = new Sabre_DAV_TreeDirectoryTester('hi', array($this->nodes['hi'])); + + } + + function getNodeForPath($path) { + + if (isset($this->nodes[$path])) return $this->nodes[$path]; + throw new Sabre_DAV_Exception_FileNotFound('item not found'); + + } + +} + +class Sabre_DAV_TreeDirectoryTester extends Sabre_DAV_SimpleDirectory { + + public $newDirectories = array(); + public $newFiles = array(); + public $isDeleted = false; + public $isRenamed = false; + + function createDirectory($name) { + + $this->newDirectories[$name] = true; + + } + + function createFile($name,$data = null) { + + $this->newFiles[$name] = $data; + + } + + function getChild($name) { + + if (isset($this->newDirectories[$name])) return new Sabre_DAV_TreeDirectoryTester($name); + if (isset($this->newFiles[$name])) return new Sabre_DAV_TreeFileTester($name, $this->newFiles[$name]); + return parent::getChild($name); + + } + + function delete() { + + $this->isDeleted = true; + + } + + function setName($name) { + + $this->isRenamed = true; + $this->name = $name; + + } + +} + +class Sabre_DAV_TreeFileTester extends Sabre_DAV_File implements Sabre_DAV_IProperties { + + public $name; + public $data; + public $properties; + + function __construct($name, $data = null) { + + $this->name = $name; + if (is_null($data)) $data = 'bla'; + $this->data = $data; + + } + + function getName() { + + return $this->name; + + } + + function get() { + + return $this->data; + + } + + function getProperties($properties) { + + return $this->properties; + + } + + function updateProperties($properties) { + + $this->properties = $properties; + return true; + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/URLUtilTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/URLUtilTest.php new file mode 100755 index 0000000..8ca248e --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/URLUtilTest.php @@ -0,0 +1,129 @@ +assertEquals( + '%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f'. + '%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f'. + '%20%21%22%23%24%25%26%27()%2a%2b%2c-./'. + '0123456789%3a%3b%3c%3d%3e%3f'. + '%40ABCDEFGHIJKLMNO' . + 'PQRSTUVWXYZ%5b%5c%5d%5e_' . + '%60abcdefghijklmno' . + 'pqrstuvwxyz%7b%7c%7d~%7f', + $newStr); + + $this->assertEquals($str,Sabre_DAV_URLUtil::decodePath($newStr)); + + } + + function testEncodePathSegment() { + + $str = ''; + for($i=0;$i<128;$i++) $str.=chr($i); + + $newStr = Sabre_DAV_URLUtil::encodePathSegment($str); + + // Note: almost exactly the same as the last test, with the + // exception of the encoding of / (ascii code 2f) + $this->assertEquals( + '%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f'. + '%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f'. + '%20%21%22%23%24%25%26%27()%2a%2b%2c-.%2f'. + '0123456789%3a%3b%3c%3d%3e%3f'. + '%40ABCDEFGHIJKLMNO' . + 'PQRSTUVWXYZ%5b%5c%5d%5e_' . + '%60abcdefghijklmno' . + 'pqrstuvwxyz%7b%7c%7d~%7f', + $newStr); + + $this->assertEquals($str,Sabre_DAV_URLUtil::decodePathSegment($newStr)); + + } + + function testDecode() { + + $str = 'Hello%20Test+Test2.txt'; + $newStr = Sabre_DAV_URLUtil::decodePath($str); + $this->assertEquals('Hello Test Test2.txt',$newStr); + + } + + /** + * @depends testDecode + */ + function testDecodeUmlaut() { + + $str = 'Hello%C3%BC.txt'; + $newStr = Sabre_DAV_URLUtil::decodePath($str); + $this->assertEquals("Hello\xC3\xBC.txt",$newStr); + + } + + /** + * @depends testDecodeUmlaut + */ + function testDecodeUmlautLatin1() { + + $str = 'Hello%FC.txt'; + $newStr = Sabre_DAV_URLUtil::decodePath($str); + $this->assertEquals("Hello\xC3\xBC.txt",$newStr); + + } + + /** + * This testcase was sent by a bug reporter + * + * @depends testDecode + */ + function testDecodeAccentsWindows7() { + + $str = '/webdav/%C3%A0fo%C3%B3'; + $newStr = Sabre_DAV_URLUtil::decodePath($str); + $this->assertEquals(strtolower($str),Sabre_DAV_URLUtil::encodePath($newStr)); + + } + + function testSplitPath() { + + $strings = array( + + // input // expected result + '/foo/bar' => array('/foo','bar'), + '/foo/bar/' => array('/foo','bar'), + 'foo/bar/' => array('foo','bar'), + 'foo/bar' => array('foo','bar'), + 'foo/bar/baz' => array('foo/bar','baz'), + 'foo/bar/baz/' => array('foo/bar','baz'), + 'foo' => array('','foo'), + 'foo/' => array('','foo'), + '/foo/' => array('','foo'), + '/foo' => array('','foo'), + '' => array(null,null), + + // UTF-8 + "/\xC3\xA0fo\xC3\xB3/bar" => array("/\xC3\xA0fo\xC3\xB3",'bar'), + "/\xC3\xA0foo/b\xC3\xBCr/" => array("/\xC3\xA0foo","b\xC3\xBCr"), + "foo/\xC3\xA0\xC3\xBCr" => array("foo","\xC3\xA0\xC3\xBCr"), + + ); + + foreach($strings as $input => $expected) { + + $output = Sabre_DAV_URLUtil::splitPath($input); + $this->assertEquals($expected, $output, 'The expected output for \'' . $input . '\' was incorrect'); + + + } + + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/UUIDUtilTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/UUIDUtilTest.php new file mode 100755 index 0000000..613461b --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/UUIDUtilTest.php @@ -0,0 +1,23 @@ +assertTrue( + Sabre_DAV_UUIDUtil::validateUUID('11111111-2222-3333-4444-555555555555') + ); + $this->assertFalse( + Sabre_DAV_UUIDUtil::validateUUID(' 11111111-2222-3333-4444-555555555555') + ); + $this->assertTrue( + Sabre_DAV_UUIDUtil::validateUUID('ffffffff-2222-3333-4444-555555555555') + ); + $this->assertFalse( + Sabre_DAV_UUIDUtil::validateUUID('fffffffg-2222-3333-4444-555555555555') + ); + + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/XMLUtilTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/XMLUtilTest.php new file mode 100755 index 0000000..e9fd1ff --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAV/XMLUtilTest.php @@ -0,0 +1,282 @@ +loadXML('Testdoc'); + + $this->assertEquals( + '{http://www.example.org/}test1', + Sabre_DAV_XMLUtil::toClarkNotation($dom->firstChild) + ); + + } + + function testToClarkNotation2() { + + $dom = new DOMDocument(); + $dom->loadXML('Testdoc'); + + $this->assertEquals( + '{http://www.example.org/}test1', + Sabre_DAV_XMLUtil::toClarkNotation($dom->firstChild) + ); + + } + + function testToClarkNotationDAVNamespace() { + + $dom = new DOMDocument(); + $dom->loadXML('Testdoc'); + + $this->assertEquals( + '{DAV:}test1', + Sabre_DAV_XMLUtil::toClarkNotation($dom->firstChild) + ); + + } + + function testToClarkNotationNoElem() { + + $dom = new DOMDocument(); + $dom->loadXML('Testdoc'); + + $this->assertNull( + Sabre_DAV_XMLUtil::toClarkNotation($dom->firstChild->firstChild) + ); + + } + + function testConvertDAVNamespace() { + + $xml='blablabla'; + $this->assertEquals( + 'blablabla', + Sabre_DAV_XMLUtil::convertDAVNamespace($xml) + ); + + } + + function testConvertDAVNamespace2() { + + $xml='blablabla'; + $this->assertEquals( + 'blablabla', + Sabre_DAV_XMLUtil::convertDAVNamespace($xml) + ); + + } + + function testConvertDAVNamespace3() { + + $xml='blablabla'; + $this->assertEquals( + 'blablabla', + Sabre_DAV_XMLUtil::convertDAVNamespace($xml) + ); + + } + + function testConvertDAVNamespace4() { + + $xml='blablabla'; + $this->assertEquals( + 'blablabla', + Sabre_DAV_XMLUtil::convertDAVNamespace($xml) + ); + + } + + function testConvertDAVNamespaceMixedQuotes() { + + $xml=''; + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml); + $this->assertTrue($dom instanceof DOMDocument); + + } + + /** + * @depends testLoadDOMDocument + * @expectedException Sabre_DAV_Exception_BadRequest + */ + function testLoadDOMDocumentEmpty() { + + Sabre_DAV_XMLUtil::loadDOMDocument(''); + + } + + /** + * @depends testConvertDAVNamespace + * @expectedException Sabre_DAV_Exception_BadRequest + */ + function testLoadDOMDocumentInvalid() { + + $xml='assertEquals('blabla',$dom->firstChild->nodeValue); + + } + + + function testParseProperties() { + + $xml=' + + + Calendars + +'; + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml); + $properties = Sabre_DAV_XMLUtil::parseProperties($dom->firstChild); + + $this->assertEquals(array( + '{DAV:}displayname' => 'Calendars', + ), $properties); + + + + } + + /** + * @depends testParseProperties + */ + function testParsePropertiesEmpty() { + + $xml=' + + + Calendars + + + + +'; + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml); + $properties = Sabre_DAV_XMLUtil::parseProperties($dom->firstChild); + + $this->assertEquals(array( + '{DAV:}displayname' => 'Calendars', + '{http://www.rooftopsolutions.nl/example}example' => null + ), $properties); + + } + + + /** + * @depends testParseProperties + */ + function testParsePropertiesComplex() { + + $xml=' + + + Calendars + + + Complex value right here + +'; + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml); + $properties = Sabre_DAV_XMLUtil::parseProperties($dom->firstChild); + + $this->assertEquals(array( + '{DAV:}displayname' => 'Calendars', + '{DAV:}someprop' => 'Complex value right here', + ), $properties); + + } + + + /** + * @depends testParseProperties + */ + function testParsePropertiesNoProperties() { + + $xml=' + + + +'; + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml); + $properties = Sabre_DAV_XMLUtil::parseProperties($dom->firstChild); + + $this->assertEquals(array(), $properties); + + } + + function testParsePropertiesMapHref() { + + $xml=' + + + Calendars + + + http://sabredav.org/ + +'; + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml); + $properties = Sabre_DAV_XMLUtil::parseProperties($dom->firstChild,array('{DAV:}someprop'=>'Sabre_DAV_Property_Href')); + + $this->assertEquals(array( + '{DAV:}displayname' => 'Calendars', + '{DAV:}someprop' => new Sabre_DAV_Property_Href('http://sabredav.org/',false), + ), $properties); + + } + + function testParseClarkNotation() { + + $this->assertEquals(array( + 'DAV:', + 'foo', + ), Sabre_DAV_XMLUtil::parseClarkNotation('{DAV:}foo')); + + $this->assertEquals(array( + 'http://example.org/ns/bla', + 'bar-soap', + ), Sabre_DAV_XMLUtil::parseClarkNotation('{http://example.org/ns/bla}bar-soap')); + } + + /** + * @expectedException InvalidArgumentException + */ + function testParseClarkNotationFail() { + + Sabre_DAV_XMLUtil::parseClarkNotation('}foo'); + + } + +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/ACLMethodTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/ACLMethodTest.php new file mode 100755 index 0000000..ddff460 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/ACLMethodTest.php @@ -0,0 +1,326 @@ +addPlugin($acl); + + $acl->unknownMethod('ACL','test'); + + } + + function testCallbackPassthru() { + + $acl = new Sabre_DAVACL_Plugin(); + $server = new Sabre_DAV_Server(); + $server->addPlugin($acl); + + $this->assertNull($acl->unknownMethod('FOO','test')); + + } + + /** + + /** + * @expectedException Sabre_DAV_Exception_MethodNotAllowed + */ + function testNotSupportedByNode() { + + $tree = array( + new Sabre_DAV_SimpleDirectory('test'), + ); + $acl = new Sabre_DAVACL_Plugin(); + $server = new Sabre_DAV_Server($tree); + $server->httpRequest = new Sabre_HTTP_Request(); + $body = ' + +'; + $server->httpRequest->setBody($body); + $server->addPlugin($acl); + + $acl->httpACL('test'); + + } + + function testSuccessSimple() { + + $tree = array( + new Sabre_DAVACL_MockACLNode('test',array()), + ); + $acl = new Sabre_DAVACL_Plugin(); + $server = new Sabre_DAV_Server($tree); + $server->httpRequest = new Sabre_HTTP_Request(); + $body = ' + +'; + $server->httpRequest->setBody($body); + $server->addPlugin($acl); + + $this->assertNull($acl->httpACL('test')); + + } + + /** + * @expectedException Sabre_DAVACL_Exception_NotRecognizedPrincipal + */ + function testUnrecognizedPrincipal() { + + $tree = array( + new Sabre_DAVACL_MockACLNode('test',array()), + ); + $acl = new Sabre_DAVACL_Plugin(); + $server = new Sabre_DAV_Server($tree); + $server->httpRequest = new Sabre_HTTP_Request(); + $body = ' + + + + /principals/notfound + +'; + $server->httpRequest->setBody($body); + $server->addPlugin($acl); + + $acl->httpACL('test'); + + } + + /** + * @expectedException Sabre_DAVACL_Exception_NotRecognizedPrincipal + */ + function testUnrecognizedPrincipal2() { + + $tree = array( + new Sabre_DAVACL_MockACLNode('test',array()), + new Sabre_DAV_SimpleDirectory('principals',array( + new Sabre_DAV_SimpleDirectory('notaprincipal'), + )), + ); + $acl = new Sabre_DAVACL_Plugin(); + $server = new Sabre_DAV_Server($tree); + $server->httpRequest = new Sabre_HTTP_Request(); + $body = ' + + + + /principals/notaprincipal + +'; + $server->httpRequest->setBody($body); + $server->addPlugin($acl); + + $acl->httpACL('test'); + + } + + /** + * @expectedException Sabre_DAVACL_Exception_NotSupportedPrivilege + */ + function testUnknownPrivilege() { + + $tree = array( + new Sabre_DAVACL_MockACLNode('test',array()), + ); + $acl = new Sabre_DAVACL_Plugin(); + $server = new Sabre_DAV_Server($tree); + $server->httpRequest = new Sabre_HTTP_Request(); + $body = ' + + + + /principals/notfound + +'; + $server->httpRequest->setBody($body); + $server->addPlugin($acl); + + $acl->httpACL('test'); + + } + + /** + * @expectedException Sabre_DAVACL_Exception_NoAbstract + */ + function testAbstractPrivilege() { + + $tree = array( + new Sabre_DAVACL_MockACLNode('test',array()), + ); + $acl = new Sabre_DAVACL_Plugin(); + $server = new Sabre_DAV_Server($tree); + $server->httpRequest = new Sabre_HTTP_Request(); + $body = ' + + + + /principals/notfound + +'; + $server->httpRequest->setBody($body); + $server->addPlugin($acl); + + $acl->httpACL('test'); + + } + + /** + * @expectedException Sabre_DAVACL_Exception_AceConflict + */ + function testUpdateProtectedPrivilege() { + + $oldACL = array( + array( + 'principal' => 'principals/notfound', + 'privilege' => '{DAV:}write', + 'protected' => true, + ), + ); + + $tree = array( + new Sabre_DAVACL_MockACLNode('test',$oldACL), + ); + $acl = new Sabre_DAVACL_Plugin(); + $server = new Sabre_DAV_Server($tree); + $server->httpRequest = new Sabre_HTTP_Request(); + $body = ' + + + + /principals/notfound + +'; + $server->httpRequest->setBody($body); + $server->addPlugin($acl); + + $acl->httpACL('test'); + + } + + /** + * @expectedException Sabre_DAVACL_Exception_AceConflict + */ + function testUpdateProtectedPrivilege2() { + + $oldACL = array( + array( + 'principal' => 'principals/notfound', + 'privilege' => '{DAV:}write', + 'protected' => true, + ), + ); + + $tree = array( + new Sabre_DAVACL_MockACLNode('test',$oldACL), + ); + $acl = new Sabre_DAVACL_Plugin(); + $server = new Sabre_DAV_Server($tree); + $server->httpRequest = new Sabre_HTTP_Request(); + $body = ' + + + + /principals/foo + +'; + $server->httpRequest->setBody($body); + $server->addPlugin($acl); + + $acl->httpACL('test'); + + } + + /** + * @expectedException Sabre_DAVACL_Exception_AceConflict + */ + function testUpdateProtectedPrivilege3() { + + $oldACL = array( + array( + 'principal' => 'principals/notfound', + 'privilege' => '{DAV:}write', + 'protected' => true, + ), + ); + + $tree = array( + new Sabre_DAVACL_MockACLNode('test',$oldACL), + ); + $acl = new Sabre_DAVACL_Plugin(); + $server = new Sabre_DAV_Server($tree); + $server->httpRequest = new Sabre_HTTP_Request(); + $body = ' + + + + /principals/notfound + +'; + $server->httpRequest->setBody($body); + $server->addPlugin($acl); + + $acl->httpACL('test'); + + } + + function testSuccessComplex () { + + $oldACL = array( + array( + 'principal' => 'principals/foo', + 'privilege' => '{DAV:}write', + 'protected' => true, + ), + array( + 'principal' => 'principals/bar', + 'privilege' => '{DAV:}read', + ), + ); + + $tree = array( + $node = new Sabre_DAVACL_MockACLNode('test',$oldACL), + new Sabre_DAV_SimpleDirectory('principals', array( + new Sabre_DAVACL_MockPrincipal('foo','principals/foo'), + new Sabre_DAVACL_MockPrincipal('baz','principals/baz'), + )), + ); + $acl = new Sabre_DAVACL_Plugin(); + $server = new Sabre_DAV_Server($tree); + $server->httpRequest = new Sabre_HTTP_Request(); + $body = ' + + + + /principals/foo + + + + + /principals/baz + +'; + $server->httpRequest->setBody($body); + $server->addPlugin($acl); + + $this->assertFalse($acl->unknownMethod('ACL','test')); + + $this->assertEquals(array( + array( + 'principal' => 'principals/foo', + 'privilege' => '{DAV:}write', + 'protected' => true, + ), + array( + 'principal' => 'principals/baz', + 'privilege' => '{DAV:}write', + 'protected' => false, + ), + ), $node->getACL()); + + } +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/AllowAccessTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/AllowAccessTest.php new file mode 100755 index 0000000..c12a5f5 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/AllowAccessTest.php @@ -0,0 +1,131 @@ +server = new Sabre_DAV_Server($nodes); + $aclPlugin = new Sabre_DAVACL_Plugin(); + $aclPlugin->allowAccessToNodesWithoutACL = true; + $this->server->addPlugin($aclPlugin); + + } + + function testGet() { + + $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('GET','testdir'))); + + } + + function testGetDoesntExist() { + + $r = $this->server->broadcastEvent('beforeMethod',array('GET','foo')); + $this->assertTrue($r); + + } + + function testHEAD() { + + $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('HEAD','testdir'))); + + } + + function testOPTIONS() { + + $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('OPTIONS','testdir'))); + + } + + function testPUT() { + + $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('PUT','testdir'))); + + } + + function testACL() { + + $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('ACL','testdir'))); + + } + + function testPROPPATCH() { + + $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('PROPPATCH','testdir'))); + + } + + function testCOPY() { + + $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('COPY','testdir'))); + + } + + function testMOVE() { + + $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('MOVE','testdir'))); + + } + + function testLOCK() { + + $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('LOCK','testdir'))); + + } + + function testBeforeBind() { + + $this->assertTrue($this->server->broadcastEvent('beforeBind',array('testdir/file'))); + + } + + + function testBeforeUnbind() { + + $this->assertTrue($this->server->broadcastEvent('beforeUnbind',array('testdir'))); + + } + + function testAfterGetProperties() { + + $properties = array( + 'href' => 'foo', + '200' => array( + '{DAV:}displayname' => 'foo', + '{DAV:}getcontentlength' => 500, + ), + '404' => array( + '{DAV:}bar' => null, + ), + '403' => array( + '{DAV:}owner' => null, + ), + ); + + $expected = array( + 'href' => 'foo', + '200' => array( + '{DAV:}displayname' => 'foo', + '{DAV:}getcontentlength' => 500, + ), + '404' => array( + '{DAV:}bar' => null, + ), + '403' => array( + '{DAV:}owner' => null, + ), + ); + + $r = $this->server->broadcastEvent('afterGetProperties',array('testdir',&$properties)); + $this->assertTrue($r); + + $this->assertEquals($expected, $properties); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/BlockAccessTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/BlockAccessTest.php new file mode 100755 index 0000000..a4c5f70 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/BlockAccessTest.php @@ -0,0 +1,182 @@ +server = new Sabre_DAV_Server($nodes); + $this->plugin = new Sabre_DAVACL_Plugin(); + $this->plugin->allowAccessToNodesWithoutACL = false; + $this->server->addPlugin($this->plugin); + + } + + /** + * @expectedException Sabre_DAVACL_Exception_NeedPrivileges + */ + function testGet() { + + $this->server->broadcastEvent('beforeMethod',array('GET','testdir')); + + } + + function testGetDoesntExist() { + + $r = $this->server->broadcastEvent('beforeMethod',array('GET','foo')); + $this->assertTrue($r); + + } + + /** + * @expectedException Sabre_DAVACL_Exception_NeedPrivileges + */ + function testHEAD() { + + $this->server->broadcastEvent('beforeMethod',array('HEAD','testdir')); + + } + + /** + * @expectedException Sabre_DAVACL_Exception_NeedPrivileges + */ + function testOPTIONS() { + + $this->server->broadcastEvent('beforeMethod',array('OPTIONS','testdir')); + + } + + /** + * @expectedException Sabre_DAVACL_Exception_NeedPrivileges + */ + function testPUT() { + + $this->server->broadcastEvent('beforeMethod',array('PUT','testdir')); + + } + + /** + * @expectedException Sabre_DAVACL_Exception_NeedPrivileges + */ + function testPROPPATCH() { + + $this->server->broadcastEvent('beforeMethod',array('PROPPATCH','testdir')); + + } + + /** + * @expectedException Sabre_DAVACL_Exception_NeedPrivileges + */ + function testCOPY() { + + $this->server->broadcastEvent('beforeMethod',array('COPY','testdir')); + + } + + /** + * @expectedException Sabre_DAVACL_Exception_NeedPrivileges + */ + function testMOVE() { + + $this->server->broadcastEvent('beforeMethod',array('MOVE','testdir')); + + } + + /** + * @expectedException Sabre_DAVACL_Exception_NeedPrivileges + */ + function testACL() { + + $this->server->broadcastEvent('beforeMethod',array('ACL','testdir')); + + } + + /** + * @expectedException Sabre_DAVACL_Exception_NeedPrivileges + */ + function testLOCK() { + + $this->server->broadcastEvent('beforeMethod',array('LOCK','testdir')); + + } + + /** + * @expectedException Sabre_DAVACL_Exception_NeedPrivileges + */ + function testBeforeBind() { + + $this->server->broadcastEvent('beforeBind',array('testdir/file')); + + } + + /** + * @expectedException Sabre_DAVACL_Exception_NeedPrivileges + */ + function testBeforeUnbind() { + + $this->server->broadcastEvent('beforeUnbind',array('testdir')); + + } + + function testBeforeGetProperties() { + + $requestedProperties = array( + '{DAV:}displayname', + '{DAV:}getcontentlength', + '{DAV:}bar', + '{DAV:}owner', + ); + $returnedProperties = array(); + + $arguments = array( + 'testdir', + new Sabre_DAV_SimpleDirectory('testdir'), + &$requestedProperties, + &$returnedProperties + ); + $r = $this->server->broadcastEvent('beforeGetProperties',$arguments); + $this->assertTrue($r); + + $expected = array( + '403' => array( + '{DAV:}displayname' => null, + '{DAV:}getcontentlength' => null, + '{DAV:}bar' => null, + '{DAV:}owner' => null, + ), + ); + + $this->assertEquals($expected, $returnedProperties); + $this->assertEquals(array(), $requestedProperties); + + } + + function testBeforeGetPropertiesNoListing() { + + $this->plugin->hideNodesFromListings = true; + + $requestedProperties = array( + '{DAV:}displayname', + '{DAV:}getcontentlength', + '{DAV:}bar', + '{DAV:}owner', + ); + $returnedProperties = array(); + + $arguments = array( + 'testdir', + new Sabre_DAV_SimpleDirectory('testdir'), + &$requestedProperties, + &$returnedProperties + ); + $r = $this->server->broadcastEvent('beforeGetProperties',$arguments); + $this->assertFalse($r); + + } +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/AceConflictTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/AceConflictTest.php new file mode 100755 index 0000000..4e0f3ee --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/AceConflictTest.php @@ -0,0 +1,35 @@ +createElementNS('DAV:','d:root'); + $dom->appendChild($root); + + $ex->serialize($server, $root); + + $xpaths = array( + '/d:root' => 1, + '/d:root/d:no-ace-conflict' => 1, + ); + + // Reloading because PHP DOM sucks + $dom2 = new DOMDocument('1.0', 'utf-8'); + $dom2->loadXML($dom->saveXML()); + + $dxpath = new DOMXPath($dom2); + $dxpath->registerNamespace('d','DAV:'); + foreach($xpaths as $xpath=>$count) { + + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); + + } + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php new file mode 100755 index 0000000..1be4d17 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php @@ -0,0 +1,45 @@ +createElementNS('DAV:','d:root'); + $dom->appendChild($root); + + $ex->serialize($server, $root); + + $xpaths = array( + '/d:root' => 1, + '/d:root/d:need-privileges' => 1, + '/d:root/d:need-privileges/d:resource' => 2, + '/d:root/d:need-privileges/d:resource/d:href' => 2, + '/d:root/d:need-privileges/d:resource/d:privilege' => 2, + '/d:root/d:need-privileges/d:resource/d:privilege/d:read' => 1, + '/d:root/d:need-privileges/d:resource/d:privilege/d:write' => 1, + ); + + // Reloading because PHP DOM sucks + $dom2 = new DOMDocument('1.0', 'utf-8'); + $dom2->loadXML($dom->saveXML()); + + $dxpath = new DOMXPath($dom2); + $dxpath->registerNamespace('d','DAV:'); + foreach($xpaths as $xpath=>$count) { + + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); + + } + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/NoAbstractTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/NoAbstractTest.php new file mode 100755 index 0000000..e469dac --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/NoAbstractTest.php @@ -0,0 +1,35 @@ +createElementNS('DAV:','d:root'); + $dom->appendChild($root); + + $ex->serialize($server, $root); + + $xpaths = array( + '/d:root' => 1, + '/d:root/d:no-abstract' => 1, + ); + + // Reloading because PHP DOM sucks + $dom2 = new DOMDocument('1.0', 'utf-8'); + $dom2->loadXML($dom->saveXML()); + + $dxpath = new DOMXPath($dom2); + $dxpath->registerNamespace('d','DAV:'); + foreach($xpaths as $xpath=>$count) { + + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); + + } + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php new file mode 100755 index 0000000..d676908 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php @@ -0,0 +1,35 @@ +createElementNS('DAV:','d:root'); + $dom->appendChild($root); + + $ex->serialize($server, $root); + + $xpaths = array( + '/d:root' => 1, + '/d:root/d:recognized-principal' => 1, + ); + + // Reloading because PHP DOM sucks + $dom2 = new DOMDocument('1.0', 'utf-8'); + $dom2->loadXML($dom->saveXML()); + + $dxpath = new DOMXPath($dom2); + $dxpath->registerNamespace('d','DAV:'); + foreach($xpaths as $xpath=>$count) { + + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); + + } + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php new file mode 100755 index 0000000..09c58bb --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php @@ -0,0 +1,35 @@ +createElementNS('DAV:','d:root'); + $dom->appendChild($root); + + $ex->serialize($server, $root); + + $xpaths = array( + '/d:root' => 1, + '/d:root/d:not-supported-privilege' => 1, + ); + + // Reloading because PHP DOM sucks + $dom2 = new DOMDocument('1.0', 'utf-8'); + $dom2->loadXML($dom->saveXML()); + + $dxpath = new DOMXPath($dom2); + $dxpath->registerNamespace('d','DAV:'); + foreach($xpaths as $xpath=>$count) { + + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); + + } + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/ExpandPropertiesTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/ExpandPropertiesTest.php new file mode 100755 index 0000000..53975f6 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/ExpandPropertiesTest.php @@ -0,0 +1,353 @@ + 'foo', + '{http://sabredav.org/ns}href' => new Sabre_DAV_Property_Href('node2'), + '{DAV:}displayname' => 'Node 1', + )), + new Sabre_DAVACL_MockPropertyNode('node2', array( + '{http://sabredav.org/ns}simple' => 'simple', + '{http://sabredav.org/ns}hreflist' => new Sabre_DAV_Property_HrefList(array('node1','node3')), + '{DAV:}displayname' => 'Node 2', + )), + new Sabre_DAVACL_MockPropertyNode('node3', array( + '{http://sabredav.org/ns}simple' => 'simple', + '{DAV:}displayname' => 'Node 3', + )), + ); + + $fakeServer = new Sabre_DAV_Server($tree); + $fakeServer->debugExceptions = true; + $fakeServer->httpResponse = new Sabre_HTTP_ResponseMock(); + $plugin = new Sabre_DAVACL_Plugin(); + $plugin->allowAccessToNodesWithoutACL = true; + + $this->assertTrue($plugin instanceof Sabre_DAVACL_Plugin); + $fakeServer->addPlugin($plugin); + $this->assertEquals($plugin, $fakeServer->getPlugin('acl')); + + return $fakeServer; + + } + + function testSimple() { + + $xml = ' + + + + + +'; + + $serverVars = array( + 'REQUEST_METHOD' => 'REPORT', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/node1', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody($xml); + + $server = $this->getServer(); + $server->httpRequest = $request; + + $server->exec(); + + $this->assertEquals('HTTP/1.1 207 Multi-Status', $server->httpResponse->status,'Incorrect status code received. Full body: ' . $server->httpResponse->body); + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ), $server->httpResponse->headers); + + + $check = array( + '/d:multistatus', + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 2, + '/d:multistatus/d:response/d:propstat/d:prop' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:simple' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:href' => 1, + ); + + $xml = simplexml_load_string($server->httpResponse->body); + $xml->registerXPathNamespace('d','DAV:'); + $xml->registerXPathNamespace('s','http://sabredav.org/ns'); + foreach($check as $v1=>$v2) { + + $xpath = is_int($v1)?$v2:$v1; + + $result = $xml->xpath($xpath); + + $count = 1; + if (!is_int($v1)) $count = $v2; + + $this->assertEquals($count,count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response: ' . $server->httpResponse->body); + + } + + } + + /** + * @depends testSimple + */ + function testExpand() { + + $xml = ' + + + + +'; + + $serverVars = array( + 'REQUEST_METHOD' => 'REPORT', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/node1', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody($xml); + + $server = $this->getServer(); + $server->httpRequest = $request; + + $server->exec(); + + $this->assertEquals('HTTP/1.1 207 Multi-Status', $server->httpResponse->status, 'Incorrect response status received. Full response body: ' . $server->httpResponse->body); + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ), $server->httpResponse->headers); + + + $check = array( + '/d:multistatus', + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop/d:displayname' => 1, + ); + + $xml = simplexml_load_string($server->httpResponse->body); + $xml->registerXPathNamespace('d','DAV:'); + $xml->registerXPathNamespace('s','http://sabredav.org/ns'); + foreach($check as $v1=>$v2) { + + $xpath = is_int($v1)?$v2:$v1; + + $result = $xml->xpath($xpath); + + $count = 1; + if (!is_int($v1)) $count = $v2; + + $this->assertEquals($count,count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result)); + + } + + } + + /** + * @depends testSimple + */ + function testExpandHrefList() { + + $xml = ' + + + + +'; + + $serverVars = array( + 'REQUEST_METHOD' => 'REPORT', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/node2', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody($xml); + + $server = $this->getServer(); + $server->httpRequest = $request; + + $server->exec(); + + $this->assertEquals('HTTP/1.1 207 Multi-Status', $server->httpResponse->status); + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ), $server->httpResponse->headers); + + + $check = array( + '/d:multistatus', + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/d:displayname' => 2, + ); + + $xml = simplexml_load_string($server->httpResponse->body); + $xml->registerXPathNamespace('d','DAV:'); + $xml->registerXPathNamespace('s','http://sabredav.org/ns'); + foreach($check as $v1=>$v2) { + + $xpath = is_int($v1)?$v2:$v1; + + $result = $xml->xpath($xpath); + + $count = 1; + if (!is_int($v1)) $count = $v2; + + $this->assertEquals($count,count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result)); + + } + + } + + /** + * @depends testExpand + */ + function testExpandDeep() { + + $xml = ' + + + + + + + +'; + + $serverVars = array( + 'REQUEST_METHOD' => 'REPORT', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/node2', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody($xml); + + $server = $this->getServer(); + $server->httpRequest = $request; + + $server->exec(); + + $this->assertEquals('HTTP/1.1 207 Multi-Status', $server->httpResponse->status); + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ), $server->httpResponse->headers); + + + $check = array( + '/d:multistatus', + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 3, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 3, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/d:displayname' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop/d:displayname' => 1, + ); + + $xml = simplexml_load_string($server->httpResponse->body); + $xml->registerXPathNamespace('d','DAV:'); + $xml->registerXPathNamespace('s','http://sabredav.org/ns'); + foreach($check as $v1=>$v2) { + + $xpath = is_int($v1)?$v2:$v1; + + $result = $xml->xpath($xpath); + + $count = 1; + if (!is_int($v1)) $count = $v2; + + $this->assertEquals($count,count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result)); + + } + + } +} +class Sabre_DAVACL_MockPropertyNode implements Sabre_DAV_INode, Sabre_DAV_IProperties { + + function __construct($name, array $properties) { + + $this->name = $name; + $this->properties = $properties; + + } + + function getName() { + + return $this->name; + + } + + function getProperties($requestedProperties) { + + $returnedProperties = array(); + foreach($requestedProperties as $requestedProperty) { + if (isset($this->properties[$requestedProperty])) { + $returnedProperties[$requestedProperty] = + $this->properties[$requestedProperty]; + } + } + return $returnedProperties; + + } + + function delete() { + + throw new Sabre_DAV_Exception('Not implemented'); + + } + + function setName($name) { + + throw new Sabre_DAV_Exception('Not implemented'); + + } + + function getLastModified() { + + return null; + + } + + function updateProperties($properties) { + + throw new Sabre_DAV_Exception('Not implemented'); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/MockACLNode.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/MockACLNode.php new file mode 100755 index 0000000..2cb82e6 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/MockACLNode.php @@ -0,0 +1,45 @@ +name = $name; + $this->acl = $acl; + + } + + function getName() { + + return $this->name; + + } + + function getOwner() { + + return null; + + } + + function getGroup() { + + return null; + + } + + function getACL() { + + return $this->acl; + + } + + function setACL(array $acl) { + + $this->acl = $acl; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/MockPrincipal.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/MockPrincipal.php new file mode 100755 index 0000000..1ea2de3 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/MockPrincipal.php @@ -0,0 +1,61 @@ +name = $name; + $this->principalUrl = $principalUrl; + $this->groupMembership = $groupMembership; + $this->groupMemberSet = $groupMemberSet; + + } + + function getName() { + + return $this->name; + + } + + function getDisplayName() { + + return $this->getName(); + + } + + function getAlternateUriSet() { + + return array(); + + } + + function getPrincipalUrl() { + + return $this->principalUrl; + + } + + function getGroupMemberSet() { + + return $this->groupMemberSet; + + } + + function getGroupMemberShip() { + + return $this->groupMembership; + + } + + function setGroupMemberSet(array $groupMemberSet) { + + $this->groupMemberSet = $groupMemberSet; + + } +} + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/MockPrincipalBackend.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/MockPrincipalBackend.php new file mode 100755 index 0000000..bface9c --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/MockPrincipalBackend.php @@ -0,0 +1,57 @@ + 'principals/user1', + '{DAV:}displayname' => 'User 1', + '{http://sabredav.org/ns}email-address' => 'user1.sabredav@sabredav.org', + ), + array( + 'uri' => 'principals/admin', + '{DAV:}displayname' => 'Admin', + ), + ); + + } + + } + + function getPrincipalByPath($path) { + + foreach($this->getPrincipalsByPrefix('principals') as $principal) { + if ($principal['uri'] === $path) return $principal; + } + + } + + function getGroupMemberSet($path) { + + return isset($this->groupMembers[$path]) ? $this->groupMembers[$path] : array(); + + } + + function getGroupMembership($path) { + + $membership = array(); + foreach($this->groupMembers as $group=>$members) { + if (in_array($path, $members)) $membership[] = $group; + } + return $membership; + + } + + function setGroupMemberSet($path, array $members) { + + $this->groupMembers[$path] = $members; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PluginPropertiesTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PluginPropertiesTest.php new file mode 100755 index 0000000..c4db399 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PluginPropertiesTest.php @@ -0,0 +1,361 @@ +principalCollectionSet = array( + 'principals1', + 'principals2', + ); + + $requestedProperties = array( + '{DAV:}principal-collection-set', + ); + + $returnedProperties = array( + 200 => array(), + 404 => array(), + ); + + $server = new Sabre_DAV_Server(); + $server->addPlugin($plugin); + + $this->assertNull($plugin->beforeGetProperties('', new Sabre_DAV_SimpleDirectory('root'), $requestedProperties, $returnedProperties)); + + $this->assertEquals(1,count($returnedProperties[200])); + $this->assertArrayHasKey('{DAV:}principal-collection-set',$returnedProperties[200]); + $this->assertInstanceOf('Sabre_DAV_Property_HrefList', $returnedProperties[200]['{DAV:}principal-collection-set']); + + $expected = array( + 'principals1/', + 'principals2/', + ); + + + $this->assertEquals($expected, $returnedProperties[200]['{DAV:}principal-collection-set']->getHrefs()); + + + } + + function testCurrentUserPrincipal() { + + $fakeServer = new Sabre_DAV_Server(); + $plugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(),'realm'); + $fakeServer->addPlugin($plugin); + $plugin = new Sabre_DAVACL_Plugin(); + $fakeServer->addPlugin($plugin); + + + $requestedProperties = array( + '{DAV:}current-user-principal', + ); + + $returnedProperties = array( + 200 => array(), + 404 => array(), + ); + + $this->assertNull($plugin->beforeGetProperties('', new Sabre_DAV_SimpleDirectory('root'), $requestedProperties, $returnedProperties)); + + $this->assertEquals(1,count($returnedProperties[200])); + $this->assertArrayHasKey('{DAV:}current-user-principal',$returnedProperties[200]); + $this->assertInstanceOf('Sabre_DAVACL_Property_Principal', $returnedProperties[200]['{DAV:}current-user-principal']); + $this->assertEquals(Sabre_DAVACL_Property_Principal::UNAUTHENTICATED, $returnedProperties[200]['{DAV:}current-user-principal']->getType()); + + // This will force the login + $fakeServer->broadCastEvent('beforeMethod',array('GET','')); + + + $requestedProperties = array( + '{DAV:}current-user-principal', + ); + + $returnedProperties = array( + 200 => array(), + 404 => array(), + ); + + + $this->assertNull($plugin->beforeGetProperties('', new Sabre_DAV_SimpleDirectory('root'), $requestedProperties, $returnedProperties)); + + + $this->assertEquals(1,count($returnedProperties[200])); + $this->assertArrayHasKey('{DAV:}current-user-principal',$returnedProperties[200]); + $this->assertInstanceOf('Sabre_DAVACL_Property_Principal', $returnedProperties[200]['{DAV:}current-user-principal']); + $this->assertEquals(Sabre_DAVACL_Property_Principal::HREF, $returnedProperties[200]['{DAV:}current-user-principal']->getType()); + $this->assertEquals('principals/admin/', $returnedProperties[200]['{DAV:}current-user-principal']->getHref()); + + } + + function testSupportedPrivilegeSet() { + + $plugin = new Sabre_DAVACL_Plugin(); + $server = new Sabre_DAV_Server(); + $server->addPlugin($plugin); + + $requestedProperties = array( + '{DAV:}supported-privilege-set', + ); + + $returnedProperties = array( + 200 => array(), + 404 => array(), + ); + + + $this->assertNull($plugin->beforeGetProperties('', new Sabre_DAV_SimpleDirectory('root'), $requestedProperties, $returnedProperties)); + + $this->assertEquals(1,count($returnedProperties[200])); + $this->assertArrayHasKey('{DAV:}supported-privilege-set',$returnedProperties[200]); + $this->assertInstanceOf('Sabre_DAVACL_Property_SupportedPrivilegeSet', $returnedProperties[200]['{DAV:}supported-privilege-set']); + + $server = new Sabre_DAV_Server(); + $prop = $returnedProperties[200]['{DAV:}supported-privilege-set']; + + $dom = new DOMDocument('1.0', 'utf-8'); + $root = $dom->createElement('d:root'); + $root->setAttribute('xmlns:d','DAV:'); + $dom->appendChild($root); + $prop->serialize($server, $root); + + + $xpaths = array( + '/d:root' => 1, + '/d:root/d:supported-privilege' => 1, + '/d:root/d:supported-privilege/d:privilege' => 1, + '/d:root/d:supported-privilege/d:privilege/d:all' => 1, + '/d:root/d:supported-privilege/d:abstract' => 1, + '/d:root/d:supported-privilege/d:supported-privilege' => 2, + '/d:root/d:supported-privilege/d:supported-privilege/d:privilege' => 2, + '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:read' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:write' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege' => 8, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege' => 8, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-acl' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-current-user-privilege-set' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-content' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-properties' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-acl' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:bind' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unbind' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unlock' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:abstract' => 8, + ); + + + // reloading because php dom sucks + $dom2 = new DOMDocument('1.0', 'utf-8'); + $dom2->loadXML($dom->saveXML()); + + $dxpath = new DOMXPath($dom2); + $dxpath->registerNamespace('d','DAV:'); + foreach($xpaths as $xpath=>$count) { + + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); + + } + + } + + function testACL() { + + $plugin = new Sabre_DAVACL_Plugin(); + + $nodes = array( + new Sabre_DAVACL_MockACLNode('foo', array( + array( + 'principal' => 'principals/admin', + 'privilege' => '{DAV:}read', + ) + )), + new Sabre_DAV_SimpleDirectory('principals', array( + $principal = new Sabre_DAVACL_MockPrincipal('admin','principals/admin'), + )), + + ); + + $server = new Sabre_DAV_Server($nodes); + $server->addPlugin($plugin); + $authPlugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(),'realm'); + $server->addPlugin($authPlugin); + + // Force login + $authPlugin->beforeMethod('BLA','foo'); + + $requestedProperties = array( + '{DAV:}acl', + ); + + $returnedProperties = array( + 200 => array(), + 404 => array(), + ); + + + $this->assertNull($plugin->beforeGetProperties('foo', $nodes[0], $requestedProperties, $returnedProperties)); + + $this->assertEquals(1,count($returnedProperties[200]),'The {DAV:}acl property did not return from the list. Full list: ' . print_r($returnedProperties,true)); + $this->assertArrayHasKey('{DAV:}acl',$returnedProperties[200]); + $this->assertInstanceOf('Sabre_DAVACL_Property_ACL', $returnedProperties[200]['{DAV:}acl']); + + } + + function testAlternateUriSet() { + + $tree = array( + new Sabre_DAV_SimpleDirectory('principals', array( + $principal = new Sabre_DAVACL_MockPrincipal('user','principals/user'), + )), + ); + + $fakeServer = new Sabre_DAV_Server($tree); + //$plugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(),'realm'); + //$fakeServer->addPlugin($plugin); + $plugin = new Sabre_DAVACL_Plugin(); + $fakeServer->addPlugin($plugin); + + $requestedProperties = array( + '{DAV:}alternate-URI-set', + ); + $returnedProperties = array(); + + $result = $plugin->beforeGetProperties('principals/user',$principal,$requestedProperties,$returnedProperties); + + $this->assertNull($result); + + $this->assertTrue(isset($returnedProperties[200])); + $this->assertTrue(isset($returnedProperties[200]['{DAV:}alternate-URI-set'])); + $this->assertInstanceOf('Sabre_DAV_Property_HrefList', $returnedProperties[200]['{DAV:}alternate-URI-set']); + + $this->assertEquals(array(), $returnedProperties[200]['{DAV:}alternate-URI-set']->getHrefs()); + + } + + function testPrincipalURL() { + + $tree = array( + new Sabre_DAV_SimpleDirectory('principals', array( + $principal = new Sabre_DAVACL_MockPrincipal('user','principals/user'), + )), + ); + + $fakeServer = new Sabre_DAV_Server($tree); + //$plugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(),'realm'); + //$fakeServer->addPlugin($plugin); + $plugin = new Sabre_DAVACL_Plugin(); + $fakeServer->addPlugin($plugin); + + $requestedProperties = array( + '{DAV:}principal-URL', + ); + $returnedProperties = array(); + + $result = $plugin->beforeGetProperties('principals/user',$principal,$requestedProperties,$returnedProperties); + + $this->assertNull($result); + + $this->assertTrue(isset($returnedProperties[200])); + $this->assertTrue(isset($returnedProperties[200]['{DAV:}principal-URL'])); + $this->assertInstanceOf('Sabre_DAV_Property_Href', $returnedProperties[200]['{DAV:}principal-URL']); + + $this->assertEquals('principals/user/', $returnedProperties[200]['{DAV:}principal-URL']->getHref()); + + } + + function testGroupMemberSet() { + + $tree = array( + new Sabre_DAV_SimpleDirectory('principals', array( + $principal = new Sabre_DAVACL_MockPrincipal('user','principals/user'), + )), + ); + + $fakeServer = new Sabre_DAV_Server($tree); + //$plugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(),'realm'); + //$fakeServer->addPlugin($plugin); + $plugin = new Sabre_DAVACL_Plugin(); + $fakeServer->addPlugin($plugin); + + $requestedProperties = array( + '{DAV:}group-member-set', + ); + $returnedProperties = array(); + + $result = $plugin->beforeGetProperties('principals/user',$principal,$requestedProperties,$returnedProperties); + + $this->assertNull($result); + + $this->assertTrue(isset($returnedProperties[200])); + $this->assertTrue(isset($returnedProperties[200]['{DAV:}group-member-set'])); + $this->assertInstanceOf('Sabre_DAV_Property_HrefList', $returnedProperties[200]['{DAV:}group-member-set']); + + $this->assertEquals(array(), $returnedProperties[200]['{DAV:}group-member-set']->getHrefs()); + + } + + function testGroupMemberShip() { + + $tree = array( + new Sabre_DAV_SimpleDirectory('principals', array( + $principal = new Sabre_DAVACL_MockPrincipal('user','principals/user'), + )), + ); + + $fakeServer = new Sabre_DAV_Server($tree); + //$plugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(),'realm'); + //$fakeServer->addPlugin($plugin); + $plugin = new Sabre_DAVACL_Plugin(); + $fakeServer->addPlugin($plugin); + + $requestedProperties = array( + '{DAV:}group-membership', + ); + $returnedProperties = array(); + + $result = $plugin->beforeGetProperties('principals/user',$principal,$requestedProperties,$returnedProperties); + + $this->assertNull($result); + + $this->assertTrue(isset($returnedProperties[200])); + $this->assertTrue(isset($returnedProperties[200]['{DAV:}group-membership'])); + $this->assertInstanceOf('Sabre_DAV_Property_HrefList', $returnedProperties[200]['{DAV:}group-membership']); + + $this->assertEquals(array(), $returnedProperties[200]['{DAV:}group-membership']->getHrefs()); + + } + + function testGetDisplayName() { + + $tree = array( + new Sabre_DAV_SimpleDirectory('principals', array( + $principal = new Sabre_DAVACL_MockPrincipal('user','principals/user'), + )), + ); + + $fakeServer = new Sabre_DAV_Server($tree); + //$plugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(),'realm'); + //$fakeServer->addPlugin($plugin); + $plugin = new Sabre_DAVACL_Plugin(); + $fakeServer->addPlugin($plugin); + + $requestedProperties = array( + '{DAV:}displayname', + ); + $returnedProperties = array(); + + $result = $plugin->beforeGetProperties('principals/user',$principal,$requestedProperties,$returnedProperties); + + $this->assertNull($result); + + $this->assertTrue(isset($returnedProperties[200])); + $this->assertTrue(isset($returnedProperties[200]['{DAV:}displayname'])); + + $this->assertEquals('user', $returnedProperties[200]['{DAV:}displayname']); + + } +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php new file mode 100755 index 0000000..e723ed5 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php @@ -0,0 +1,123 @@ +addPlugin(new Sabre_DAVACL_Plugin()); + + $result = $server->updateProperties('foo', array( + '{DAV:}foo' => 'bar', + )); + + $expected = array( + 'href' => 'foo', + '403' => array( + '{DAV:}foo' => null, + ), + ); + + $this->assertEquals($expected, $result); + + } + + public function testRemoveGroupMembers() { + + $tree = array( + new Sabre_DAVACL_MockPrincipal('foo','foo'), + ); + $server = new Sabre_DAV_Server($tree); + $server->addPlugin(new Sabre_DAVACL_Plugin()); + + $result = $server->updateProperties('foo', array( + '{DAV:}group-member-set' => null, + )); + + $expected = array( + 'href' => 'foo', + '200' => array( + '{DAV:}group-member-set' => null, + ), + ); + + $this->assertEquals($expected, $result); + $this->assertEquals(array(),$tree[0]->getGroupMemberSet()); + + } + + public function testSetGroupMembers() { + + $tree = array( + new Sabre_DAVACL_MockPrincipal('foo','foo'), + ); + $server = new Sabre_DAV_Server($tree); + $server->addPlugin(new Sabre_DAVACL_Plugin()); + + $result = $server->updateProperties('foo', array( + '{DAV:}group-member-set' => new Sabre_DAV_Property_HrefList(array('bar','baz')), + )); + + $expected = array( + 'href' => 'foo', + '200' => array( + '{DAV:}group-member-set' => null, + ), + ); + + $this->assertEquals($expected, $result); + $this->assertEquals(array('bar','baz'),$tree[0]->getGroupMemberSet()); + + } + + /** + * @expectedException sabre_DAV_Exception + */ + public function testSetBadValue() { + + $tree = array( + new Sabre_DAVACL_MockPrincipal('foo','foo'), + ); + $server = new Sabre_DAV_Server($tree); + $server->addPlugin(new Sabre_DAVACL_Plugin()); + + $result = $server->updateProperties('foo', array( + '{DAV:}group-member-set' => new StdClass(), + )); + + } + + public function testSetBadNode() { + + $tree = array( + new Sabre_DAV_SimpleDirectory('foo'), + ); + $server = new Sabre_DAV_Server($tree); + $server->addPlugin(new Sabre_DAVACL_Plugin()); + + $result = $server->updateProperties('foo', array( + '{DAV:}group-member-set' => new Sabre_DAV_Property_HrefList(array('bar','baz')), + '{DAV:}bar' => 'baz', + )); + + $expected = array( + 'href' => 'foo', + '403' => array( + '{DAV:}group-member-set' => null, + ), + '424' => array( + '{DAV:}bar' => null, + ), + ); + + $this->assertEquals($expected, $result); + + } +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php new file mode 100755 index 0000000..165b285 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php @@ -0,0 +1,100 @@ +getPDO(); + $backend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo); + $this->assertTrue($backend instanceof Sabre_DAVACL_PrincipalBackend_PDO); + + } + + /** + * @depends testConstruct + */ + function testGetPrincipalsByPrefix() { + + $pdo = $this->getPDO(); + $backend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo); + + $expected = array( + array( + 'uri' => 'principals/user', + '{http://sabredav.org/ns}email-address' => 'user@example.org', + '{DAV:}displayname' => 'User', + ), + array( + 'uri' => 'principals/group', + '{http://sabredav.org/ns}email-address' => 'group@example.org', + '{DAV:}displayname' => 'Group', + ), + ); + + $this->assertEquals($expected, $backend->getPrincipalsByPrefix('principals')); + $this->assertEquals(array(), $backend->getPrincipalsByPrefix('foo')); + + } + + /** + * @depends testConstruct + */ + function testGetPrincipalByPath() { + + $pdo = $this->getPDO(); + $backend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo); + + $expected = array( + 'id' => 1, + 'uri' => 'principals/user', + '{http://sabredav.org/ns}email-address' => 'user@example.org', + '{DAV:}displayname' => 'User', + ); + + $this->assertEquals($expected, $backend->getPrincipalByPath('principals/user')); + $this->assertEquals(null, $backend->getPrincipalByPath('foo')); + + } + + function testGetGroupMemberSet() { + + $pdo = $this->getPDO(); + $backend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo); + $expected = array('principals/user'); + + $this->assertEquals($expected,$backend->getGroupMemberSet('principals/group')); + + } + + function testGetGroupMembership() { + + $pdo = $this->getPDO(); + $backend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo); + $expected = array('principals/group'); + + $this->assertEquals($expected,$backend->getGroupMembership('principals/user')); + + } + + function testSetGroupMemberSet() { + + $pdo = $this->getPDO(); + + // Start situation + $backend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo); + $this->assertEquals(array('principals/user'), $backend->getGroupMemberSet('principals/group')); + + // Removing all principals + $backend->setGroupMemberSet('principals/group', array()); + $this->assertEquals(array(), $backend->getGroupMemberSet('principals/group')); + + // Adding principals again + $backend->setGroupMemberSet('principals/group', array('principals/user')); + $this->assertEquals(array('principals/user'), $backend->getGroupMemberSet('principals/group')); + + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php new file mode 100755 index 0000000..aed7c3e --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php @@ -0,0 +1,38 @@ +markTestSkipped('MySQL driver is not available, or not properly configured'); + $pdo = Sabre_TestUtil::getMySQLDB(); + if (!$pdo) $this->markTestSkipped('Could not connect to MySQL database'); + $pdo->query("DROP TABLE IF EXISTS principals"); + $pdo->query(" +create table principals ( + id integer unsigned not null primary key auto_increment, + uri varchar(50), + email varchar(80), + displayname VARCHAR(80), + unique(uri) +);"); + + $pdo->query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/user','user@example.org','User')"); + $pdo->query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/group','group@example.org','Group')"); + $pdo->query("DROP TABLE IF EXISTS groupmembers"); + $pdo->query("CREATE TABLE groupmembers ( + id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + principal_id INTEGER UNSIGNED NOT NULL, + member_id INTEGER UNSIGNED NOT NULL, + UNIQUE(principal_id, member_id) + );"); + + $pdo->query("INSERT INTO groupmembers (principal_id,member_id) VALUES (2,1)"); + + return $pdo; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php new file mode 100755 index 0000000..09a38de --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php @@ -0,0 +1,36 @@ +markTestSkipped('SQLite driver is not available'); + $pdo = new PDO('sqlite:'.SABRE_TEMPDIR.'/pdobackend'); + $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); + $pdo->query('CREATE TABLE principals (id INTEGER PRIMARY KEY ASC, uri TEXT, email VARCHAR(80), displayname VARCHAR(80))'); + $pdo->query('INSERT INTO principals VALUES (1, "principals/user","user@example.org","User")'); + $pdo->query('INSERT INTO principals VALUES (2, "principals/group","group@example.org","Group")'); + + $pdo->query("CREATE TABLE groupmembers ( + id INTEGER PRIMARY KEY ASC, + principal_id INT, + member_id INT, + UNIQUE(principal_id, member_id) + );"); + + $pdo->query("INSERT INTO groupmembers (principal_id,member_id) VALUES (2,1)"); + + return $pdo; + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalCollectionTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalCollectionTest.php new file mode 100755 index 0000000..529d479 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalCollectionTest.php @@ -0,0 +1,48 @@ +assertTrue($pc instanceof Sabre_DAVACL_PrincipalCollection); + + $this->assertEquals('principals',$pc->getName()); + + } + + /** + * @depends testBasic + */ + public function testGetChildren() { + + $backend = new Sabre_DAVACL_MockPrincipalBackend(); + $pc = new Sabre_DAVACL_PrincipalCollection($backend); + + $children = $pc->getChildren(); + $this->assertTrue(is_array($children)); + + foreach($children as $child) { + $this->assertTrue($child instanceof Sabre_DAVACL_IPrincipal); + } + + } + + /** + * @depends testBasic + * @expectedException Sabre_DAV_Exception_MethodNotAllowed + */ + public function testGetChildrenDisable() { + + $backend = new Sabre_DAVACL_MockPrincipalBackend(); + $pc = new Sabre_DAVACL_PrincipalCollection($backend); + $pc->disableListing = true; + + $children = $pc->getChildren(); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php new file mode 100755 index 0000000..9ae5d86 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php @@ -0,0 +1,182 @@ +addChild($principals); + + $fakeServer = new Sabre_DAV_Server(new Sabre_DAV_ObjectTree($dir)); + $fakeServer->httpResponse = new Sabre_HTTP_ResponseMock(); + $fakeServer->debugExceptions = true; + $plugin = new Sabre_DAVACL_MockPlugin($backend,'realm'); + $plugin->allowAccessToNodesWithoutACL = true; + + $this->assertTrue($plugin instanceof Sabre_DAVACL_Plugin); + $fakeServer->addPlugin($plugin); + $this->assertEquals($plugin, $fakeServer->getPlugin('acl')); + + return $fakeServer; + + } + + function testDepth1() { + + $xml = ' + + + + + + user + + + + + +'; + + $serverVars = array( + 'REQUEST_METHOD' => 'REPORT', + 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/principals', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody($xml); + + $server = $this->getServer(); + $server->httpRequest = $request; + + $server->exec(); + + $this->assertEquals('HTTP/1.1 400 Bad request', $server->httpResponse->status); + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ), $server->httpResponse->headers); + + } + + + function testUnknownSearchField() { + + $xml = ' + + + + + + user + + + + + +'; + + $serverVars = array( + 'REQUEST_METHOD' => 'REPORT', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/principals', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody($xml); + + $server = $this->getServer(); + $server->httpRequest = $request; + + $server->exec(); + + $this->assertEquals('HTTP/1.1 207 Multi-Status', $server->httpResponse->status); + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ), $server->httpResponse->headers); + + } + + function testCorrect() { + + $xml = ' + + + + + + user + + + + + +'; + + $serverVars = array( + 'REQUEST_METHOD' => 'REPORT', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/principals', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody($xml); + + $server = $this->getServer(); + $server->httpRequest = $request; + + $server->exec(); + + $this->assertEquals('HTTP/1.1 207 Multi-Status', $server->httpResponse->status, $server->httpResponse->body); + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ), $server->httpResponse->headers); + + + $check = array( + '/d:multistatus', + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 2, + '/d:multistatus/d:response/d:propstat/d:prop' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 1, + '/d:multistatus/d:response/d:propstat/d:status' => 2, + ); + + $xml = simplexml_load_string($server->httpResponse->body); + $xml->registerXPathNamespace('d','DAV:'); + foreach($check as $v1=>$v2) { + + $xpath = is_int($v1)?$v2:$v1; + + $result = $xml->xpath($xpath); + + $count = 1; + if (!is_int($v1)) $count = $v2; + + $this->assertEquals($count,count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); + + } + + } +} + +class Sabre_DAVACL_MockPlugin extends Sabre_DAVACL_Plugin { + + function getCurrentUserPrivilegeSet($node) { + + return array( + '{DAV:}read', + '{DAV:}write', + ); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php new file mode 100755 index 0000000..7d5a7a9 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php @@ -0,0 +1,128 @@ +addChild($principals); + + $fakeServer = new Sabre_DAV_Server(new Sabre_DAV_ObjectTree($dir)); + $fakeServer->httpResponse = new Sabre_HTTP_ResponseMock(); + $plugin = new Sabre_DAVACL_Plugin($backend,'realm'); + $this->assertTrue($plugin instanceof Sabre_DAVACL_Plugin); + $fakeServer->addPlugin($plugin); + $this->assertEquals($plugin, $fakeServer->getPlugin('acl')); + + return $fakeServer; + + } + + function testDepth1() { + + $xml = ' +'; + + $serverVars = array( + 'REQUEST_METHOD' => 'REPORT', + 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/principals', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody($xml); + + $server = $this->getServer(); + $server->httpRequest = $request; + + $server->exec(); + + $this->assertEquals('HTTP/1.1 400 Bad request', $server->httpResponse->status); + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ), $server->httpResponse->headers); + + } + + function testDepthIncorrectXML() { + + $xml = ' +'; + + $serverVars = array( + 'REQUEST_METHOD' => 'REPORT', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/principals', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody($xml); + + $server = $this->getServer(); + $server->httpRequest = $request; + + $server->exec(); + + $this->assertEquals('HTTP/1.1 400 Bad request', $server->httpResponse->status, $server->httpResponse->body); + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ), $server->httpResponse->headers); + + } + + function testCorrect() { + + $xml = ' +'; + + $serverVars = array( + 'REQUEST_METHOD' => 'REPORT', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/principals', + ); + + $request = new Sabre_HTTP_Request($serverVars); + $request->setBody($xml); + + $server = $this->getServer(); + $server->httpRequest = $request; + + $server->exec(); + + $this->assertEquals('HTTP/1.1 200 OK', $server->httpResponse->status, $server->httpResponse->body); + $this->assertEquals(array( + 'Content-Type' => 'application/xml; charset=utf-8', + ), $server->httpResponse->headers); + + + $check = array( + '/d:principal-search-property-set', + '/d:principal-search-property-set/d:principal-search-property', + '/d:principal-search-property-set/d:principal-search-property/d:prop', + '/d:principal-search-property-set/d:principal-search-property/d:prop/d:displayname', + '/d:principal-search-property-set/d:principal-search-property/d:description', + ); + + $xml = simplexml_load_string($server->httpResponse->body); + $xml->registerXPathNamespace('d','DAV:'); + foreach($check as $v1=>$v2) { + + $xpath = is_int($v1)?$v2:$v1; + + $result = $xml->xpath($xpath); + + $count = 1; + if (!is_int($v1)) $count = $v2; + + $this->assertEquals($count,count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); + + } + + } +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalTest.php new file mode 100755 index 0000000..0bbfe98 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/PrincipalTest.php @@ -0,0 +1,192 @@ + 'principals/admin')); + $this->assertTrue($principal instanceof Sabre_DAVACL_Principal); + + } + + /** + * @expectedException Sabre_DAV_Exception + */ + public function testConstructNoUri() { + + $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); + $principal = new Sabre_DAVACL_Principal($principalBackend, array()); + + } + + public function testGetName() { + + $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); + $principal = new Sabre_DAVACL_Principal($principalBackend, array('uri' => 'principals/admin')); + $this->assertEquals('admin',$principal->getName()); + + } + + public function testGetDisplayName() { + + $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); + $principal = new Sabre_DAVACL_Principal($principalBackend, array('uri' => 'principals/admin')); + $this->assertEquals('admin',$principal->getDisplayname()); + + $principal = new Sabre_DAVACL_Principal($principalBackend, array( + 'uri' => 'principals/admin', + '{DAV:}displayname' => 'Mr. Admin' + )); + $this->assertEquals('Mr. Admin',$principal->getDisplayname()); + + } + + public function testGetProperties() { + + $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); + $principal = new Sabre_DAVACL_Principal($principalBackend, array( + 'uri' => 'principals/admin', + '{DAV:}displayname' => 'Mr. Admin', + '{http://www.example.org/custom}custom' => 'Custom', + '{http://sabredav.org/ns}email-address' => 'admin@example.org', + )); + + $keys = array( + '{DAV:}displayname', + '{http://www.example.org/custom}custom', + '{http://sabredav.org/ns}email-address', + ); + $props = $principal->getProperties($keys); + + foreach($keys as $key) $this->assertArrayHasKey($key,$props); + + $this->assertEquals('Mr. Admin',$props['{DAV:}displayname']); + + $this->assertEquals('admin@example.org', $props['{http://sabredav.org/ns}email-address']); + } + + public function testUpdateProperties() { + + $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); + $principal = new Sabre_DAVACL_Principal($principalBackend, array('uri' => 'principals/admin')); + $result = $principal->updateProperties(array('{DAV:}yourmom'=>'test')); + $this->assertEquals(false,$result); + + } + + public function testGetPrincipalUrl() { + + $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); + $principal = new Sabre_DAVACL_Principal($principalBackend, array('uri' => 'principals/admin')); + $this->assertEquals('principals/admin',$principal->getPrincipalUrl()); + + } + + public function testGetAlternateUriSet() { + + $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); + $principal = new Sabre_DAVACL_Principal($principalBackend, array( + 'uri' => 'principals/admin', + '{DAV:}displayname' => 'Mr. Admin', + '{http://www.example.org/custom}custom' => 'Custom', + '{http://sabredav.org/ns}email-address' => 'admin@example.org', + '{DAV:}alternate-URI-set' => array( + 'mailto:admin+1@example.org', + 'mailto:admin+2@example.org', + 'mailto:admin@example.org', + ), + )); + + $expected = array( + 'mailto:admin+1@example.org', + 'mailto:admin+2@example.org', + 'mailto:admin@example.org', + ); + + $this->assertEquals($expected,$principal->getAlternateUriSet()); + + } + public function testGetAlternateUriSetEmpty() { + + $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); + $principal = new Sabre_DAVACL_Principal($principalBackend, array( + 'uri' => 'principals/admin', + )); + + $expected = array(); + + $this->assertEquals($expected,$principal->getAlternateUriSet()); + + } + + public function testGetGroupMemberSet() { + + $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); + $principal = new Sabre_DAVACL_Principal($principalBackend, array('uri' => 'principals/admin')); + $this->assertEquals(array(),$principal->getGroupMemberSet()); + + } + public function testGetGroupMembership() { + + $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); + $principal = new Sabre_DAVACL_Principal($principalBackend, array('uri' => 'principals/admin')); + $this->assertEquals(array(),$principal->getGroupMembership()); + + } + + public function testSetGroupMemberSet() { + + $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); + $principal = new Sabre_DAVACL_Principal($principalBackend, array('uri' => 'principals/admin')); + $principal->setGroupMemberSet(array('principals/foo')); + + $this->assertEquals(array( + 'principals/admin' => array('principals/foo'), + ), $principalBackend->groupMembers); + + } + + public function testGetOwner() { + + $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); + $principal = new Sabre_DAVACL_Principal($principalBackend, array('uri' => 'principals/admin')); + $this->assertEquals('principals/admin',$principal->getOwner()); + + } + + public function testGetGroup() { + + $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); + $principal = new Sabre_DAVACL_Principal($principalBackend, array('uri' => 'principals/admin')); + $this->assertNull($principal->getGroup()); + + } + + public function testGetACl() { + + $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); + $principal = new Sabre_DAVACL_Principal($principalBackend, array('uri' => 'principals/admin')); + $this->assertEquals(array( + array( + 'privilege' => '{DAV:}read', + 'principal' => 'principals/admin', + 'protected' => true, + ) + ),$principal->getACL()); + + } + + /** + * @expectedException Sabre_DAV_Exception_MethodNotAllowed + */ + public function testSetACl() { + + $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); + $principal = new Sabre_DAVACL_Principal($principalBackend, array('uri' => 'principals/admin')); + $principal->setACL(array()); + + } +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Property/ACLTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Property/ACLTest.php new file mode 100755 index 0000000..e630f60 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Property/ACLTest.php @@ -0,0 +1,223 @@ +createElementNS('DAV:','d:root'); + + $dom->appendChild($root); + + $acl = new Sabre_DAVACL_Property_Acl(array()); + $acl->serialize(new Sabre_DAV_Server(), $root); + + $xml = $dom->saveXML(); + $expected = ' + +'; + $this->assertEquals($expected, $xml); + + } + + function testSerialize() { + + $dom = new DOMDocument('1.0'); + $root = $dom->createElementNS('DAV:','d:root'); + + $dom->appendChild($root); + + $privileges = array( + array( + 'principal' => 'principals/evert', + 'privilege' => '{DAV:}write', + 'uri' => 'articles', + ), + array( + 'principal' => 'principals/foo', + 'privilege' => '{DAV:}read', + 'uri' => 'articles', + 'protected' => true, + ), + ); + + $acl = new Sabre_DAVACL_Property_Acl($privileges); + $acl->serialize(new Sabre_DAV_Server(), $root); + + $dom->formatOutput = true; + + $xml = $dom->saveXML(); + $expected = ' + + + + /principals/evert/ + + + + + + + + + + /principals/foo/ + + + + + + + + + +'; + $this->assertEquals($expected, $xml); + + } + + function testUnserialize() { + + $source = ' + + + + /principals/evert/ + + + + + + + + + + /principals/foo/ + + + + + + + + + +'; + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($source); + $result = Sabre_DAVACL_Property_Acl::unserialize($dom->firstChild); + + $this->assertInstanceOf('Sabre_DAVACL_Property_Acl', $result); + + $expected = array( + array( + 'principal' => '/principals/evert/', + 'protected' => false, + 'privilege' => '{DAV:}write', + ), + array( + 'principal' => '/principals/foo/', + 'protected' => true, + 'privilege' => '{DAV:}read', + ), + ); + + $this->assertEquals($expected, $result->getPrivileges()); + + + } + + /** + * @expectedException Sabre_DAV_Exception_BadRequest + */ + function testUnserializeNoPrincipal() { + + $source = ' + + + + + + + + + +'; + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($source); + Sabre_DAVACL_Property_Acl::unserialize($dom->firstChild); + + } + + /** + * @expectedException Sabre_DAV_Exception_NotImplemented + */ + function testUnserializeUnsupportedPrincipal() { + + $source = ' + + + + + + + + + + +'; + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($source); + Sabre_DAVACL_Property_Acl::unserialize($dom->firstChild); + + } + + /** + * @expectedException Sabre_DAV_Exception_NotImplemented + */ + function testUnserializeDeny() { + + $source = ' + + + + + + + + /principals/evert + + +'; + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($source); + Sabre_DAVACL_Property_Acl::unserialize($dom->firstChild); + } + + /** + * @expectedException Sabre_DAV_Exception_BadRequest + */ + function testUnserializeMissingPriv() { + + $source = ' + + + + + + /principals/evert + + +'; + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($source); + Sabre_DAVACL_Property_Acl::unserialize($dom->firstChild); + + } +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Property/CurrentUserPrivilegeSetTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Property/CurrentUserPrivilegeSetTest.php new file mode 100755 index 0000000..2c3f720 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Property/CurrentUserPrivilegeSetTest.php @@ -0,0 +1,41 @@ +createElementNS('DAV:','d:root'); + $dom->appendChild($root); + + $prop->serialize($server, $root); + + $xpaths = array( + '/d:root' => 1, + '/d:root/d:privilege' => 2, + '/d:root/d:privilege/d:read' => 1, + '/d:root/d:privilege/d:write' => 1, + ); + + // Reloading because PHP DOM sucks + $dom2 = new DOMDocument('1.0', 'utf-8'); + $dom2->loadXML($dom->saveXML()); + + $dxpath = new DOMXPath($dom2); + $dxpath->registerNamespace('d','DAV:'); + foreach($xpaths as $xpath=>$count) { + + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); + + } + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Property/PrincipalTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Property/PrincipalTest.php new file mode 100755 index 0000000..5ac7d6a --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Property/PrincipalTest.php @@ -0,0 +1,176 @@ +assertEquals(Sabre_DAVACL_Property_Principal::UNAUTHENTICATED, $principal->getType()); + $this->assertNull($principal->getHref()); + + $principal = new Sabre_DAVACL_Property_Principal(Sabre_DAVACL_Property_Principal::AUTHENTICATED); + $this->assertEquals(Sabre_DAVACL_Property_Principal::AUTHENTICATED, $principal->getType()); + $this->assertNull($principal->getHref()); + + $principal = new Sabre_DAVACL_Property_Principal(Sabre_DAVACL_Property_Principal::HREF,'admin'); + $this->assertEquals(Sabre_DAVACL_Property_Principal::HREF, $principal->getType()); + $this->assertEquals('admin',$principal->getHref()); + + } + + /** + * @depends testSimple + * @expectedException Sabre_DAV_Exception + */ + function testNoHref() { + + $principal = new Sabre_DAVACL_Property_Principal(Sabre_DAVACL_Property_Principal::HREF); + + } + + /** + * @depends testSimple + */ + function testSerializeUnAuthenticated() { + + $prin = new Sabre_DAVACL_Property_Principal(Sabre_DAVACL_Property_Principal::UNAUTHENTICATED); + + $doc = new DOMDocument(); + $root = $doc->createElement('d:principal'); + $root->setAttribute('xmlns:d','DAV:'); + + $doc->appendChild($root); + $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('rootdir')); + $server = new Sabre_DAV_Server($objectTree); + + $prin->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' +' . +'' . +' +', $xml); + + } + + + /** + * @depends testSerializeUnAuthenticated + */ + function testSerializeAuthenticated() { + + $prin = new Sabre_DAVACL_Property_Principal(Sabre_DAVACL_Property_Principal::AUTHENTICATED); + + $doc = new DOMDocument(); + $root = $doc->createElement('d:principal'); + $root->setAttribute('xmlns:d','DAV:'); + + $doc->appendChild($root); + $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('rootdir')); + $server = new Sabre_DAV_Server($objectTree); + + $prin->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' +' . +'' . +' +', $xml); + + } + + + /** + * @depends testSerializeUnAuthenticated + */ + function testSerializeHref() { + + $prin = new Sabre_DAVACL_Property_Principal(Sabre_DAVACL_Property_Principal::HREF,'principals/admin'); + + $doc = new DOMDocument(); + $root = $doc->createElement('d:principal'); + $root->setAttribute('xmlns:d','DAV:'); + + $doc->appendChild($root); + $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('rootdir')); + $server = new Sabre_DAV_Server($objectTree); + + $prin->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' +' . +'/principals/admin' . +' +', $xml); + + } + + function testUnserializeHref() { + + $xml = ' +' . +'/principals/admin' . +''; + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml); + + $principal = Sabre_DAVACL_Property_Principal::unserialize($dom->firstChild); + $this->assertEquals(Sabre_DAVACL_Property_Principal::HREF, $principal->getType()); + $this->assertEquals('/principals/admin', $principal->getHref()); + + } + + function testUnserializeAuthenticated() { + + $xml = ' +' . +' ' . +''; + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml); + + $principal = Sabre_DAVACL_Property_Principal::unserialize($dom->firstChild); + $this->assertEquals(Sabre_DAVACL_Property_Principal::AUTHENTICATED, $principal->getType()); + + } + + function testUnserializeUnauthenticated() { + + $xml = ' +' . +' ' . +''; + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml); + + $principal = Sabre_DAVACL_Property_Principal::unserialize($dom->firstChild); + $this->assertEquals(Sabre_DAVACL_Property_Principal::UNAUTHENTICATED, $principal->getType()); + + } + + /** + * @expectedException Sabre_DAV_Exception_BadRequest + */ + function testUnserializeUnknown() { + + $xml = ' +' . +' ' . +''; + + $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml); + + Sabre_DAVACL_Property_Principal::unserialize($dom->firstChild); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Property/SupportedPrivilegeSetTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Property/SupportedPrivilegeSetTest.php new file mode 100755 index 0000000..195602d --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/Property/SupportedPrivilegeSetTest.php @@ -0,0 +1,99 @@ + '{DAV:}all', + )); + + } + + + /** + * @depends testSimple + */ + function testSerializeSimple() { + + $prop = new Sabre_DAVACL_Property_SupportedPrivilegeSet(array( + 'privilege' => '{DAV:}all', + )); + + $doc = new DOMDocument(); + $root = $doc->createElementNS('DAV:', 'd:supported-privilege-set'); + + $doc->appendChild($root); + + $server = new Sabre_DAV_Server(); + $prop->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' +' . +'' . +'' . +'' . +'' . +'' . +' +', $xml); + + } + + /** + * @depends testSimple + */ + function testSerializeAggregate() { + + $prop = new Sabre_DAVACL_Property_SupportedPrivilegeSet(array( + 'privilege' => '{DAV:}all', + 'abstract' => true, + 'aggregates' => array( + array( + 'privilege' => '{DAV:}read', + ), + array( + 'privilege' => '{DAV:}write', + 'description' => 'booh', + ), + ), + )); + + $doc = new DOMDocument(); + $root = $doc->createElementNS('DAV:', 'd:supported-privilege-set'); + + $doc->appendChild($root); + + $server = new Sabre_DAV_Server(); + $prop->serialize($server, $root); + + $xml = $doc->saveXML(); + + $this->assertEquals( +' +' . +'' . +'' . +'' . +'' . +'' . +'' . +'' . +'' . +'' . +'' . +'' . +'' . +'' . +'' . +'booh' . +'' . +'' . +' +', $xml); + + } +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/SimplePluginTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/SimplePluginTest.php new file mode 100755 index 0000000..a492727 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/SimplePluginTest.php @@ -0,0 +1,270 @@ +assertEquals('acl',$aclPlugin->getPluginName()); + $this->assertEquals(array('access-control'), $aclPlugin->getFeatures()); + + $this->assertEquals( + array( + '{DAV:}expand-property', + '{DAV:}principal-property-search', + '{DAV:}principal-search-property-set' + ), + $aclPlugin->getSupportedReportSet('')); + + $this->assertEquals(array('ACL'), $aclPlugin->getMethods('')); + + } + + function testGetFlatPrivilegeSet() { + + $expected = array( + '{DAV:}all' => array( + 'privilege' => '{DAV:}all', + 'abstract' => true, + 'aggregates' => array( + '{DAV:}read', + '{DAV:}write', + ), + 'concrete' => null, + ), + '{DAV:}read' => array( + 'privilege' => '{DAV:}read', + 'abstract' => false, + 'aggregates' => array( + '{DAV:}read-acl', + '{DAV:}read-current-user-privilege-set', + ), + 'concrete' => '{DAV:}read', + ), + '{DAV:}read-acl' => array( + 'privilege' => '{DAV:}read-acl', + 'abstract' => true, + 'aggregates' => array(), + 'concrete' => '{DAV:}read', + ), + '{DAV:}read-current-user-privilege-set' => array( + 'privilege' => '{DAV:}read-current-user-privilege-set', + 'abstract' => true, + 'aggregates' => array(), + 'concrete' => '{DAV:}read', + ), + '{DAV:}write' => array( + 'privilege' => '{DAV:}write', + 'abstract' => false, + 'aggregates' => array( + '{DAV:}write-acl', + '{DAV:}write-properties', + '{DAV:}write-content', + '{DAV:}bind', + '{DAV:}unbind', + '{DAV:}unlock', + ), + 'concrete' => '{DAV:}write', + ), + '{DAV:}write-acl' => array( + 'privilege' => '{DAV:}write-acl', + 'abstract' => true, + 'aggregates' => array(), + 'concrete' => '{DAV:}write', + ), + '{DAV:}write-properties' => array( + 'privilege' => '{DAV:}write-properties', + 'abstract' => true, + 'aggregates' => array(), + 'concrete' => '{DAV:}write', + ), + '{DAV:}write-content' => array( + 'privilege' => '{DAV:}write-content', + 'abstract' => true, + 'aggregates' => array(), + 'concrete' => '{DAV:}write', + ), + '{DAV:}unlock' => array( + 'privilege' => '{DAV:}unlock', + 'abstract' => true, + 'aggregates' => array(), + 'concrete' => '{DAV:}write', + ), + '{DAV:}bind' => array( + 'privilege' => '{DAV:}bind', + 'abstract' => true, + 'aggregates' => array(), + 'concrete' => '{DAV:}write', + ), + '{DAV:}unbind' => array( + 'privilege' => '{DAV:}unbind', + 'abstract' => true, + 'aggregates' => array(), + 'concrete' => '{DAV:}write', + ), + + ); + + $plugin = new Sabre_DAVACL_Plugin(); + $this->assertEquals($expected, $plugin->getFlatPrivilegeSet()); + + + } + + function testCurrentUserPrincipalsNotLoggedIn() { + + $acl = new Sabre_DAVACL_Plugin(); + $server = new Sabre_DAV_Server(); + $server->addPlugin($acl); + + $this->assertEquals(array(),$acl->getCurrentUserPrincipals()); + + } + + function testCurrentUserPrincipalsSimple() { + + $tree = array( + + new Sabre_DAV_SimpleDirectory('principals', array( + new Sabre_DAVACL_MockPrincipal('admin','principals/admin'), + )) + + ); + + $acl = new Sabre_DAVACL_Plugin(); + $server = new Sabre_DAV_Server($tree); + $server->addPlugin($acl); + + $auth = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(),'SabreDAV'); + $server->addPlugin($auth); + + //forcing login + $auth->beforeMethod('GET','/'); + + $this->assertEquals(array('principals/admin'),$acl->getCurrentUserPrincipals()); + + } + + function testCurrentUserPrincipalsGroups() { + + $tree = array( + + new Sabre_DAV_SimpleDirectory('principals', array( + new Sabre_DAVACL_MockPrincipal('admin','principals/admin',array('principals/administrators', 'principals/everyone')), + new Sabre_DAVACL_MockPrincipal('administrators','principals/administrators',array('principals/groups'), array('principals/admin')), + new Sabre_DAVACL_MockPrincipal('everyone','principals/everyone',array(), array('principals/admin')), + new Sabre_DAVACL_MockPrincipal('groups','principals/groups',array(), array('principals/administrators')), + )) + + ); + + $acl = new Sabre_DAVACL_Plugin(); + $server = new Sabre_DAV_Server($tree); + $server->addPlugin($acl); + + $auth = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(),'SabreDAV'); + $server->addPlugin($auth); + + //forcing login + $auth->beforeMethod('GET','/'); + + $expected = array( + 'principals/admin', + 'principals/administrators', + 'principals/everyone', + 'principals/groups', + ); + + $this->assertEquals($expected,$acl->getCurrentUserPrincipals()); + + } + + function testGetACL() { + + $acl = array( + array( + 'principal' => 'principals/admin', + 'privilege' => '{DAV:}read', + ), + array( + 'principal' => 'principals/admin', + 'privilege' => '{DAV:}write', + ), + ); + + + $tree = array( + new Sabre_DAVACL_MockACLNode('foo',$acl), + ); + + $server = new Sabre_DAV_Server($tree); + $aclPlugin = new Sabre_DAVACL_Plugin(); + $server->addPlugin($aclPlugin); + + $this->assertEquals($acl,$aclPlugin->getACL('foo')); + + } + + function testGetCurrentUserPrivilegeSet() { + + $acl = array( + array( + 'principal' => 'principals/admin', + 'privilege' => '{DAV:}read', + ), + array( + 'principal' => 'principals/user1', + 'privilege' => '{DAV:}read', + ), + array( + 'principal' => 'principals/admin', + 'privilege' => '{DAV:}write', + ), + ); + + + $tree = array( + new Sabre_DAVACL_MockACLNode('foo',$acl), + + new Sabre_DAV_SimpleDirectory('principals', array( + new Sabre_DAVACL_MockPrincipal('admin','principals/admin'), + )), + + ); + + $server = new Sabre_DAV_Server($tree); + $aclPlugin = new Sabre_DAVACL_Plugin(); + $server->addPlugin($aclPlugin); + + $auth = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(),'SabreDAV'); + $server->addPlugin($auth); + + //forcing login + $auth->beforeMethod('GET','/'); + + $expected = array( + '{DAV:}write', + '{DAV:}write-acl', + '{DAV:}write-properties', + '{DAV:}write-content', + '{DAV:}bind', + '{DAV:}unbind', + '{DAV:}unlock', + '{DAV:}read', + '{DAV:}read-acl', + '{DAV:}read-current-user-privilege-set', + ); + + $this->assertEquals($expected,$aclPlugin->getCurrentUserPrivilegeSet('foo')); + + } + +} + + + + diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/VersionTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/VersionTest.php new file mode 100755 index 0000000..216bd05 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/DAVACL/VersionTest.php @@ -0,0 +1,15 @@ +assertEquals(-1, version_compare('1.0.0',$v)); + + $s = Sabre_DAVACL_Version::STABILITY; + $this->assertTrue($s == 'alpha' || $s == 'beta' || $s =='stable'); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/AWSAuthTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/AWSAuthTest.php new file mode 100755 index 0000000..38d9a62 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/AWSAuthTest.php @@ -0,0 +1,237 @@ +response = new Sabre_HTTP_ResponseMock(); + $this->auth = new Sabre_HTTP_AWSAuth(); + $this->auth->setRealm(self::REALM); + $this->auth->setHTTPResponse($this->response); + + } + + public function testNoHeader() { + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'GET', + )); + + $this->auth->setHTTPRequest($request); + + $result = $this->auth->init(); + + $this->assertFalse($result,'No AWS Authorization header was supplied, so we should have gotten false'); + $this->assertEquals(Sabre_HTTP_AWSAuth::ERR_NOAWSHEADER,$this->auth->errorCode); + + } + + public function testIncorrectContentMD5() { + + $accessKey = 'accessKey'; + $secretKey = 'secretKey'; + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'GET', + 'HTTP_AUTHORIZATION' => "AWS $accessKey:sig", + 'HTTP_CONTENT_MD5' => 'garbage', + 'REQUEST_URI' => '/', + )); + + $this->auth->setHTTPRequest($request); + $this->auth->init(); + $result = $this->auth->validate($secretKey); + + $this->assertFalse($result); + $this->assertEquals(Sabre_HTTP_AWSAuth::ERR_MD5CHECKSUMWRONG,$this->auth->errorCode); + + } + + public function testNoDate() { + + $accessKey = 'accessKey'; + $secretKey = 'secretKey'; + $content = 'thisisthebody'; + $contentMD5 = base64_encode(md5($content,true)); + + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'POST', + 'HTTP_AUTHORIZATION' => "AWS $accessKey:sig", + 'HTTP_CONTENT_MD5' => $contentMD5, + )); + + $request->setBody($content); + + $this->auth->setHTTPRequest($request); + $this->auth->init(); + $result = $this->auth->validate($secretKey); + + $this->assertFalse($result); + $this->assertEquals(Sabre_HTTP_AWSAuth::ERR_INVALIDDATEFORMAT,$this->auth->errorCode); + + } + + public function testFutureDate() { + + $accessKey = 'accessKey'; + $secretKey = 'secretKey'; + $content = 'thisisthebody'; + $contentMD5 = base64_encode(md5($content,true)); + + $date = new DateTime('@' . (time() + (60*20))); + $date->setTimeZone(new DateTimeZone('GMT')); + $date = $date->format('D, d M Y H:i:s \\G\\M\\T'); + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'POST', + 'HTTP_AUTHORIZATION' => "AWS $accessKey:sig", + 'HTTP_CONTENT_MD5' => $contentMD5, + 'HTTP_DATE' => $date, + )); + + $request->setBody($content); + + $this->auth->setHTTPRequest($request); + $this->auth->init(); + $result = $this->auth->validate($secretKey); + + $this->assertFalse($result); + $this->assertEquals(Sabre_HTTP_AWSAuth::ERR_REQUESTTIMESKEWED,$this->auth->errorCode); + + } + + public function testPastDate() { + + $accessKey = 'accessKey'; + $secretKey = 'secretKey'; + $content = 'thisisthebody'; + $contentMD5 = base64_encode(md5($content,true)); + + $date = new DateTime('@' . (time() - (60*20))); + $date->setTimeZone(new DateTimeZone('GMT')); + $date = $date->format('D, d M Y H:i:s \\G\\M\\T'); + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'POST', + 'HTTP_AUTHORIZATION' => "AWS $accessKey:sig", + 'HTTP_CONTENT_MD5' => $contentMD5, + 'HTTP_X_AMZ_DATE' => $date, + )); + + $request->setBody($content); + + $this->auth->setHTTPRequest($request); + $this->auth->init(); + $result = $this->auth->validate($secretKey); + + $this->assertFalse($result); + $this->assertEquals(Sabre_HTTP_AWSAuth::ERR_REQUESTTIMESKEWED,$this->auth->errorCode); + + } + + public function testIncorrectSignature() { + + $accessKey = 'accessKey'; + $secretKey = 'secretKey'; + $content = 'thisisthebody'; + + $contentMD5 = base64_encode(md5($content,true)); + + $date = new DateTime('now'); + $date->setTimeZone(new DateTimeZone('GMT')); + $date = $date->format('D, d M Y H:i:s \\G\\M\\T'); + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'POST', + 'HTTP_AUTHORIZATION' => "AWS $accessKey:sig", + 'HTTP_CONTENT_MD5' => $contentMD5, + 'HTTP_X_AMZ_DATE' => $date, + 'REQUEST_URI' => '/', + )); + + $request->setBody($content); + + $this->auth->setHTTPRequest($request); + $this->auth->init(); + $result = $this->auth->validate($secretKey); + + $this->assertFalse($result); + $this->assertEquals(Sabre_HTTP_AWSAuth::ERR_INVALIDSIGNATURE,$this->auth->errorCode); + + } + + public function testValidRequest() { + + $accessKey = 'accessKey'; + $secretKey = 'secretKey'; + $content = 'thisisthebody'; + $contentMD5 = base64_encode(md5($content,true)); + + $date = new DateTime('now'); + $date->setTimeZone(new DateTimeZone('GMT')); + $date = $date->format('D, d M Y H:i:s \\G\\M\\T'); + + + $sig = base64_encode($this->hmacsha1($secretKey, + "POST\n$contentMD5\n\n$date\nx-amz-date:$date\n/evert" + )); + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'POST', + 'HTTP_AUTHORIZATION' => "AWS $accessKey:$sig", + 'HTTP_CONTENT_MD5' => $contentMD5, + 'HTTP_X_AMZ_DATE' => $date, + 'REQUEST_URI' => '/evert', + )); + + $request->setBody($content); + + $this->auth->setHTTPRequest($request); + $this->auth->init(); + $result = $this->auth->validate($secretKey); + + $this->assertTrue($result,'Signature did not validate, got errorcode ' . $this->auth->errorCode); + $this->assertEquals($accessKey,$this->auth->getAccessKey()); + + } + + public function test401() { + + $this->auth->requireLogin(); + $test = preg_match('/^AWS$/',$this->response->headers['WWW-Authenticate'],$matches); + $this->assertTrue($test==true,'The WWW-Authenticate response didn\'t match our pattern'); + + } + + /** + * Generates an HMAC-SHA1 signature + * + * @param string $key + * @param string $message + * @return string + */ + private function hmacsha1($key, $message) { + + $blocksize=64; + if (strlen($key)>$blocksize) + $key=pack('H*', sha1($key)); + $key=str_pad($key,$blocksize,chr(0x00)); + $ipad=str_repeat(chr(0x36),$blocksize); + $opad=str_repeat(chr(0x5c),$blocksize); + $hmac = pack('H*',sha1(($key^$opad).pack('H*',sha1(($key^$ipad).$message)))); + return $hmac; + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/BasicAuthTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/BasicAuthTest.php new file mode 100755 index 0000000..3e6e8fa --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/BasicAuthTest.php @@ -0,0 +1,89 @@ +response = new Sabre_HTTP_ResponseMock(); + $this->basicAuth = new Sabre_HTTP_BasicAuth(); + $this->basicAuth->setHTTPResponse($this->response); + + } + + function testGetUserPassApache() { + + $server = array( + 'PHP_AUTH_USER' => 'admin', + 'PHP_AUTH_PW' => '1234', + ); + + $request = new Sabre_HTTP_Request($server); + $this->basicAuth->setHTTPRequest($request); + + $userPass = $this->basicAuth->getUserPass(); + + $this->assertEquals( + array('admin','1234'), + $userPass, + 'We did not get the username and password we expected' + ); + + } + + function testGetUserPassIIS() { + + $server = array( + 'HTTP_AUTHORIZATION' => 'Basic ' . base64_encode('admin:1234'), + ); + + $request = new Sabre_HTTP_Request($server); + $this->basicAuth->setHTTPRequest($request); + + $userPass = $this->basicAuth->getUserPass(); + + $this->assertEquals( + array('admin','1234'), + $userPass, + 'We did not get the username and password we expected' + ); + + } + + function testGetUserPassNothing() { + + $this->assertEquals( + false, + $this->basicAuth->getUserPass() + ); + + } + + function testRequireLogin() { + + $this->basicAuth->requireLogin(); + $this->assertEquals('SabreDAV',$this->basicAuth->getRealm()); + $this->assertEquals( + 'HTTP/1.1 401 Unauthorized', + $this->response->status, + 'We expected a 401 status to be set' + ); + + $this->assertEquals( + 'Basic realm="SabreDAV"', + $this->response->headers['WWW-Authenticate'], + 'The WWW-Autenticate header was not set!' + ); + + + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/DigestAuthTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/DigestAuthTest.php new file mode 100755 index 0000000..ac86c19 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/DigestAuthTest.php @@ -0,0 +1,192 @@ +response = new Sabre_HTTP_ResponseMock(); + $this->auth = new Sabre_HTTP_DigestAuth(); + $this->auth->setRealm(self::REALM); + $this->auth->setHTTPResponse($this->response); + + } + + public function testDigest() { + + list($nonce,$opaque) = $this->getServerTokens(); + + $username = 'admin'; + $password = 12345; + $nc = '00002'; + $cnonce = uniqid(); + + $digestHash = md5( + md5($username . ':' . self::REALM . ':' . $password) . ':' . + $nonce . ':' . + $nc . ':' . + $cnonce . ':' . + 'auth:' . + md5('GET' . ':' . '/') + ); + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'GET', + 'PHP_AUTH_DIGEST' => 'username="'.$username.'", realm="' . self::REALM . '", nonce="' . $nonce . '", uri="/", response="' . $digestHash . '", opaque="' . $opaque . '", qop=auth,nc='.$nc.',cnonce="' . $cnonce . '"', + )); + + $this->auth->setHTTPRequest($request); + $this->auth->init(); + + $this->assertEquals($username,$this->auth->getUserName()); + $this->assertEquals(self::REALM,$this->auth->getRealm()); + $this->assertTrue($this->auth->validateA1(md5($username . ':' . self::REALM . ':' . $password)),'Authentication is deemed invalid through validateA1'); + $this->assertTrue($this->auth->validatePassword($password),'Authentication is deemed invalid through validatePassword'); + + } + + public function testDigestCGIFormat() { + + list($nonce,$opaque) = $this->getServerTokens(); + + $username = 'admin'; + $password = 12345; + $nc = '00002'; + $cnonce = uniqid(); + + $digestHash = md5( + md5($username . ':' . self::REALM . ':' . $password) . ':' . + $nonce . ':' . + $nc . ':' . + $cnonce . ':' . + 'auth:' . + md5('GET' . ':' . '/') + ); + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'GET', + 'HTTP_AUTHORIZATION' => 'Digest username="'.$username.'", realm="' . self::REALM . '", nonce="' . $nonce . '", uri="/", response="' . $digestHash . '", opaque="' . $opaque . '", qop=auth,nc='.$nc.',cnonce="' . $cnonce . '"', + )); + + $this->auth->setHTTPRequest($request); + $this->auth->init(); + + $this->assertTrue($this->auth->validateA1(md5($username . ':' . self::REALM . ':' . $password)),'Authentication is deemed invalid through validateA1'); + $this->assertTrue($this->auth->validatePassword($password),'Authentication is deemed invalid through validatePassword'); + + } + + public function testInvalidDigest() { + + list($nonce,$opaque) = $this->getServerTokens(); + + $username = 'admin'; + $password = 12345; + $nc = '00002'; + $cnonce = uniqid(); + + $digestHash = md5( + md5($username . ':' . self::REALM . ':' . $password) . ':' . + $nonce . ':' . + $nc . ':' . + $cnonce . ':' . + 'auth:' . + md5('GET' . ':' . '/') + ); + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'GET', + 'PHP_AUTH_DIGEST' => 'username="'.$username.'", realm="' . self::REALM . '", nonce="' . $nonce . '", uri="/", response="' . $digestHash . '", opaque="' . $opaque . '", qop=auth,nc='.$nc.',cnonce="' . $cnonce . '"', + )); + + $this->auth->setHTTPRequest($request); + $this->auth->init(); + + $this->assertFalse($this->auth->validateA1(md5($username . ':' . self::REALM . ':' . ($password . 'randomness'))),'Authentication is deemed invalid through validateA1'); + + } + + public function testInvalidDigest2() { + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'GET', + 'HTTP_AUTHORIZATION' => 'basic blablabla', + )); + + $this->auth->setHTTPRequest($request); + $this->auth->init(); + + $this->assertFalse($this->auth->validateA1(md5('user:realm:password'))); + + } + + + public function testDigestAuthInt() { + + $this->auth->setQOP(Sabre_HTTP_DigestAuth::QOP_AUTHINT | Sabre_HTTP_DigestAuth::QOP_AUTH); + list($nonce,$opaque) = $this->getServerTokens(Sabre_HTTP_DigestAuth::QOP_AUTHINT| Sabre_HTTP_DigestAuth::QOP_AUTH); + + $username = 'admin'; + $password = 12345; + $nc = '00003'; + $cnonce = uniqid(); + + $digestHash = md5( + md5($username . ':' . self::REALM . ':' . $password) . ':' . + $nonce . ':' . + $nc . ':' . + $cnonce . ':' . + 'auth-int:' . + md5('POST' . ':' . '/' . ':' . md5('body')) + ); + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'POST', + 'PHP_AUTH_DIGEST' => 'username="'.$username.'", realm="' . self::REALM . '", nonce="' . $nonce . '", uri="/", response="' . $digestHash . '", opaque="' . $opaque . '", qop=auth-int,nc='.$nc.',cnonce="' . $cnonce . '"', + )); + $request->setBody('body'); + + $this->auth->setHTTPRequest($request); + + $this->auth->init(); + + $this->assertTrue($this->auth->validateA1(md5($username . ':' . self::REALM . ':' . $password)),'Authentication is deemed invalid through validateA1'); + + } + + private function getServerTokens($qop = Sabre_HTTP_DigestAuth::QOP_AUTH) { + + $this->auth->requireLogin(); + + switch($qop) { + case Sabre_HTTP_DigestAuth::QOP_AUTH : $qopstr='auth'; break; + case Sabre_HTTP_DigestAuth::QOP_AUTHINT : $qopstr='auth-int'; break; + default : $qopstr='auth,auth-int'; break; + } + + $test = preg_match('/Digest realm="'.self::REALM.'",qop="'.$qopstr.'",nonce="([0-9a-f]*)",opaque="([0-9a-f]*)"/', + $this->response->headers['WWW-Authenticate'],$matches); + + $this->assertTrue($test==true,'The WWW-Authenticate response didn\'t match our pattern. We received: ' . $this->response->headers['WWW-Authenticate']); + + $nonce = $matches[1]; + $opaque = $matches[2]; + + // Reset our environment + $this->setUp(); + $this->auth->setQOP($qop); + + return array($nonce,$opaque); + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/RequestTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/RequestTest.php new file mode 100755 index 0000000..f775067 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/RequestTest.php @@ -0,0 +1,139 @@ + 'www.example.org', + 'REQUEST_METHOD' => 'PUT', + 'REQUEST_URI' => '/testuri/', + 'CONTENT_TYPE' => 'text/xml', + ); + + $this->request = new Sabre_HTTP_Request($server); + + } + + function testGetHeader() { + + $this->assertEquals('www.example.org', $this->request->getHeader('Host')); + $this->assertEquals('text/xml', $this->request->getHeader('Content-Type')); + + } + + function testGetNonExistantHeader() { + + $this->assertNull($this->request->getHeader('doesntexist')); + $this->assertNull($this->request->getHeader('Content-Length')); + + } + + function testGetHeaders() { + + $expected = array( + 'host' => 'www.example.org', + 'content-type' => 'text/xml', + ); + + $this->assertEquals($expected, $this->request->getHeaders()); + + } + + function testGetMethod() { + + $this->assertEquals('PUT', $this->request->getMethod(), 'It seems as if we didn\'t get a valid HTTP Request method back'); + + } + + function testGetUri() { + + $this->assertEquals('/testuri/', $this->request->getUri(), 'We got an invalid uri back'); + + } + + function testSetGetBody() { + + $h = fopen('php://memory','r+'); + fwrite($h,'testing'); + rewind($h); + $this->request->setBody($h); + $this->assertEquals('testing',$this->request->getBody(true),'We didn\'t get our testbody back'); + + } + + function testSetGetBodyStream() { + + $h = fopen('php://memory','r+'); + fwrite($h,'testing'); + rewind($h); + $this->request->setBody($h); + $this->assertEquals('testing',stream_get_contents($this->request->getBody()),'We didn\'t get our testbody back'); + + } + + + function testDefaultInputStream() { + + $h = fopen('php://memory','r+'); + fwrite($h,'testing'); + rewind($h); + + $previousValue = Sabre_HTTP_Request::$defaultInputStream; + Sabre_HTTP_Request::$defaultInputStream = $h; + + $this->assertEquals('testing',$this->request->getBody(true),'We didn\'t get our testbody back'); + Sabre_HTTP_Request::$defaultInputStream = $previousValue; + + } + + function testGetAbsoluteUri() { + + $s = array( + 'HTTP_HOST' => 'sabredav.org', + 'REQUEST_URI' => '/foo' + ); + + $r = new Sabre_HTTP_Request($s); + + $this->assertEquals('http://sabredav.org/foo', $r->getAbsoluteUri()); + + $s = array( + 'HTTP_HOST' => 'sabredav.org', + 'REQUEST_URI' => '/foo', + 'HTTPS' => 'on', + ); + + $r = new Sabre_HTTP_Request($s); + + $this->assertEquals('https://sabredav.org/foo', $r->getAbsoluteUri()); + + } + + function testGetQueryString() { + + $s = array( + 'QUERY_STRING' => 'bla', + ); + + $r = new Sabre_HTTP_Request($s); + $this->assertEquals('bla', $r->getQueryString()); + + $s = array(); + + $r = new Sabre_HTTP_Request($s); + $this->assertEquals('', $r->getQueryString()); + + } + + + + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/ResponseMock.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/ResponseMock.php new file mode 100755 index 0000000..1d770ed --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/ResponseMock.php @@ -0,0 +1,29 @@ +headers[$name] = $value; + + } + + function sendStatus($code) { + + $this->status = $this->getStatusMessage($code); + + } + + function sendBody($body) { + + $this->body = $body; + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/ResponseTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/ResponseTest.php new file mode 100755 index 0000000..e874937 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/ResponseTest.php @@ -0,0 +1,60 @@ +response = new Sabre_HTTP_ResponseMock(); + + } + + function testGetStatusMessage() { + + $msg = $this->response->getStatusMessage(200); + $this->assertEquals('HTTP/1.1 200 OK',$msg); + + } + + function testSetHeader() { + + $this->response->setHeader('Content-Type','text/html'); + $this->assertEquals('text/html', $this->response->headers['Content-Type']); + + + } + + function testSendStatus() { + + $this->response->sendStatus(404); + $this->assertEquals('HTTP/1.1 404 Not Found', $this->response->status); + + } + + function testSendBody() { + + ob_start(); + $response = new Sabre_HTTP_Response(); + $response->sendBody('hello'); + $this->assertEquals('hello',ob_get_clean()); + + } + + function testSendBodyStream() { + + ob_start(); + $stream = fopen('php://memory','r+'); + fwrite($stream,'hello'); + rewind($stream); + $response = new Sabre_HTTP_Response(); + $response->sendBody($stream); + $this->assertEquals('hello',ob_get_clean()); + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/UtilTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/UtilTest.php new file mode 100755 index 0000000..75bedfc --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/UtilTest.php @@ -0,0 +1,53 @@ +assertEquals($expected, $result->format('U')); + } + + $result = Sabre_HTTP_Util::parseHTTPDate('Wed Oct 6 10:26:00 2010'); + $this->assertEquals(1286360760, $result->format('U')); + + } + + function testParseHTTPDateFail() { + + $times = array( + //random string + 'NOW', + // not-GMT timezone + 'Wednesday, 13-Oct-10 10:26:00 UTC', + // No space before the 6 + 'Wed Oct 6 10:26:00 2010', + ); + + foreach($times as $time) { + $this->assertFalse(Sabre_HTTP_Util::parseHTTPDate($time), 'We used the string: ' . $time); + } + + } + + function testTimezones() { + + $default = date_default_timezone_get(); + date_default_timezone_set('Europe/Amsterdam'); + + $this->testParseHTTPDate(); + + date_default_timezone_set($default); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/VersionTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/VersionTest.php new file mode 100755 index 0000000..5cb124e --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/HTTP/VersionTest.php @@ -0,0 +1,15 @@ +assertEquals(-1, version_compare('1.0.0',$v)); + + $s = Sabre_HTTP_Version::STABILITY; + $this->assertTrue($s == 'alpha' || $s == 'beta' || $s =='stable'); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/TestUtil.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/TestUtil.php new file mode 100755 index 0000000..b35b055 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/TestUtil.php @@ -0,0 +1,49 @@ +setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); + return $pdo; + } catch (PDOException $e) { + return null; + } + + } + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/ComponentTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/ComponentTest.php new file mode 100755 index 0000000..4db4ec6 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/ComponentTest.php @@ -0,0 +1,332 @@ +children[] = $sub; + + $sub = new Sabre_VObject_Component('VTODO'); + $comp->children[] = $sub; + + $count = 0; + foreach($comp->children() as $key=>$subcomponent) { + + $count++; + $this->assertInstanceOf('Sabre_VObject_Component',$subcomponent); + + } + $this->assertEquals(2,$count); + $this->assertEquals(1,$key); + + } + + function testMagicGet() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + + $sub = new Sabre_VObject_Component('VEVENT'); + $comp->children[] = $sub; + + $sub = new Sabre_VObject_Component('VTODO'); + $comp->children[] = $sub; + + $event = $comp->vevent; + $this->assertInstanceOf('Sabre_VObject_Component', $event); + $this->assertEquals('VEVENT', $event->name); + + $this->assertInternalType('null', $comp->vjournal); + + } + + function testMagicGetGroups() { + + $comp = new Sabre_VObject_Component('VCARD'); + + $sub = new Sabre_VObject_Property('GROUP1.EMAIL','1@1.com'); + $comp->children[] = $sub; + + $sub = new Sabre_VObject_Property('GROUP2.EMAIL','2@2.com'); + $comp->children[] = $sub; + + $sub = new Sabre_VObject_Property('EMAIL','3@3.com'); + $comp->children[] = $sub; + + $emails = $comp->email; + $this->assertEquals(3, count($emails)); + + $email1 = $comp->{"group1.email"}; + $this->assertEquals('EMAIL', $email1[0]->name); + $this->assertEquals('GROUP1', $email1[0]->group); + + $email3 = $comp->{".email"}; + $this->assertEquals('EMAIL', $email3[0]->name); + $this->assertEquals(null, $email3[0]->group); + + } + + function testMagicIsset() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + + $sub = new Sabre_VObject_Component('VEVENT'); + $comp->children[] = $sub; + + $sub = new Sabre_VObject_Component('VTODO'); + $comp->children[] = $sub; + + $this->assertTrue(isset($comp->vevent)); + $this->assertTrue(isset($comp->vtodo)); + $this->assertFalse(isset($comp->vjournal)); + + } + + function testMagicSetScalar() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp->myProp = 'myValue'; + + $this->assertInstanceOf('Sabre_VObject_Property',$comp->MYPROP); + $this->assertEquals('myValue',$comp->MYPROP->value); + + + } + + function testMagicSetScalarTwice() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp->myProp = 'myValue'; + $comp->myProp = 'myValue'; + + $this->assertEquals(1,count($comp->children)); + $this->assertInstanceOf('Sabre_VObject_Property',$comp->MYPROP); + $this->assertEquals('myValue',$comp->MYPROP->value); + + } + + function testMagicSetComponent() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + + // Note that 'myProp' is ignored here. + $comp->myProp = new Sabre_VObject_Component('VEVENT'); + + $this->assertEquals(1, count($comp->children)); + + $this->assertEquals('VEVENT',$comp->VEVENT->name); + + } + + function testMagicSetTwice() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + + $comp->VEVENT = new Sabre_VObject_Component('VEVENT'); + $comp->VEVENT = new Sabre_VObject_Component('VEVENT'); + + $this->assertEquals(1, count($comp->children)); + + $this->assertEquals('VEVENT',$comp->VEVENT->name); + + } + + function testArrayAccessGet() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + + $event = new Sabre_VObject_Component('VEVENT'); + $event->summary = 'Event 1'; + + $comp->add($event); + + $event2 = clone $event; + $event2->summary = 'Event 2'; + + $comp->add($event2); + + $this->assertEquals(2,count($comp->children())); + $this->assertTrue($comp->vevent[1] instanceof Sabre_VObject_Component); + $this->assertEquals('Event 2', (string)$comp->vevent[1]->summary); + + } + + function testArrayAccessExists() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + + $event = new Sabre_VObject_Component('VEVENT'); + $event->summary = 'Event 1'; + + $comp->add($event); + + $event2 = clone $event; + $event2->summary = 'Event 2'; + + $comp->add($event2); + + $this->assertTrue(isset($comp->vevent[0])); + $this->assertTrue(isset($comp->vevent[1])); + + } + + /** + * @expectedException LogicException + */ + function testArrayAccessSet() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp['hey'] = 'hi there'; + + } + /** + * @expectedException LogicException + */ + function testArrayAccessUnset() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + unset($comp[0]); + + } + + function testAddScalar() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + + $comp->add('myprop','value'); + + $this->assertEquals(1, count($comp->children)); + + $this->assertTrue($comp->children[0] instanceof Sabre_VObject_Property); + $this->assertEquals('MYPROP',$comp->children[0]->name); + $this->assertEquals('value',$comp->children[0]->value); + + } + + function testAddComponent() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + + $comp->add(new Sabre_VObject_Component('VEVENT')); + + $this->assertEquals(1, count($comp->children)); + + $this->assertEquals('VEVENT',$comp->VEVENT->name); + + } + + function testAddComponentTwice() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + + $comp->add(new Sabre_VObject_Component('VEVENT')); + $comp->add(new Sabre_VObject_Component('VEVENT')); + + $this->assertEquals(2, count($comp->children)); + + $this->assertEquals('VEVENT',$comp->VEVENT->name); + + } + + /** + * @expectedException InvalidArgumentException + */ + function testAddArgFail() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp->add(new Sabre_VObject_Component('VEVENT'),'hello'); + + } + + /** + * @expectedException InvalidArgumentException + */ + function testAddArgFail2() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp->add(array()); + + } + + /** + * @expectedException InvalidArgumentException + */ + function testAddArgFail3() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp->add('hello',array()); + + } + + /** + * @expectedException InvalidArgumentException + */ + function testMagicSetInvalid() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + + // Note that 'myProp' is ignored here. + $comp->myProp = new StdClass(); + + $this->assertEquals(1, count($comp->children)); + + $this->assertEquals('VEVENT',$comp->VEVENT->name); + + } + + function testMagicUnset() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp->add(new Sabre_VObject_Component('VEVENT')); + + unset($comp->vevent); + + $this->assertEquals(array(), $comp->children); + + } + + + function testCount() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + $this->assertEquals(1,$comp->count()); + + } + + function testChildren() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + + // Note that 'myProp' is ignored here. + $comp->children = array( + new Sabre_VObject_Component('VEVENT'), + new Sabre_VObject_Component('VTODO') + ); + + $r = $comp->children(); + $this->assertTrue($r instanceof Sabre_VObject_ElementList); + $this->assertEquals(2,count($r)); + } + + function testSerialize() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + $this->assertEquals("BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n", $comp->serialize()); + + + } + + function testSerializeChildren() { + + $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp->children = array( + new Sabre_VObject_Component('VEVENT'), + new Sabre_VObject_Component('VTODO') + ); + $this->assertEquals("BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nBEGIN:VEVENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", $comp->serialize()); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/Element/DateTimeTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/Element/DateTimeTest.php new file mode 100755 index 0000000..3df3ea3 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/Element/DateTimeTest.php @@ -0,0 +1,204 @@ +setTimeZone($tz); + + $elem = new Sabre_VObject_Element_DateTime('DTSTART'); + $elem->setDateTime($dt); + + $this->assertEquals('19850704T013000', $elem->value); + $this->assertEquals('Europe/Amsterdam', (string)$elem['TZID']); + $this->assertEquals('DATE-TIME', (string)$elem['VALUE']); + + } + + function testSetDateTimeLOCAL() { + + $tz = new DateTimeZone('Europe/Amsterdam'); + $dt = new DateTime('1985-07-04 01:30:00', $tz); + $dt->setTimeZone($tz); + + $elem = new Sabre_VObject_Element_DateTime('DTSTART'); + $elem->setDateTime($dt, Sabre_VObject_Element_DateTime::LOCAL); + + $this->assertEquals('19850704T013000', $elem->value); + $this->assertNull($elem['TZID']); + $this->assertEquals('DATE-TIME', (string)$elem['VALUE']); + + } + + function testSetDateTimeUTC() { + + $tz = new DateTimeZone('GMT'); + $dt = new DateTime('1985-07-04 01:30:00', $tz); + $dt->setTimeZone($tz); + + $elem = new Sabre_VObject_Element_DateTime('DTSTART'); + $elem->setDateTime($dt, Sabre_VObject_Element_DateTime::UTC); + + $this->assertEquals('19850704T013000Z', $elem->value); + $this->assertNull($elem['TZID']); + $this->assertEquals('DATE-TIME', (string)$elem['VALUE']); + + } + + function testSetDateTimeLOCALTZ() { + + $tz = new DateTimeZone('Europe/Amsterdam'); + $dt = new DateTime('1985-07-04 01:30:00', $tz); + $dt->setTimeZone($tz); + + $elem = new Sabre_VObject_Element_DateTime('DTSTART'); + $elem->setDateTime($dt, Sabre_VObject_Element_DateTime::LOCALTZ); + + $this->assertEquals('19850704T013000', $elem->value); + $this->assertEquals('Europe/Amsterdam', (string)$elem['TZID']); + $this->assertEquals('DATE-TIME', (string)$elem['VALUE']); + + } + + function testSetDateTimeDATE() { + + $tz = new DateTimeZone('Europe/Amsterdam'); + $dt = new DateTime('1985-07-04 01:30:00', $tz); + $dt->setTimeZone($tz); + + $elem = new Sabre_VObject_Element_DateTime('DTSTART'); + $elem->setDateTime($dt, Sabre_VObject_Element_DateTime::DATE); + + $this->assertEquals('19850704', $elem->value); + $this->assertNull($elem['TZID']); + $this->assertEquals('DATE', (string)$elem['VALUE']); + + } + + /** + * @expectedException InvalidArgumentException + */ + function testSetDateTimeInvalid() { + + $tz = new DateTimeZone('Europe/Amsterdam'); + $dt = new DateTime('1985-07-04 01:30:00', $tz); + $dt->setTimeZone($tz); + + $elem = new Sabre_VObject_Element_DateTime('DTSTART'); + $elem->setDateTime($dt, 7); + + } + + function testGetDateTimeCached() { + + $tz = new DateTimeZone('Europe/Amsterdam'); + $dt = new DateTime('1985-07-04 01:30:00', $tz); + $dt->setTimeZone($tz); + + $elem = new Sabre_VObject_Element_DateTime('DTSTART'); + $elem->setDateTime($dt); + + $this->assertEquals($elem->getDateTime(), $dt); + + } + + function testGetDateTimeDateNULL() { + + $elem = new Sabre_VObject_Element_DateTime('DTSTART'); + $dt = $elem->getDateTime(); + + $this->assertNull($dt); + $this->assertNull($elem->getDateType()); + + } + + function testGetDateTimeDateDATE() { + + $elem = new Sabre_VObject_Element_DateTime('DTSTART','19850704'); + $dt = $elem->getDateTime(); + + $this->assertInstanceOf('DateTime', $dt); + $this->assertEquals('1985-07-04 00:00:00', $dt->format('Y-m-d H:i:s')); + $this->assertEquals(Sabre_VObject_Element_DateTime::DATE, $elem->getDateType()); + + } + + + function testGetDateTimeDateLOCAL() { + + $elem = new Sabre_VObject_Element_DateTime('DTSTART','19850704T013000'); + $dt = $elem->getDateTime(); + + $this->assertInstanceOf('DateTime', $dt); + $this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s')); + $this->assertEquals(Sabre_VObject_Element_DateTime::LOCAL, $elem->getDateType()); + + } + + function testGetDateTimeDateUTC() { + + $elem = new Sabre_VObject_Element_DateTime('DTSTART','19850704T013000Z'); + $dt = $elem->getDateTime(); + + $this->assertInstanceOf('DateTime', $dt); + $this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s')); + $this->assertEquals('UTC', $dt->getTimeZone()->getName()); + $this->assertEquals(Sabre_VObject_Element_DateTime::UTC, $elem->getDateType()); + + } + + function testGetDateTimeDateLOCALTZ() { + + $elem = new Sabre_VObject_Element_DateTime('DTSTART','19850704T013000'); + $elem['TZID'] = 'Europe/Amsterdam'; + + $dt = $elem->getDateTime(); + + $this->assertInstanceOf('DateTime', $dt); + $this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s')); + $this->assertEquals('Europe/Amsterdam', $dt->getTimeZone()->getName()); + $this->assertEquals(Sabre_VObject_Element_DateTime::LOCALTZ, $elem->getDateType()); + + } + + /** + * @expectedException InvalidArgumentException + */ + function testGetDateTimeDateInvalid() { + + $elem = new Sabre_VObject_Element_DateTime('DTSTART','bla'); + $dt = $elem->getDateTime(); + + } + + function testGetDateTimeWeirdTZ() { + + $elem = new Sabre_VObject_Element_DateTime('DTSTART','19850704T013000'); + $elem['TZID'] = '/freeassociation.sourceforge.net/Tzfile/Europe/Amsterdam'; + + + $event = new Sabre_VObject_Component('VEVENT'); + $event->add($elem); + + $timezone = new Sabre_VObject_Component('VTIMEZONE'); + $timezone->TZID = '/freeassociation.sourceforge.net/Tzfile/Europe/Amsterdam'; + $timezone->{'X-LIC-LOCATION'} = 'Europe/Amsterdam'; + + $calendar = new Sabre_VObject_Component('VCALENDAR'); + $calendar->add($event); + $calendar->add($timezone); + + $dt = $elem->getDateTime(); + + $this->assertInstanceOf('DateTime', $dt); + $this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s')); + $this->assertEquals('Europe/Amsterdam', $dt->getTimeZone()->getName()); + $this->assertEquals(Sabre_VObject_Element_DateTime::LOCALTZ, $elem->getDateType()); + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/Element/MultiDateTimeTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/Element/MultiDateTimeTest.php new file mode 100755 index 0000000..b2595f9 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/Element/MultiDateTimeTest.php @@ -0,0 +1,202 @@ +setTimeZone($tz); + $dt2->setTimeZone($tz); + + $elem = new Sabre_VObject_Element_MultiDateTime('DTSTART'); + $elem->setDateTimes(array($dt1,$dt2)); + + $this->assertEquals('19850704T013000,19860704T013000', $elem->value); + $this->assertEquals('Europe/Amsterdam', (string)$elem['TZID']); + $this->assertEquals('DATE-TIME', (string)$elem['VALUE']); + + } + + function testSetDateTimeLOCAL() { + + $tz = new DateTimeZone('Europe/Amsterdam'); + $dt1 = new DateTime('1985-07-04 01:30:00', $tz); + $dt2 = new DateTime('1986-07-04 01:30:00', $tz); + $dt1->setTimeZone($tz); + $dt2->setTimeZone($tz); + + $elem = new Sabre_VObject_Element_MultiDateTime('DTSTART'); + $elem->setDateTimes(array($dt1,$dt2), Sabre_VObject_Element_DateTime::LOCAL); + + $this->assertEquals('19850704T013000,19860704T013000', $elem->value); + $this->assertNull($elem['TZID']); + $this->assertEquals('DATE-TIME', (string)$elem['VALUE']); + + } + + function testSetDateTimeUTC() { + + $tz = new DateTimeZone('GMT'); + $dt1 = new DateTime('1985-07-04 01:30:00', $tz); + $dt2 = new DateTime('1986-07-04 01:30:00', $tz); + $dt1->setTimeZone($tz); + $dt2->setTimeZone($tz); + + $elem = new Sabre_VObject_Element_MultiDateTime('DTSTART'); + $elem->setDateTimes(array($dt1,$dt2), Sabre_VObject_Element_DateTime::UTC); + + $this->assertEquals('19850704T013000Z,19860704T013000Z', $elem->value); + $this->assertNull($elem['TZID']); + $this->assertEquals('DATE-TIME', (string)$elem['VALUE']); + + } + + function testSetDateTimeLOCALTZ() { + + $tz = new DateTimeZone('Europe/Amsterdam'); + $dt1 = new DateTime('1985-07-04 01:30:00', $tz); + $dt2 = new DateTime('1986-07-04 01:30:00', $tz); + $dt1->setTimeZone($tz); + $dt2->setTimeZone($tz); + + $elem = new Sabre_VObject_Element_MultiDateTime('DTSTART'); + $elem->setDateTimes(array($dt1,$dt2), Sabre_VObject_Element_DateTime::LOCALTZ); + + $this->assertEquals('19850704T013000,19860704T013000', $elem->value); + $this->assertEquals('Europe/Amsterdam', (string)$elem['TZID']); + $this->assertEquals('DATE-TIME', (string)$elem['VALUE']); + + } + + function testSetDateTimeDATE() { + + $tz = new DateTimeZone('Europe/Amsterdam'); + $dt1 = new datetime('1985-07-04 01:30:00', $tz); + $dt2 = new datetime('1986-07-04 01:30:00', $tz); + $dt1->settimezone($tz); + $dt2->settimezone($tz); + + $elem = new Sabre_VObject_Element_MultiDateTime('DTSTART'); + $elem->setDateTimes(array($dt1,$dt2), Sabre_VObject_Element_DateTime::DATE); + + $this->assertEquals('19850704,19860704', $elem->value); + $this->assertNull($elem['TZID']); + $this->assertEquals('DATE', (string)$elem['VALUE']); + + } + + /** + * @expectedException InvalidArgumentException + */ + function testSetDateTimeInvalid() { + + $tz = new DateTimeZone('Europe/Amsterdam'); + $dt = new DateTime('1985-07-04 01:30:00', $tz); + $dt->setTimeZone($tz); + + $elem = new Sabre_VObject_Element_MultiDateTime('DTSTART'); + $elem->setDateTimes(array($dt), 7); + + } + + function testGetDateTimeCached() { + + $tz = new DateTimeZone('Europe/Amsterdam'); + $dt1 = new datetime('1985-07-04 01:30:00', $tz); + $dt2 = new datetime('1986-07-04 01:30:00', $tz); + $dt1->settimezone($tz); + $dt2->settimezone($tz); + + $elem = new Sabre_VObject_Element_MultiDateTime('DTSTART'); + $elem->setDateTimes(array($dt1,$dt2)); + + $this->assertEquals($elem->getDateTimes(), array($dt1,$dt2)); + + } + + function testGetDateTimeDateNULL() { + + $elem = new Sabre_VObject_Element_MultiDateTime('DTSTART'); + $dt = $elem->getDateTimes(); + + $this->assertNull($dt); + $this->assertNull($elem->getDateType()); + + } + + function testGetDateTimeDateDATE() { + + $elem = new Sabre_VObject_Element_MultiDateTime('DTSTART','19850704,19860704'); + $dt = $elem->getDateTimes(); + + $this->assertEquals('1985-07-04 00:00:00', $dt[0]->format('Y-m-d H:i:s')); + $this->assertEquals('1986-07-04 00:00:00', $dt[1]->format('Y-m-d H:i:s')); + $this->assertEquals(Sabre_VObject_Element_DateTime::DATE, $elem->getDateType()); + + } + + function testGetDateTimeDateDATEReverse() { + + $elem = new Sabre_VObject_Element_MultiDateTime('DTSTART','19850704,19860704'); + + $this->assertEquals(Sabre_VObject_Element_DateTime::DATE, $elem->getDateType()); + + $dt = $elem->getDateTimes(); + $this->assertEquals('1985-07-04 00:00:00', $dt[0]->format('Y-m-d H:i:s')); + $this->assertEquals('1986-07-04 00:00:00', $dt[1]->format('Y-m-d H:i:s')); + + } + + + function testGetDateTimeDateLOCAL() { + + $elem = new Sabre_VObject_Element_DateTime('DTSTART','19850704T013000'); + $dt = $elem->getDateTime(); + + $this->assertInstanceOf('DateTime', $dt); + $this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s')); + $this->assertEquals(Sabre_VObject_Element_DateTime::LOCAL, $elem->getDateType()); + + } + + function testGetDateTimeDateUTC() { + + $elem = new Sabre_VObject_Element_DateTime('DTSTART','19850704T013000Z'); + $dt = $elem->getDateTime(); + + $this->assertInstanceOf('DateTime', $dt); + $this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s')); + $this->assertEquals('UTC', $dt->getTimeZone()->getName()); + $this->assertEquals(Sabre_VObject_Element_DateTime::UTC, $elem->getDateType()); + + } + + function testGetDateTimeDateLOCALTZ() { + + $elem = new Sabre_VObject_Element_DateTime('DTSTART','19850704T013000'); + $elem['TZID'] = 'Europe/Amsterdam'; + + $dt = $elem->getDateTime(); + + $this->assertInstanceOf('DateTime', $dt); + $this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s')); + $this->assertEquals('Europe/Amsterdam', $dt->getTimeZone()->getName()); + $this->assertEquals(Sabre_VObject_Element_DateTime::LOCALTZ, $elem->getDateType()); + + } + + /** + * @expectedException InvalidArgumentException + */ + function testGetDateTimeDateInvalid() { + + $elem = new Sabre_VObject_Element_DateTime('DTSTART','bla'); + $dt = $elem->getDateTime(); + + } + +} + +?> diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/ElementListTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/ElementListTest.php new file mode 100755 index 0000000..3b7cd4b --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/ElementListTest.php @@ -0,0 +1,32 @@ +$subcomponent) { + + $count++; + $this->assertInstanceOf('Sabre_VObject_Component',$subcomponent); + + } + $this->assertEquals(3,$count); + $this->assertEquals(2,$key); + + } + + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/Issue153Test.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/Issue153Test.php new file mode 100755 index 0000000..16557c5 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/Issue153Test.php @@ -0,0 +1,12 @@ +assertEquals('Test Benutzer', (string)$obj->fn); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/ParameterTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/ParameterTest.php new file mode 100755 index 0000000..ea30997 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/ParameterTest.php @@ -0,0 +1,21 @@ +assertEquals('NAME',$param->name); + $this->assertEquals('value',$param->value); + + } + + function testCastToString() { + + $param = new Sabre_VObject_Parameter('name','value'); + $this->assertEquals('value',$param->__toString()); + $this->assertEquals('value',(string)$param); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/PropertyTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/PropertyTest.php new file mode 100755 index 0000000..e2bf430 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/PropertyTest.php @@ -0,0 +1,266 @@ +assertEquals('PROPNAME', $property->name); + $this->assertEquals('propvalue', $property->value); + $this->assertEquals('propvalue', $property->__toString()); + $this->assertEquals('propvalue', (string)$property); + + } + + public function testParameterExists() { + + $property = new Sabre_VObject_Property('propname','propvalue'); + $property->parameters[] = new Sabre_VObject_Parameter('paramname','paramvalue'); + + $this->assertTrue(isset($property['PARAMNAME'])); + $this->assertTrue(isset($property['paramname'])); + $this->assertFalse(isset($property['foo'])); + + } + + public function testParameterGet() { + + $property = new Sabre_VObject_Property('propname','propvalue'); + $property->parameters[] = new Sabre_VObject_Parameter('paramname','paramvalue'); + + $this->assertInstanceOf('Sabre_VObject_Parameter',$property['paramname']); + + } + + public function testParameterNotExists() { + + $property = new Sabre_VObject_Property('propname','propvalue'); + $property->parameters[] = new Sabre_VObject_Parameter('paramname','paramvalue'); + + $this->assertInternalType('null',$property['foo']); + + } + + public function testParameterMultiple() { + + $property = new Sabre_VObject_Property('propname','propvalue'); + $property->parameters[] = new Sabre_VObject_Parameter('paramname','paramvalue'); + $property->parameters[] = new Sabre_VObject_Parameter('paramname','paramvalue'); + + $this->assertInstanceOf('Sabre_VObject_Parameter',$property['paramname']); + $this->assertEquals(2,count($property['paramname'])); + + } + + public function testSetParameterAsString() { + + $property = new Sabre_VObject_Property('propname','propvalue'); + $property['paramname'] = 'paramvalue'; + + $this->assertEquals(1,count($property->parameters)); + $this->assertInstanceOf('Sabre_VObject_Parameter', $property->parameters[0]); + $this->assertEquals('PARAMNAME',$property->parameters[0]->name); + $this->assertEquals('paramvalue',$property->parameters[0]->value); + + } + + /** + * @expectedException InvalidArgumentException + */ + public function testSetParameterAsStringNoKey() { + + $property = new Sabre_VObject_Property('propname','propvalue'); + $property[] = 'paramvalue'; + + } + + public function testSetParameterObject() { + + $property = new Sabre_VObject_Property('propname','propvalue'); + $param = new Sabre_VObject_Parameter('paramname','paramvalue'); + + $property[] = $param; + + $this->assertEquals(1,count($property->parameters)); + $this->assertEquals($param, $property->parameters[0]); + + } + + /** + * @expectedException InvalidArgumentException + */ + public function testSetParameterObjectWithKey() { + + $property = new Sabre_VObject_Property('propname','propvalue'); + $param = new Sabre_VObject_Parameter('paramname','paramvalue'); + + $property['key'] = $param; + + } + + + /** + * @expectedException InvalidArgumentException + */ + public function testSetParameterObjectRandomObject() { + + $property = new Sabre_VObject_Property('propname','propvalue'); + $property[] = new StdClass(); + + } + + public function testUnsetParameter() { + + $property = new Sabre_VObject_Property('propname','propvalue'); + $param = new Sabre_VObject_Parameter('paramname','paramvalue'); + $property->parameters[] = $param; + + unset($property['PARAMNAME']); + $this->assertEquals(0,count($property->parameters)); + + } + + public function testParamCount() { + + $property = new Sabre_VObject_Property('propname','propvalue'); + $param = new Sabre_VObject_Parameter('paramname','paramvalue'); + $property->parameters[] = $param; + $property->parameters[] = clone $param; + + $this->assertEquals(2,count($property->parameters)); + + } + + public function testSerialize() { + + $property = new Sabre_VObject_Property('propname','propvalue'); + + $this->assertEquals("PROPNAME:propvalue\r\n",$property->serialize()); + + } + + public function testSerializeParam() { + + $property = new Sabre_VObject_Property('propname','propvalue'); + $property->parameters[] = new Sabre_VObject_Parameter('paramname','paramvalue'); + $property->parameters[] = new Sabre_VObject_Parameter('paramname2','paramvalue2'); + + $this->assertEquals("PROPNAME;PARAMNAME=paramvalue;PARAMNAME2=paramvalue2:propvalue\r\n",$property->serialize()); + + } + + public function testSerializeNewLine() { + + $property = new Sabre_VObject_Property('propname',"line1\nline2"); + + $this->assertEquals("PROPNAME:line1\\nline2\r\n",$property->serialize()); + + } + + public function testSerializeLongLine() { + + $value = str_repeat('!',200); + $property = new Sabre_VObject_Property('propname',$value); + + $expected = "PROPNAME:" . str_repeat('!',66) . "\r\n " . str_repeat('!',74) . "\r\n " . str_repeat('!',60) . "\r\n"; + + $this->assertEquals($expected,$property->serialize()); + + } + + public function testSerializeUTF8LineFold() { + + $value = str_repeat('!',65) . "\xc3\xa4bla"; // inserted umlaut-a + $property = new Sabre_VObject_Property('propname', $value); + $expected = "PROPNAME:" . str_repeat('!',65) . "\r\n \xc3\xa4bla\r\n"; + $this->assertEquals($expected, $property->serialize()); + + } + + public function testGetIterator() { + + $it = new Sabre_VObject_ElementList(array()); + $property = new Sabre_VObject_Property('propname','propvalue', $it); + $this->assertEquals($it,$property->getIterator()); + + } + + + public function testGetIteratorDefault() { + + $property = new Sabre_VObject_Property('propname','propvalue'); + $it = $property->getIterator(); + $this->assertTrue($it instanceof Sabre_VObject_ElementList); + $this->assertEquals(1,count($it)); + + } + + function testAddScalar() { + + $property = new Sabre_VObject_Property('EMAIL'); + + $property->add('myparam','value'); + + $this->assertEquals(1, count($property->parameters)); + + $this->assertTrue($property->parameters[0] instanceof Sabre_VObject_Parameter); + $this->assertEquals('MYPARAM',$property->parameters[0]->name); + $this->assertEquals('value',$property->parameters[0]->value); + + } + + function testAddParameter() { + + $prop = new Sabre_VObject_Property('EMAIL'); + + $prop->add(new Sabre_VObject_Parameter('MYPARAM','value')); + + $this->assertEquals(1, count($prop->parameters)); + $this->assertEquals('MYPARAM',$prop['myparam']->name); + + } + + function testAddParameterTwice() { + + $prop = new Sabre_VObject_Property('EMAIL'); + + $prop->add(new Sabre_VObject_Parameter('MYPARAM', 'value1')); + $prop->add(new Sabre_VObject_Parameter('MYPARAM', 'value2')); + + $this->assertEquals(2, count($prop->parameters)); + + $this->assertEquals('MYPARAM',$prop['MYPARAM']->name); + + } + + /** + * @expectedException InvalidArgumentException + */ + function testAddArgFail() { + + $prop = new Sabre_VObject_Property('EMAIL'); + $prop->add(new Sabre_VObject_Parameter('MPARAM'),'hello'); + + } + + /** + * @expectedException InvalidArgumentException + */ + function testAddArgFail2() { + + $property = new Sabre_VObject_Property('EMAIL','value'); + $property->add(array()); + + } + + /** + * @expectedException InvalidArgumentException + */ + function testAddArgFail3() { + + $property = new Sabre_VObject_Property('EMAIL','value'); + $property->add('hello',array()); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/ReaderTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/ReaderTest.php new file mode 100755 index 0000000..ec69d8a --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/ReaderTest.php @@ -0,0 +1,226 @@ +assertInstanceOf('Sabre_VObject_Component', $result); + $this->assertEquals('VCALENDAR', $result->name); + $this->assertEquals(0, count($result->children)); + + } + + function testReadComponentUnixNewLine() { + + $data = "BEGIN:VCALENDAR\nEND:VCALENDAR"; + + $result = Sabre_VObject_Reader::read($data); + + $this->assertInstanceOf('Sabre_VObject_Component', $result); + $this->assertEquals('VCALENDAR', $result->name); + $this->assertEquals(0, count($result->children)); + + } + + function testReadComponentMacNewLine() { + + $data = "BEGIN:VCALENDAR\rEND:VCALENDAR"; + + $result = Sabre_VObject_Reader::read($data); + + $this->assertInstanceOf('Sabre_VObject_Component', $result); + $this->assertEquals('VCALENDAR', $result->name); + $this->assertEquals(0, count($result->children)); + + } + + function testReadComponentLineFold() { + + $data = "BEGIN:\r\n\tVCALENDAR\r\nE\r\n ND:VCALENDAR"; + + $result = Sabre_VObject_Reader::read($data); + + $this->assertInstanceOf('Sabre_VObject_Component', $result); + $this->assertEquals('VCALENDAR', $result->name); + $this->assertEquals(0, count($result->children)); + + } + + /** + * @expectedException Sabre_VObject_ParseException + */ + function testReadCorruptComponent() { + + $data = "BEGIN:VCALENDAR\r\nEND:FOO"; + + $result = Sabre_VObject_Reader::read($data); + + } + + function testReadProperty() { + + $data = "PROPNAME:propValue"; + $result = Sabre_VObject_Reader::read($data); + + $this->assertInstanceOf('Sabre_VObject_Property', $result); + $this->assertEquals('PROPNAME', $result->name); + $this->assertEquals('propValue', $result->value); + + } + + function testReadMappedProperty() { + + $data = "DTSTART:20110529"; + $result = Sabre_VObject_Reader::read($data); + + $this->assertInstanceOf('Sabre_VObject_Element_DateTime', $result); + $this->assertEquals('DTSTART', $result->name); + $this->assertEquals('20110529', $result->value); + + } + + /** + * @expectedException Sabre_VObject_ParseException + */ + function testReadBrokenLine() { + + $data = "PROPNAME;propValue"; + $result = Sabre_VObject_Reader::read($data); + + } + + function testReadPropertyInComponent() { + + $data = array( + "BEGIN:VCALENDAR", + "PROPNAME:propValue", + "END:VCALENDAR" + ); + + $result = Sabre_VObject_Reader::read(implode("\r\n",$data)); + + $this->assertInstanceOf('Sabre_VObject_Component', $result); + $this->assertEquals('VCALENDAR', $result->name); + $this->assertEquals(1, count($result->children)); + $this->assertInstanceOf('Sabre_VObject_Property', $result->children[0]); + $this->assertEquals('PROPNAME', $result->children[0]->name); + $this->assertEquals('propValue', $result->children[0]->value); + + + } + function testReadNestedComponent() { + + $data = array( + "BEGIN:VCALENDAR", + "BEGIN:VTIMEZONE", + "BEGIN:DAYLIGHT", + "END:DAYLIGHT", + "END:VTIMEZONE", + "END:VCALENDAR" + ); + + $result = Sabre_VObject_Reader::read(implode("\r\n",$data)); + + $this->assertInstanceOf('Sabre_VObject_Component', $result); + $this->assertEquals('VCALENDAR', $result->name); + $this->assertEquals(1, count($result->children)); + $this->assertInstanceOf('Sabre_VObject_Component', $result->children[0]); + $this->assertEquals('VTIMEZONE', $result->children[0]->name); + $this->assertEquals(1, count($result->children[0]->children)); + $this->assertInstanceOf('Sabre_VObject_Component', $result->children[0]->children[0]); + $this->assertEquals('DAYLIGHT', $result->children[0]->children[0]->name); + + + } + + function testReadPropertyParameter() { + + $data = "PROPNAME;PARAMNAME=paramvalue:propValue"; + $result = Sabre_VObject_Reader::read($data); + + $this->assertInstanceOf('Sabre_VObject_Property', $result); + $this->assertEquals('PROPNAME', $result->name); + $this->assertEquals('propValue', $result->value); + $this->assertEquals(1, count($result->parameters)); + $this->assertEquals('PARAMNAME', $result->parameters[0]->name); + $this->assertEquals('paramvalue', $result->parameters[0]->value); + + } + + function testReadPropertyNoValue() { + + $data = "PROPNAME;PARAMNAME:propValue"; + $result = Sabre_VObject_Reader::read($data); + + $this->assertInstanceOf('Sabre_VObject_Property', $result); + $this->assertEquals('PROPNAME', $result->name); + $this->assertEquals('propValue', $result->value); + $this->assertEquals(1, count($result->parameters)); + $this->assertEquals('PARAMNAME', $result->parameters[0]->name); + $this->assertEquals('', $result->parameters[0]->value); + + } + + function testReadPropertyParameterExtraColon() { + + $data = "PROPNAME;PARAMNAME=paramvalue:propValue:anotherrandomstring"; + $result = Sabre_VObject_Reader::read($data); + + $this->assertInstanceOf('Sabre_VObject_Property', $result); + $this->assertEquals('PROPNAME', $result->name); + $this->assertEquals('propValue:anotherrandomstring', $result->value); + $this->assertEquals(1, count($result->parameters)); + $this->assertEquals('PARAMNAME', $result->parameters[0]->name); + $this->assertEquals('paramvalue', $result->parameters[0]->value); + + } + + function testReadProperty2Parameters() { + + $data = "PROPNAME;PARAMNAME=paramvalue;PARAMNAME2=paramvalue2:propValue"; + $result = Sabre_VObject_Reader::read($data); + + $this->assertInstanceOf('Sabre_VObject_Property', $result); + $this->assertEquals('PROPNAME', $result->name); + $this->assertEquals('propValue', $result->value); + $this->assertEquals(2, count($result->parameters)); + $this->assertEquals('PARAMNAME', $result->parameters[0]->name); + $this->assertEquals('paramvalue', $result->parameters[0]->value); + $this->assertEquals('PARAMNAME2', $result->parameters[1]->name); + $this->assertEquals('paramvalue2', $result->parameters[1]->value); + + } + + function testReadPropertyParameterQuoted() { + + $data = "PROPNAME;PARAMNAME=\"paramvalue\":propValue"; + $result = Sabre_VObject_Reader::read($data); + + $this->assertInstanceOf('Sabre_VObject_Property', $result); + $this->assertEquals('PROPNAME', $result->name); + $this->assertEquals('propValue', $result->value); + $this->assertEquals(1, count($result->parameters)); + $this->assertEquals('PARAMNAME', $result->parameters[0]->name); + $this->assertEquals('paramvalue', $result->parameters[0]->value); + + } + + function testReadPropertyParameterQuotedColon() { + + $data = "PROPNAME;PARAMNAME=\"param:value\":propValue"; + $result = Sabre_VObject_Reader::read($data); + + $this->assertInstanceOf('Sabre_VObject_Property', $result); + $this->assertEquals('PROPNAME', $result->name); + $this->assertEquals('propValue', $result->value); + $this->assertEquals(1, count($result->parameters)); + $this->assertEquals('PARAMNAME', $result->parameters[0]->name); + $this->assertEquals('param:value', $result->parameters[0]->value); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/VersionTest.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/VersionTest.php new file mode 100755 index 0000000..ea2a4b2 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/Sabre/VObject/VersionTest.php @@ -0,0 +1,15 @@ +assertEquals(-1, version_compare('0.9.0',$v)); + + $s = Sabre_VObject_Version::STABILITY; + $this->assertTrue($s == 'alpha' || $s == 'beta' || $s =='stable'); + + } + +} diff --git a/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/bootstrap.php b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/bootstrap.php new file mode 100755 index 0000000..7367d2e --- /dev/null +++ b/CoreVersions/Baikal_0.1/Frameworks/Versions/SabreDAV.1.5.7-stable/tests/bootstrap.php @@ -0,0 +1,21 @@ + + + Sabre/ + + + + + ../lib/ + + ../lib/Sabre.includes.php + ../lib/Sabre/VObject/includes.php + + + + diff --git a/CoreVersions/Baikal_0.1/Resources/baikal.empty.sqlite b/CoreVersions/Baikal_0.1/Resources/baikal.empty.sqlite new file mode 100755 index 0000000000000000000000000000000000000000..c08b67f2f31533a2e57d079a6f838ae8b3545ed2 GIT binary patch literal 14336 zcmeHN&2G~`5Vn&vsokFg7mEYxR-&R&!y)PcsZu3Ev8t-2qG^igDcaaeFtNSCyAdrC zhlFS0Df%3|0H@w~04}UIwquu8p@+z+G?rrT&W?A!@7tN(NXhBRk;4i4Km!kRw5^mB zRaIUhq$tZZMNwA8C%$yiP~*;xcFLS?iaDPDT3ZO6i+{p_#qlHU18qgbuIVd21L@>a|MmnO7{bZsi$6vv5g zggKnX#vG%LOFNM*0X(MbV#YmcJ0Bd9C?jC*6)VQpmO9#vV7kP&aX>qth{XlqOt*9c zdS>wdNW?Qv0UNvhL-ckQqt#NySX)!S_cAOJ{A}S??UVEyHtF+^X+vC=qV^t@E5`b|I;0YOvLCTYOUuxh*hS)o8^*zL%iK4c=xy`h zO`~~^4$X7aINb|jg<)Fe`&LcYh=(0F?xc6OX#DK>;N;BQ6mL}Z>UO1U?60eer$9wi;$)p?5LEj@@hXgF$UdpgZk4)jCYe}&7gtnkI z4wAJ+bkc9sP~s>kzR=3X;l^DQ)3Dn0bZ_~aE|YC|E?EwkpeJuD8D7#95xV;X(n2?R z#zd=NJ6*y!uEz@%uS(=5a95Yg#;$P}ZW*>+mycEW{{JAhF8~P&%tV3kPd)Ja|4gKX zNkM_RR{+lcxnCjx2nx(h0XY9>CM`@13e3F%aQ@Hz5&=L^U}g%y`9CvhVPa5V?iKh8 D>X03W literal 0 HcmV?d00001 diff --git a/CoreVersions/Baikal_0.1/Scripts/adduser.php b/CoreVersions/Baikal_0.1/Scripts/adduser.php new file mode 100755 index 0000000..ae4b624 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Scripts/adduser.php @@ -0,0 +1,102 @@ +#!/usr/bin/env php + +* All rights reserved +* +* http://baikal.codr.fr +* +* This script is part of the Baïkal Server project. The Baïkal +* Server project is free software; you can redistribute it +* and/or modify it under the terms of the GNU General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* The GNU General Public License can be found at +* http://www.gnu.org/copyleft/gpl.html. +* +* This script is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* This copyright notice MUST APPEAR in all copies of the script! +***************************************************************/ + +define("BAIKAL_CONTEXT", TRUE); +define("BAIKAL_CONTEXT_CLI", TRUE); + +require_once("../Bootstrap.php"); +require_once("./inc/functions.php"); + +$sUsername = @trim($argv[1]); + +if($sUsername === "") { + die("You have to provide a username; aborting.\n"); +} + +$sPassword = prompt_silent("Password: "); +$sPasswordConfirm = prompt_silent("Confirm password: "); + +if($sPassword === "") { + die("Password cannot be empty.\n"); +} + +if($sPassword !== $sPasswordConfirm) { + die("Passwords don't match; aborting.\n"); +} + +$sHash = md5($sUsername . ':' . BAIKAL_AUTH_REALM . ':' . $sPassword); + +$sEmail = prompt("Email: "); +$sDisplayName = prompt("Display name: "); + +try { + $stmt = $pdo->prepare("INSERT INTO users (username, digesta1) VALUES (?, ?)"); + $stmt->bindParam(1, $sUsername); + $stmt->bindParam(2, $sHash); + $stmt->execute(); + + $sPath = 'principals/' . $sUsername; + $stmt = $pdo->prepare("INSERT INTO calendars (principaluri, displayname, uri, description, components, ctag) VALUES (?,'default calendar','default','','VEVENT,VTODO','1')"); + $stmt->bindParam(1, $sPath); + $stmt->execute(); + + # INSERT INTO principals (uri,email,displayname) VALUES ('principals/admin', 'admin@example.org','Adminstrator'); + + $sPath = 'principals/' . $sUsername; + $stmt = $pdo->prepare("INSERT INTO principals (uri,email,displayname) VALUES (?, ?, ?)"); + $stmt->bindParam(1, $sPath); + $stmt->bindParam(2, $sEmail); + $stmt->bindParam(3, $sDisplayName); + $stmt->execute(); + + # INSERT INTO principals (uri,email,displayname) VALUES ('principals/admin/calendar-proxy-read', null, null); + $sPath = 'principals/' . $sUsername . "/calendar-proxy-read"; + $mNull = null; + $stmt->bindParam(1, $sPath); + $stmt->bindParam(2, $mNull); + $stmt->bindParam(3, $mNull); + $stmt->execute(); + + # INSERT INTO principals (uri,email,displayname) VALUES ('principals/admin/calendar-proxy-write', null, null); + $sPath = 'principals/' . $sUsername . "/calendar-proxy-write"; + $stmt->bindParam(1, $sPath); + $stmt->bindParam(2, $mNull); + $stmt->bindParam(3, $mNull); + $stmt->execute(); + + # INSERT INTO addressbooks (principaluri, displayname, uri, description, ctag) VALUES ('principals/admin','default calendar','default','','1'); + $sPath = 'principals/' . $sUsername; + $stmt = $pdo->prepare("INSERT INTO addressbooks (principaluri, displayname, uri, description, ctag) VALUES (?,'default addressbook','default','','1')"); + $stmt->bindParam(1, $sPath); + $stmt->execute(); + + echo "User has been added.\n"; + exit(0); +} catch(PDOException $e) { + echo "Fatal error. User has not been added. Details follow.\n"; + die($e->getMessage()); +} \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/Scripts/inc/functions.php b/CoreVersions/Baikal_0.1/Scripts/inc/functions.php new file mode 100755 index 0000000..1683db8 --- /dev/null +++ b/CoreVersions/Baikal_0.1/Scripts/inc/functions.php @@ -0,0 +1,35 @@ + +* All rights reserved +* +* http://baikal.codr.fr +* +* This script is part of the Baïkal Server project. The Baïkal +* Server project is free software; you can redistribute it +* and/or modify it under the terms of the GNU General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* The GNU General Public License can be found at +* http://www.gnu.org/copyleft/gpl.html. +* +* This script is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* This copyright notice MUST APPEAR in all copies of the script! +***************************************************************/ + +define("BAIKAL_CONTEXT", TRUE); +define("BAIKAL_CONTEXT_CLI", TRUE); + +require_once("../Bootstrap.php"); +require_once("./inc/functions.php"); + +$sUsername = isset($argv[1]) ? trim($argv[1]) : ""; + +if($sUsername === "") { + die("You have to provide a username; aborting.\n"); +} + +# Fetching user +$stmt = $pdo->prepare("SELECT * FROM users WHERE username=?"); +$stmt->bindParam(1, $sUsername); +$stmt->execute(); +if(($user = $stmt->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_FIRST)) === FALSE) { + die("User not found; aborting.\n"); +} + +# Fetching principal +$sUri = "principals/" . $sUsername; +$stmt = $pdo->prepare("SELECT * FROM principals WHERE uri=?"); +$stmt->bindParam(1, $sUri); +$stmt->execute(); +if(($principal = $stmt->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_FIRST)) === FALSE) { + die("Principal not found for user; aborting.\n"); +} + +echo "--User found--\nid:\t\t" . $user["id"] . "\nemail:\t\t" . $principal["email"] . "\ndisplayname:\t" . $principal["displayname"] . "\n"; + +echo "\n--Please enter new values--\n"; + +$sPassword = prompt_silent("Password (empty to leave untouched): "); +$sHash = ""; +$sEmail = ""; +$sDisplayName = ""; + +if($sPassword !== "") { + $sPasswordConfirm = prompt_silent("Confirm password: "); + if($sPassword !== $sPasswordConfirm) { + die("Passwords don't match; aborting.\n"); + } + + $sHash = md5($sUsername . ':' . BAIKAL_AUTH_REALM . ':' . $sPassword); +} + +$sEmail = prompt("Email (empty to leave untouched): "); +$sDisplayName = prompt("Display name (empty to leave untouched): "); + + +if($sHash === "" && $sEmail === "" && $sDisplayName === "") { + echo ("\nNothing to do. User is left untouched.\n"); + exit(0); +} + +if($sHash !== "") { + $stmt = $pdo->prepare("UPDATE users set digesta1=? WHERE id=?"); + $stmt->bindParam(1, $sHash); + $stmt->bindParam(2, $user["id"]); + $stmt->execute(); +} + +if($sEmail !== "") { + $stmt = $pdo->prepare("UPDATE principals set email=? WHERE id=?"); + $stmt->bindParam(1, $sEmail); + $stmt->bindParam(2, $principal["id"]); + $stmt->execute(); +} + +if($sDisplayName !== "") { + $stmt = $pdo->prepare("UPDATE principals set displayname=? WHERE id=?"); + $stmt->bindParam(1, $sDisplayName); + $stmt->bindParam(2, $principal["id"]); + $stmt->execute(); +} + +echo ("\nUser is updated.\n"); +exit(0); \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/WWWRoot/cal.php b/CoreVersions/Baikal_0.1/WWWRoot/cal.php new file mode 100755 index 0000000..d2cdabc --- /dev/null +++ b/CoreVersions/Baikal_0.1/WWWRoot/cal.php @@ -0,0 +1,56 @@ + +* All rights reserved +* +* http://baikal.codr.fr +* +* This script is part of the Baïkal Server project. The Baïkal +* Server project is free software; you can redistribute it +* and/or modify it under the terms of the GNU General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* The GNU General Public License can be found at +* http://www.gnu.org/copyleft/gpl.html. +* +* This script is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* This copyright notice MUST APPEAR in all copies of the script! +***************************************************************/ + +define("BAIKAL_CONTEXT", TRUE); +require_once("../Core/Bootstrap.php"); + +if(!defined("BAIKAL_CAL_ENABLED") || BAIKAL_CAL_ENABLED !== TRUE) { + throw new ErrorException("Baikal CalDAV is disabled.", 0, 255, __FILE__, __LINE__); +} + +# Backends +$authBackend = new Sabre_DAV_Auth_Backend_PDO($pdo); +$principalBackend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo); +$calendarBackend = new Sabre_CalDAV_Backend_PDO($pdo); + +# Directory structure +$nodes = array( + new Sabre_CalDAV_Principal_Collection($principalBackend), + new Sabre_CalDAV_CalendarRootNode($principalBackend, $calendarBackend), +); + +# Initializing server +$server = new Sabre_DAV_Server($nodes); +$server->setBaseUri(BAIKAL_CAL_BASEURI); + +# Server Plugins +$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend, BAIKAL_AUTH_REALM)); +$server->addPlugin(new Sabre_DAVACL_Plugin()); +$server->addPlugin(new Sabre_CalDAV_Plugin()); + + +# And off we go! +$server->exec(); \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/WWWRoot/card.php b/CoreVersions/Baikal_0.1/WWWRoot/card.php new file mode 100755 index 0000000..1d23026 --- /dev/null +++ b/CoreVersions/Baikal_0.1/WWWRoot/card.php @@ -0,0 +1,55 @@ + +* All rights reserved +* +* http://baikal.codr.fr +* +* This script is part of the Baïkal Server project. The Baïkal +* Server project is free software; you can redistribute it +* and/or modify it under the terms of the GNU General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* The GNU General Public License can be found at +* http://www.gnu.org/copyleft/gpl.html. +* +* This script is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* This copyright notice MUST APPEAR in all copies of the script! +***************************************************************/ + +define("BAIKAL_CONTEXT", TRUE); +require_once("../Core/Bootstrap.php"); + +if(!defined("BAIKAL_CARD_ENABLED") || BAIKAL_CARD_ENABLED !== TRUE) { + throw new ErrorException("Baikal CardDAV is disabled.", 0, 255, __FILE__, __LINE__); +} + +# Backends +$authBackend = new Sabre_DAV_Auth_Backend_PDO($pdo); +$principalBackend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo); +$carddavBackend = new Sabre_CardDAV_Backend_PDO($pdo); + +# Setting up the directory tree +$nodes = array( + new Sabre_DAVACL_PrincipalCollection($principalBackend), + new Sabre_CardDAV_AddressBookRoot($principalBackend, $carddavBackend), +); + +# The object tree needs in turn to be passed to the server class +$server = new Sabre_DAV_Server($nodes); +$server->setBaseUri(BAIKAL_CARD_BASEURI); + +# Plugins +$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend, BAIKAL_AUTH_REALM)); +$server->addPlugin(new Sabre_CardDAV_Plugin()); +$server->addPlugin(new Sabre_DAVACL_Plugin()); + +# And off we go! +$server->exec(); \ No newline at end of file diff --git a/CoreVersions/Baikal_0.1/WWWRoot/index.php b/CoreVersions/Baikal_0.1/WWWRoot/index.php new file mode 100755 index 0000000..b89364b --- /dev/null +++ b/CoreVersions/Baikal_0.1/WWWRoot/index.php @@ -0,0 +1,41 @@ + +* All rights reserved +* +* http://baikal.codr.fr +* +* This script is part of the Baïkal Server project. The Baïkal +* Server project is free software; you can redistribute it +* and/or modify it under the terms of the GNU General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* The GNU General Public License can be found at +* http://www.gnu.org/copyleft/gpl.html. +* +* This script is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* This copyright notice MUST APPEAR in all copies of the script! +***************************************************************/ + + define("BAIKAL_CONTEXT", TRUE); + require_once("../Core/Bootstrap.php"); + +?> + + + <?= BAIKAL_BASEURI ?> + + + +

Baïkal on

+ + \ No newline at end of file diff --git a/INSTALL.txt b/INSTALL.txt new file mode 100644 index 0000000..c5cc5cf --- /dev/null +++ b/INSTALL.txt @@ -0,0 +1,213 @@ +******************************************************************************* +INSTALLING Baïkal Server +******************************************************************************* + +This document is a part of the Baïkal Server project. Baïkal Server is an open +source lightweight CalDAV and CardDAV server released under the GNU GPL. Baïkal +is copyright (c) 2012 by Jérôme Schneider. + +This document describes the system requirements for Baïkal Server and the +installation routine. + + +=============================================================================== +0 - System requirements +=============================================================================== + +Baïkal Server is based on PHP5.2.0, and uses a SQLite3 with PHP PDO. This +document does not cover the installation of these requirements. + +The following configuration is the minimum required: +- an Apache2 web server capable of running PHP, and accessible thru a + dedicated subdomain (something like "dav.mydomainname.com") + NOTE: this document only covers sub-domain based installations. Other + installations modes are possible, though not documented (yet). +- root access to a command line on this server + NOTE: tools to create and manage users are command line only. Web-based + interfaces will be produced in the future. +- PHP 5.2.0 or newer with the following extensions: + - PDO and SQLite3 + Some extensions can be optionally compiled into PHP. A list of loaded + extensions can be checked using the phpinfo() function. +- 30 MB of disk space +- Apache configuration that activates "FollowSymlinks" + +=============================================================================== +1 - Obtaining Baïkal Server +=============================================================================== + +To get Baïkal Server, navigate to the following location: + http://baikal.codr.fr/ + +=============================================================================== +02 - Installation > Installing files +=============================================================================== + +To install Baïkal Server, unpack the source package outside of the web site root +directory on your server. The location must be accessible to the web server. +Usually, it will be something like /var/www/ + + # a. Enter the directory where the websites are stored + $ root:~> cd /var/www + +Unpacking will produce a directory with a name like BaikalServer-x.y.z, where x, +y and z correspond to the Baïkal Server version. For example, the Baikal Server +0.0.1 source package will create a directory named BaikalServer-0.0.1. + + # b. Unpack the package using: + $ root:/var/www> tar xzf BaikalServer-0.0.1.tgz + +Rename the untar'd directory to the name of your baikal dedicated subdomain. + + # c. Rename the directory to match your domain (good practice) + $ root:/var/www> mv BaikalServer-0.0.1 dav.mydomain.com + + # d. Enter the new Baïkal directory + $ root:/var/www> cd dav.mydomain.com + +In order to grant Apache access to the files of your Baïkal installation, +you'll have to grant the user running the apache process r+w permissions on +the Baïkal files. In our example, we will suppose the linux username/usergroup +running Apache is www-data:www-data + + # e. Change permissions on the files + $ root:/var/www> chown www-data:www-data dav.mydomain.com -Rf + +=============================================================================== +03 - Installation > Installing virtualhost +=============================================================================== + +Baïkal Server must be bound to a domain/subdomain in order to run properly. +This package provides a default virtualhost configuration file for Apache 2 in + Specific/virtualhosts/baikal.apache2 + +To enable your host to run Baïkal, you'll have to add the Baïkal virtualhost +to your Apache environment. + +In our example, we will assume that the apache2 configuration directory is: + /etc/apache2 + + # a. Enter the Apache2 configuration directory + $ root:/var/www> cd /etc/apache2 + + # b. Enter the sites-available directory + $ root:/etc/apache2> cd sites-available + + # c. Symlink the Baïkal virtualhost file to this directory + $ root:/etc/apache2/sites-available> ln -s /var/www/dav.mydomain.com/Specific/virtualhosts/baikal.apache2 + + # d. Customize the virtualhost config file + $ root:/etc/apache2/sites-available> nano baikal.apache2 + + # e. In baikal.apache2, replace references to dav.mydomain.com with your own domain name + + # f. Activate the new virtualhost + $ root:/etc/apache2/sites-available> cd ../sites-enabled + $ root:/etc/apache2/sites-enabled> ln -s ../sites-available/baikal.apache2 + + # h. Restart apache + $ root:/etc/apache2/sites-enabled> /etc/init.d/apache2 restart + +=============================================================================== +04 - Installation > Setting up Baïkal Server +=============================================================================== + +To set up Baïkal Server, you have to modify the content of the file + Specific/config.php + +There are 2 configurations you have to configure: + + # Timezone of your users; If unsure check http://en.wikipedia.org/wiki/List_of_tz_database_time_zones + define("BAIKAL_TIMEZONE", "Europe/Paris"); + + # WEB absolute URI + define("BAIKAL_BASEURI", "http://dav.mydomain.com/"); + +=============================================================================== +05 - Checking that Baïkal is properly configured +=============================================================================== + +You may now navigate to your domain URL using your favorite web browser. You should see something like: + + No users are defined. + To create a user, you can use the helper Core/Scripts/adduser.php (requires command line access) + +In not, there's a problem somewhere. Take a deep breath, and try to understand +what's going on. Checking out the apache log might also +be useful (tail -f /var/log/apache2/error.log) + +=============================================================================== +06 - Installation > Creating your first user +=============================================================================== + +Baïkal won't run before you create at least one user. +To do so, run the script Core/Scripts/adduser.php like this (replace username +with the actual username): + + # Enter the Baïkal Scripts directory + $ root:/etc/apache2/sites-enabled> cd /var/www/dav.mydomain.com/Core/Scripts/ + + # Add a user + $ root:/var/www/dav.mydomain.com/Core/Scripts> ./adduser.php username + +And follow the instructions on screen. + +If something like this shows up: "-bash: ./adduser.php: Permission denied" +You'll have to add the execution right to the script before running it: + chmod +x ./adduser.php + +Note: there's also a moduser.php script that'll allow you to modify users. + +=============================================================================== +07 - Checking that Baïkal is reading to fly +=============================================================================== + +You may now navigate to your domain URL using your favorite web browser. You should see something like: + + Baïkal on http://dav.mydomain.com/ + +In not, there's a problem somewhere. Take a deep breath, and try to understand +what's going on. Checking out the apache log might also +be useful (tail -f /var/log/apache2/error.log) + +=============================================================================== +08 - Connecting your CalDAV / CardDAV client to Baïkal Server +=============================================================================== + +# Apple iCal: +Add a new CalDAV account + * username: the username you just created (in our example, jerome) + * password: the password you just defined + * In server address: http://dav.mydomain.com/cal.php/principals/jerome + +# Apple Address Book: +Add a new CardDAV account: + * username: the username you just created (in our example, jerome) + * password: the password you just defined + * In server address: http://dav.mydomain.com/card.php/addressbooks/jerome/default + +=============================================================================== +09 - You're done +=============================================================================== + +You may now create new calendars, new events, new visit cards :) Enjoy. + +=============================================================================== +Troubleshooting +=============================================================================== + +For troubleshooting read the FAQ below. If your problem is not listed, contact +me after reading INSTALL.txt + +=============================================================================== +FAQ +=============================================================================== + +Q: Why is the Baïkal logo a fish ? +A: The fish is an Omul. According to Wikipedia + (http://en.wikipedia.org/wiki/Omul): The omul, Coregonus migratorius, also + known as Baikal omul (Russian: байкальский омуль), is a whitefish species + of the salmon family endemic to Lake Baikal in Siberia, Russia. It is + considered a delicacy and is the object of one of the largest commercial + fisheries on Lake Baikal. In 2004, it was listed in Russia as an endangered + species. \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..911d17d --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + Baïkal Server, a lightweight CalDAV and CardDAV server. + Copyright (C) 2012 Jérôme Schneider + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Baïkal Server Copyright (C) 2012 Jérôme Schneider + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..6b8998a --- /dev/null +++ b/README.txt @@ -0,0 +1,52 @@ +1. About this package +****************************************** + +This package contains a release of Baïkal Server. +Go to http://baikal.codr.fr to get more information about this package, and upgrades. + + +2. What is Baïkal Server ? +******************************************* + +Baïkal is an open source lightweight CalDAV and CardDAV server. It's developped +by Jérôme Schneider (http://codr.fr) and based on the SabreDAV library. Baïkal +Server is distributed under the GPL license. + +To get more info about the GPL license, visit +http://www.opensource.org/licenses/gpl-license.php. + + +3. Baïkal Server requirements +******************************************* + +Baïkal Server is based on PHP5.2.0, and uses a SQLite3 with PHP PDO. For more +information regarding these requirements see the INSTALL.txt file in this folder. + + +4. What should you do if you have a problem ? +******************************************* + + 1. Read the available documentation carefully + + 2. Search the web carefully about Baïkal Server + + 3. Mail me (Jérôme Schneider) at mail§jeromeschneider.fr <= replace § with @. + + When mailing, see the following guidelines... + - Be polite + Always include the version of used Baïkal and server environment + (phpinfo())... + - Be as specific and clear as possible - questions like "my + installation does not work - what can I do???" will be ignored. + I can read english and french. + + 4. If you have identified a genuine new bug report it at + the mail address given in point 3 of this list + + +5. How to get started +******************************************* + +Please see the INSTALL.txt in this folder. + +-- Jérôme Schneider Wed, 22 Feb 2012 21:46:00 +0100 \ No newline at end of file diff --git a/Specific/config.php b/Specific/config.php new file mode 100755 index 0000000..c04a451 --- /dev/null +++ b/Specific/config.php @@ -0,0 +1,49 @@ +gbuIVd21L@>a|MmnO7{bZsi$6vv5g zggKnX#vG%LOFNM*0X(MbV#YmcJ0Bd9C?jC*6)VQpmO9#vV7kP&aX>qth{XlqOt*9c zdS>wdNW?Qv0UNvhL-ckQqt#NySX)!S_cAOJ{A}S??UVEyHtF+^X+vC=qV^t@E5`b|I;0YOvLCTYOUuxh*hS)o8^*zL%iK4c=xy`h zO`~~^4$X7aINb|jg<)Fe`&LcYh=(0F?xc6OX#DK>;N;BQ6mL}Z>UO1U?60eer$9wi;$)p?5LEj@@hXgF$UdpgZk4)jCYe}&7gtnkI z4wAJ+bkc9sP~s>kzR=3X;l^DQ)3Dn0bZ_~aE|YC|E?EwkpeJuD8D7#95xV;X(n2?R z#zd=NJ6*y!uEz@%uS(=5a95Yg#;$P}ZW*>+mycEW{{JAhF8~P&%tV3kPd)Ja|4gKX zNkM_RR{+lcxnCjx2nx(h0XY9>CM`@13e3F%aQ@Hz5&=L^U}g%y`9CvhVPa5V?iKh8 D>X03W literal 0 HcmV?d00001 diff --git a/Specific/virtualhosts/baikal.apache2 b/Specific/virtualhosts/baikal.apache2 new file mode 100755 index 0000000..04a605e --- /dev/null +++ b/Specific/virtualhosts/baikal.apache2 @@ -0,0 +1,12 @@ + + + DocumentRoot /var/www/dav.mydomain.com/html + ServerName dav.mydomain.com + + + Options None + Options +FollowSymlinks + AllowOverride None + + + diff --git a/html/cal.php b/html/cal.php new file mode 120000 index 0000000..fb14e0f --- /dev/null +++ b/html/cal.php @@ -0,0 +1 @@ +../Core/WWWRoot/cal.php \ No newline at end of file diff --git a/html/card.php b/html/card.php new file mode 120000 index 0000000..3749e7d --- /dev/null +++ b/html/card.php @@ -0,0 +1 @@ +../Core/WWWRoot/card.php \ No newline at end of file diff --git a/html/index.php b/html/index.php new file mode 120000 index 0000000..c9a4194 --- /dev/null +++ b/html/index.php @@ -0,0 +1 @@ +../Core/WWWRoot/index.php \ No newline at end of file