1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-21 06:58:51 -05:00

Caldav: switch return code back to 503

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2120 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2013-05-14 22:39:26 +00:00
parent 3189afaae9
commit 51e7ca1cb3
13 changed files with 561 additions and 198 deletions

View File

@ -22,10 +22,7 @@ import davmail.AbstractConnection;
import davmail.BundleMessage; import davmail.BundleMessage;
import davmail.DavGateway; import davmail.DavGateway;
import davmail.Settings; import davmail.Settings;
import davmail.exception.DavMailAuthenticationException; import davmail.exception.*;
import davmail.exception.DavMailException;
import davmail.exception.HttpNotFoundException;
import davmail.exception.HttpPreconditionFailedException;
import davmail.exchange.ExchangeSession; import davmail.exchange.ExchangeSession;
import davmail.exchange.ExchangeSessionFactory; import davmail.exchange.ExchangeSessionFactory;
import davmail.exchange.ICSBufferedReader; import davmail.exchange.ICSBufferedReader;
@ -172,7 +169,7 @@ public class CaldavConnection extends AbstractConnection {
} catch (DavMailAuthenticationException e) { } catch (DavMailAuthenticationException e) {
if (Settings.getBooleanProperty("davmail.enableKerberos")) { if (Settings.getBooleanProperty("davmail.enableKerberos")) {
// authentication failed in Kerberos mode => not available // authentication failed in Kerberos mode => not available
sendErr(HttpStatus.SC_FORBIDDEN, "Kerberos authentication failed"); throw new HttpServerErrorException("Kerberos authentication failed");
} else { } else {
sendUnauthorized(); sendUnauthorized();
} }
@ -1121,7 +1118,7 @@ public class CaldavConnection extends AbstractConnection {
} else if (e instanceof HttpPreconditionFailedException) { } else if (e instanceof HttpPreconditionFailedException) {
sendErr(HttpStatus.SC_PRECONDITION_FAILED, message); sendErr(HttpStatus.SC_PRECONDITION_FAILED, message);
} else { } else {
sendErr(HttpStatus.SC_FORBIDDEN, message); sendErr(HttpStatus.SC_SERVICE_UNAVAILABLE, message);
} }
} }

View File

@ -62,6 +62,11 @@ public class AbstractDavMailTestCase extends TestCase {
Settings.setProperty("davmail.password", password); Settings.setProperty("davmail.password", password);
} }
if (Settings.getBooleanProperty("davmail.enableKerberos", false)) {
System.setProperty("java.security.krb5.realm", "CORP.COMPANY.COM");
System.setProperty("java.security.krb5.kdc", "192.168.184.129");
}
DavGatewaySSLProtocolSocketFactory.register(); DavGatewaySSLProtocolSocketFactory.register();
// force server mode // force server mode

View File

@ -390,4 +390,19 @@ public class TestCaldav extends AbstractDavMailTestCase {
method.getResponseBodyAsMultiStatus(); method.getResponseBodyAsMultiStatus();
} }
public void testPropfindPublicPrincipal() throws IOException, DavException {
//Settings.setLoggingLevel("httpclient.wire", Level.DEBUG);
DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet();
davPropertyNameSet.add(DavPropertyName.create("calendar-home-set", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav")));
davPropertyNameSet.add(DavPropertyName.create("calendar-user-address-set", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav")));
davPropertyNameSet.add(DavPropertyName.create("schedule-inbox-URL", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav")));
davPropertyNameSet.add(DavPropertyName.create("schedule-outbox-URL", Namespace.getNamespace("urn:ietf:params:xml:ns:caldav")));
PropFindMethod method = new PropFindMethod("/principals/public/testcalendar/", davPropertyNameSet, 0);
httpClient.executeMethod(method);
assertEquals(HttpStatus.SC_MULTI_STATUS, method.getStatusCode());
MultiStatus multiStatus = method.getResponseBodyAsMultiStatus();
MultiStatusResponse[] responses = multiStatus.getResponses();
assertEquals(1, responses.length);
}
} }

View File

@ -0,0 +1,61 @@
/*
* DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway
* Copyright (C) 2011 Mickael Guessant
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package davmail.exchange;
import davmail.exchange.AbstractExchangeSessionTestCase;
import davmail.exchange.ExchangeSession;
import davmail.exchange.dav.DavExchangeSession;
import davmail.exchange.dav.ExchangePropFindMethod;
import davmail.exchange.dav.Field;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.util.URIUtil;
import org.apache.jackrabbit.webdav.DavException;
import org.apache.jackrabbit.webdav.MultiStatus;
import org.apache.jackrabbit.webdav.MultiStatusResponse;
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
import org.apache.jackrabbit.webdav.property.DavPropertySet;
import java.io.ByteArrayInputStream;
import java.io.IOException;
/**
* Test custom Propfind method.
*/
public class TestExchangePropfindMethod extends AbstractExchangeSessionTestCase {
public void testGetFolder() throws IOException, DavException {
ExchangeSession.Folder folder = session.getFolder("INBOX");
assertNotNull(folder);
DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet();
// davPropertyNameSet.add(Field.getPropertyName("displayname"));
//PropFindMethod propFindMethod = new PropFindMethod(URIUtil.encodePath(((DavExchangeSession)session).getFolderPath(folder.folderPath)));
//session.httpClient.executeMethod(propFindMethod);
//propFindMethod.getResponseBodyAsMultiStatus();
ExchangePropFindMethod exchangePropFindMethod = new ExchangePropFindMethod(URIUtil.encodePath(((DavExchangeSession)session).getFolderPath(folder.folderPath)), davPropertyNameSet, 0);
//PropFindMethod propFindMethod = new PropFindMethod(URIUtil.encodePath(((DavExchangeSession)session).getFolderPath(folder.folderPath)));
session.httpClient.executeMethod(exchangePropFindMethod);
MultiStatusResponse response = exchangePropFindMethod.getResponse();
DavPropertySet properties = response.getProperties(HttpStatus.SC_OK);
System.out.println(properties);
}
}

View File

@ -64,12 +64,28 @@ public class TestExchangeSessionCalendar extends AbstractExchangeSessionTestCase
} }
}; };
for (int i = 1; i < 100; i++) { @SuppressWarnings("Since15") Set<String> tzReference = ResourceBundle.getBundle("tzreference").keySet();
Set<String> timezoneids = ResourceBundle.getBundle("timezoneids").keySet();
Map<String,String> timezoneIndexToIdMap = new HashMap<String,String>();
for (String timezoneid:timezoneids) {
timezoneIndexToIdMap.put(ResourceBundle.getBundle("timezoneids").getString(timezoneid), timezoneid);
}
for (int i = 1; i < 120; i++) {
Settings.setProperty("davmail.timezoneId", String.valueOf(i)); Settings.setProperty("davmail.timezoneId", String.valueOf(i));
VObject timezone = session.getVTimezone(); VObject timezone = session.getVTimezone();
if (timezone.getProperty("TZID") != null) { if (timezone != null && timezone.getProperty("TZID") != null) {
properties.put(timezone.getPropertyValue("TZID").replaceAll("\\\\", ""), String.valueOf(i)); String value = timezone.getPropertyValue("TZID").replaceAll("\\\\", "");
System.out.println(timezone.getPropertyValue("TZID") + '=' + i); properties.put(value, String.valueOf(i));
if (timezoneIndexToIdMap.get(String.valueOf(i)) != null) {
//properties.put(timezoneIndexToIdMap.get(String.valueOf(i)), ResourceBundle.getBundle("timezones").getString(value));
System.out.println(timezoneIndexToIdMap.get(String.valueOf(i)).replaceAll(" ", "\\\\ ") + '=' + ResourceBundle.getBundle("timezones").getString(value));
} else {
System.out.println("Missing timezone id: "+i+" "+value);
}
//noinspection Since15
if (!ResourceBundle.getBundle("timezones").keySet().contains(value)) {
System.out.println("Missing timezone: "+value.replaceAll(" ", "\\\\ "));
}
} }
session.vTimezone = null; session.vTimezone = null;
} }
@ -147,36 +163,33 @@ public class TestExchangeSessionCalendar extends AbstractExchangeSessionTestCase
String itemBody = "BEGIN:VCALENDAR\n" + String itemBody = "BEGIN:VCALENDAR\n" +
"PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN\n" + "PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN\n" +
"VERSION:2.0\n" + "VERSION:2.0\n" +
"METHOD:PUBLISH\n" +
"BEGIN:VTIMEZONE\n" + "BEGIN:VTIMEZONE\n" +
"TZID:Pacific Time (US & Canada)\\; Tijuana\n" + "TZID:W. Europe Standard Time\n" +
"BEGIN:STANDARD\n" + "BEGIN:STANDARD\n" +
"DTSTART:16010101T020000\n" + "DTSTART:16010101T030000\n" +
"TZOFFSETFROM:-0700\n" + "TZOFFSETFROM:+0200\n" +
"TZOFFSETTO:-0800\n" + "TZOFFSETTO:+0100\n" +
"RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=11;BYDAY=1SU\n" + "RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10\n" +
"END:STANDARD\n" + "END:STANDARD\n" +
"BEGIN:DAYLIGHT\n" + "BEGIN:DAYLIGHT\n" +
"DTSTART:16010101T020000\n" + "DTSTART:16010101T020000\n" +
"TZOFFSETFROM:-0800\n" + "TZOFFSETFROM:+0100\n" +
"TZOFFSETTO:-0700\n" + "TZOFFSETTO:+0200\n" +
"RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=2SU\n" + "RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3\n" +
"END:DAYLIGHT\n" + "END:DAYLIGHT\n" +
"END:VTIMEZONE\n" + "END:VTIMEZONE\n" +
"BEGIN:VEVENT\n" + "BEGIN:VEVENT\n" +
"CREATED:20100829T204658Z\n" + "CREATED:20120611T113748Z\n" +
"LAST-MODIFIED:20100829T204829Z\n" + "LAST-MODIFIED:20120611T113823Z\n" +
"DTSTAMP:20100829T204829Z\n" + "DTSTAMP:20120611T113823Z\n" +
"UID:701b9d8f-ab64-4a7c-a75d-251cc8687cd9\n" + "UID:040000008200E00074C5B7101A82E0080000000020EA852CF458CC0100000000000000001\n" +
"SUMMARY:testzz\n" + " 000000011278A1693B8494C8592446E6E249BCF\n" +
"DTSTART;TZID=\"Pacific Time (US & Canada); Tijuana\":20100830T230000\n" + "DTSTART;TZID=W. Europe Standard Time:20120926T100000\n" +
"DTEND;TZID=\"Pacific Time (US & Canada); Tijuana\":20100831T000000\n" + "DTEND;TZID=W. Europe Standard Time:20120926T120000\n" +
"X-MICROSOFT-CDO-ALLDAYEVENT:FALSE\n" +
"X-MICROSOFT-CDO-BUSYSTATUS:BUSY\n" +
"TRANSP:OPAQUE\n" +
"X-MOZ-GENERATION:1\n" +
"END:VEVENT\n" + "END:VEVENT\n" +
"END:VCALENDAR"; "END:VCALENDAR\n";
String itemName = UUID.randomUUID().toString() + ".EML"; String itemName = "test ok"/*UUID.randomUUID().toString()*/ + ".EML";
session.createOrUpdateItem("calendar", itemName, itemBody, null, null); session.createOrUpdateItem("calendar", itemName, itemBody, null, null);
} }
@ -213,34 +226,38 @@ public class TestExchangeSessionCalendar extends AbstractExchangeSessionTestCase
public void testCreateEventTZ() throws IOException { public void testCreateEventTZ() throws IOException {
String itemBody = "BEGIN:VCALENDAR\n" + String itemBody = "BEGIN:VCALENDAR\n" +
"PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN\n" + "PRODID:-//iCal4OL2.11.20\n" +
"VERSION:2.0\n" + "VERSION:2.0\n" +
"X-WR-TIMEZONE:Europe/Berlin\n" +
"CALSCALE:GREGORIAN\n" +
"BEGIN:VTIMEZONE\n" + "BEGIN:VTIMEZONE\n" +
"TZID:America/Bogota\n" + "TZID:Europe/Berlin\n" +
"X-LIC-LOCATION:Europe/Berlin\n" +
"BEGIN:DAYLIGHT\n" + "BEGIN:DAYLIGHT\n" +
"TZOFFSETFROM:-0500\n" + "DTSTART:20100328T010000\n" +
"DTSTART:19920503T000000\n" + "TZOFFSETTO:+0200\n" +
"TZNAME:COT\n" + "TZOFFSETFROM:+0100\n" +
"TZOFFSETTO:-0400\n" + "RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU\n" +
"RDATE:19920503T000000\n" +
"END:DAYLIGHT\n" + "END:DAYLIGHT\n" +
"BEGIN:STANDARD\n" + "BEGIN:STANDARD\n" +
"TZOFFSETFROM:-0400\n" + "DTSTART:20101031T030000\n" +
"DTSTART:19930404T000000\n" + "TZOFFSETTO:+0100\n" +
"TZNAME:COT\n" + "TZOFFSETFROM:+0200\n" +
"TZOFFSETTO:-0500\n" + "RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU\n" +
"RDATE:19930404T000000\n" +
"END:STANDARD\n" + "END:STANDARD\n" +
"END:VTIMEZONE\n" + "END:VTIMEZONE\n" +
"BEGIN:VEVENT\n" + "BEGIN:VEVENT\n" +
"CREATED:20110804T203742Z\n" + "UID:1BDEA2053DF34221AAD74B15755B6B89\n" +
"UID:1E17151D-92DA-4D2E-9747-60B489DE56F4\n" + "LAST-MODIFIED:20111205T102048Z\n" +
"DTEND;TZID=America/Bogota:20110805T090000\n" + "SUMMARY:Roland Test\n" +
"DESCRIPTION:\n" +
"CLASS:PUBLIC\n" +
"DTSTART;TZID=Europe/Berlin:20120205T113000\n" +
"DTEND;TZID=Europe/Berlin:20120205T120000\n" +
"DTSTAMP:20111205T102305Z\n" +
"TRANSP:OPAQUE\n" + "TRANSP:OPAQUE\n" +
"SUMMARY:New Event 2\n" + "STATUS:CONFIRMED\n" +
"DTSTART;TZID=America/Bogota:20110805T080000\n" + "X-MICROSOFT-CDO-BUSYSTATUS:BUSY\n" +
"DTSTAMP:20110804T203742Z\n" +
"SEQUENCE:0\n" +
"END:VEVENT\n" + "END:VEVENT\n" +
"END:VCALENDAR"; "END:VCALENDAR";
String itemName = UUID.randomUUID().toString() + ".EML"; String itemName = UUID.randomUUID().toString() + ".EML";
@ -249,154 +266,41 @@ public class TestExchangeSessionCalendar extends AbstractExchangeSessionTestCase
public void testCreateEventBrokenTZ() throws IOException { public void testCreateEventBrokenTZ() throws IOException {
String itemBody = "BEGIN:VCALENDAR\n" + String itemBody = "BEGIN:VCALENDAR\n" +
"PRODID:-//K Desktop Environment//NONSGML libkcal 4.3//EN\n" + "CALSCALE:GREGORIAN\n" +
"PRODID:-//Ximian//NONSGML Evolution Calendar//EN\n" +
"VERSION:2.0\n" + "VERSION:2.0\n" +
"METHOD:PUBLISH\n" + "METHOD:PUBLISH\n" +
"BEGIN:VTIMEZONE\n" + "BEGIN:VTIMEZONE\n" +
"TZID:Europe/Amsterdam\n" + "TZID:Asia/Jerusalem\n" +
"BEGIN:DAYLIGHT\n" + "X-LIC-LOCATION:Asia/Jerusalem\n" +
"TZNAME:NST\n" +
"TZOFFSETFROM:+001932\n" +
"TZOFFSETTO:+011932\n" +
"DTSTART:19160501T234028\n" +
"RDATE;VALUE=DATE-TIME:19160501T234028\n" +
"RDATE;VALUE=DATE-TIME:19170417T014028\n" +
"RDATE;VALUE=DATE-TIME:19180402T014028\n" +
"RDATE;VALUE=DATE-TIME:19190408T014028\n" +
"RDATE;VALUE=DATE-TIME:19200406T014028\n" +
"RDATE;VALUE=DATE-TIME:19210405T014028\n" +
"RDATE;VALUE=DATE-TIME:19220327T014028\n" +
"RDATE;VALUE=DATE-TIME:19230602T014028\n" +
"RDATE;VALUE=DATE-TIME:19240331T014028\n" +
"RDATE;VALUE=DATE-TIME:19250606T014028\n" +
"RDATE;VALUE=DATE-TIME:19260516T014028\n" +
"RDATE;VALUE=DATE-TIME:19270516T014028\n" +
"RDATE;VALUE=DATE-TIME:19280516T014028\n" +
"RDATE;VALUE=DATE-TIME:19290516T014028\n" +
"RDATE;VALUE=DATE-TIME:19300516T014028\n" +
"RDATE;VALUE=DATE-TIME:19310516T014028\n" +
"RDATE;VALUE=DATE-TIME:19320523T014028\n" +
"RDATE;VALUE=DATE-TIME:19330516T014028\n" +
"RDATE;VALUE=DATE-TIME:19340516T014028\n" +
"RDATE;VALUE=DATE-TIME:19350516T014028\n" +
"RDATE;VALUE=DATE-TIME:19360516T014028\n" +
"RDATE;VALUE=DATE-TIME:19370523T014028\n" +
"END:DAYLIGHT\n" +
"BEGIN:STANDARD\n" + "BEGIN:STANDARD\n" +
"TZNAME:AMT\n" + "DTSTART:19700923T020000\n" +
"TZOFFSETFROM:+011932\n" + "RRULE:FREQ=YEARLY;BYDAY=-2SU;BYMONTH=9\n" +
"TZOFFSETTO:+001932\n" + "TZOFFSETFROM:+0300\n" +
"DTSTART:19161001T224028\n" +
"RDATE;VALUE=DATE-TIME:19161001T224028\n" +
"RDATE;VALUE=DATE-TIME:19170918T024028\n" +
"RDATE;VALUE=DATE-TIME:19181001T024028\n" +
"RDATE;VALUE=DATE-TIME:19190930T024028\n" +
"RDATE;VALUE=DATE-TIME:19200928T024028\n" +
"RDATE;VALUE=DATE-TIME:19210927T024028\n" +
"RDATE;VALUE=DATE-TIME:19221009T024028\n" +
"RDATE;VALUE=DATE-TIME:19231008T024028\n" +
"RDATE;VALUE=DATE-TIME:19241006T024028\n" +
"RDATE;VALUE=DATE-TIME:19251005T024028\n" +
"RDATE;VALUE=DATE-TIME:19261004T024028\n" +
"RDATE;VALUE=DATE-TIME:19271003T024028\n" +
"RDATE;VALUE=DATE-TIME:19281008T024028\n" +
"RDATE;VALUE=DATE-TIME:19291007T024028\n" +
"RDATE;VALUE=DATE-TIME:19301006T024028\n" +
"RDATE;VALUE=DATE-TIME:19311005T024028\n" +
"RDATE;VALUE=DATE-TIME:19321003T024028\n" +
"RDATE;VALUE=DATE-TIME:19331009T024028\n" +
"RDATE;VALUE=DATE-TIME:19341008T024028\n" +
"RDATE;VALUE=DATE-TIME:19351007T024028\n" +
"RDATE;VALUE=DATE-TIME:19361005T024028\n" +
"END:STANDARD\n" +
"BEGIN:DAYLIGHT\n" +
"TZNAME:NEST\n" +
"TZOFFSETFROM:+011932\n" +
"TZOFFSETTO:+0120\n" +
"DTSTART:19370701T224028\n" +
"RDATE;VALUE=DATE-TIME:19370701T224028\n" +
"END:DAYLIGHT\n" +
"BEGIN:STANDARD\n" +
"TZNAME:NET\n" +
"TZOFFSETFROM:+0120\n" +
"TZOFFSETTO:+0020\n" +
"DTSTART:19371004T024028\n" +
"RDATE;VALUE=DATE-TIME:19371004T024028\n" +
"RDATE;VALUE=DATE-TIME:19381003T024000\n" +
"RDATE;VALUE=DATE-TIME:19391009T024000\n" +
"END:STANDARD\n" +
"BEGIN:DAYLIGHT\n" +
"TZNAME:NEST\n" +
"TZOFFSETFROM:+0020\n" +
"TZOFFSETTO:+0120\n" +
"DTSTART:19380516T014000\n" +
"RDATE;VALUE=DATE-TIME:19380516T014000\n" +
"RDATE;VALUE=DATE-TIME:19390516T014000\n" +
"END:DAYLIGHT\n" +
"BEGIN:DAYLIGHT\n" +
"TZNAME:CEST\n" +
"TZOFFSETFROM:+0020\n" +
"TZOFFSETTO:+0200\n" + "TZOFFSETTO:+0200\n" +
"DTSTART:19400516T234000\n" +
"RDATE;VALUE=DATE-TIME:19400516T234000\n" +
"END:DAYLIGHT\n" +
"BEGIN:STANDARD\n" +
"TZNAME:CET\n" +
"TZOFFSETFROM:+0200\n" +
"TZOFFSETTO:+0100\n" +
"DTSTART:19790930T030000\n" +
"RRULE:FREQ=YEARLY;COUNT=17;BYDAY=-1SU;BYMONTH=9\n" +
"END:STANDARD\n" +
"BEGIN:STANDARD\n" +
"TZNAME:CET\n" +
"TZOFFSETFROM:+0200\n" +
"TZOFFSETTO:+0100\n" +
"DTSTART:19961027T030000\n" +
"RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10\n" +
"END:STANDARD\n" +
"BEGIN:STANDARD\n" +
"TZNAME:CET\n" +
"TZOFFSETFROM:+0200\n" +
"TZOFFSETTO:+0100\n" +
"DTSTART:19421103T024000\n" +
"RDATE;VALUE=DATE-TIME:19421103T024000\n" +
"RDATE;VALUE=DATE-TIME:19431004T020000\n" +
"RDATE;VALUE=DATE-TIME:19441002T020000\n" +
"RDATE;VALUE=DATE-TIME:19450916T020000\n" +
"RDATE;VALUE=DATE-TIME:19770925T030000\n" +
"RDATE;VALUE=DATE-TIME:19781001T030000\n" +
"END:STANDARD\n" + "END:STANDARD\n" +
"BEGIN:DAYLIGHT\n" + "BEGIN:DAYLIGHT\n" +
"TZNAME:CEST\n" + "DTSTART:19700330T020000\n" +
"TZOFFSETFROM:+0100\n" + "RRULE:FREQ=YEARLY;BYDAY=-1FR;BYMONTH=3\n" +
"TZOFFSETTO:+0200\n" + "TZOFFSETFROM:+0200\n" +
"DTSTART:19810329T020000\n" + "TZOFFSETTO:+0300\n" +
"RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3\n" +
"END:DAYLIGHT\n" +
"BEGIN:DAYLIGHT\n" +
"TZNAME:CEST\n" +
"TZOFFSETFROM:+0100\n" +
"TZOFFSETTO:+0200\n" +
"DTSTART:19430329T010000\n" +
"RDATE;VALUE=DATE-TIME:19430329T010000\n" +
"RDATE;VALUE=DATE-TIME:19440403T010000\n" +
"RDATE;VALUE=DATE-TIME:19450402T010000\n" +
"RDATE;VALUE=DATE-TIME:19770403T020000\n" +
"RDATE;VALUE=DATE-TIME:19780402T020000\n" +
"RDATE;VALUE=DATE-TIME:19790401T020000\n" +
"RDATE;VALUE=DATE-TIME:19800406T020000\n" +
"END:DAYLIGHT\n" + "END:DAYLIGHT\n" +
"END:VTIMEZONE\n" + "END:VTIMEZONE\n" +
"BEGIN:VEVENT\n" + "BEGIN:VEVENT\n" +
"DTSTAMP:20111022T175835Z\n" + "UID:20120920T061713Z-6599-1001-1-2\n" +
"CREATED:20111022T175832Z\n" + "DTSTAMP:20120920T061713Z\n" +
"UID:libkcal-797112054.882\n" + "DTSTART;TZID=\"Asia/Jerusalem\":2012092\n" +
"LAST-MODIFIED:20111022T175832Z\n" + " 0T093000\n" +
"SUMMARY:Test Event 000\n" + "DTEND;TZID=\"Asia/Jerusalem\":20120920T\n" +
"DTSTART;TZID=\"Europe/Amsterdam\":20111027T120000\n" + " 103000\n" +
"DTEND;TZID=\"Europe/Amsterdam\":20111027T174500\n" +
"TRANSP:OPAQUE\n" + "TRANSP:OPAQUE\n" +
"X-MICROSOFT-CDO-REPLYTIME:20111022T175835Z\n" + "SEQUENCE:3\n" +
"SUMMARY:test\n" +
"CLASS:PUBLIC\n" +
"DESCRIPTION:tEin Test!\n" +
"CREATED:20120920T062017Z\n" +
"LAST-MODIFIED:20120920T062017Z\n" +
"ORGANIZER:MAILTO:shai.berger@healarium.com\n" +
"X-MICROSOFT-CDO-ALLDAYEVENT:FALSE\n" + "X-MICROSOFT-CDO-ALLDAYEVENT:FALSE\n" +
"X-MICROSOFT-CDO-BUSYSTATUS:BUSY\n" + "X-MICROSOFT-CDO-BUSYSTATUS:BUSY\n" +
"END:VEVENT\n" + "END:VEVENT\n" +

View File

@ -22,10 +22,7 @@ import davmail.Settings;
import davmail.util.IOUtil; import davmail.util.IOUtil;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import java.io.ByteArrayOutputStream; import java.io.*;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -485,6 +482,25 @@ public class TestExchangeSessionContact extends AbstractExchangeSessionTestCase
assertEquals("common name", contact.get("cn")); assertEquals("common name", contact.get("cn"));
} }
public void testSpecialUrlCharacters3F() throws IOException {
testCreateFolder();
VCardWriter vCardWriter = new VCardWriter();
vCardWriter.startCard();
vCardWriter.appendProperty("N", "sn", "givenName", "middlename", "personaltitle", "namesuffix");
vCardWriter.appendProperty("FN", "common name");
vCardWriter.endCard();
itemName = "test ?.vcf";
ExchangeSession.ItemResult result = session.createOrUpdateContact("testcontactfolder", itemName, vCardWriter.toString(), null, null);
assertEquals(201, result.status);
ExchangeSession.Contact contact = getCurrentContact();
assertEquals("common name", contact.get("cn"));
}
public void testPagingSearchContacts() throws IOException { public void testPagingSearchContacts() throws IOException {
int maxCount = 0; int maxCount = 0;
List<ExchangeSession.Contact> contacts = session.searchContacts(ExchangeSession.CONTACTS, ExchangeSession.CONTACT_ATTRIBUTES, null, maxCount); List<ExchangeSession.Contact> contacts = session.searchContacts(ExchangeSession.CONTACTS, ExchangeSession.CONTACT_ATTRIBUTES, null, maxCount);
@ -493,4 +509,25 @@ public class TestExchangeSessionContact extends AbstractExchangeSessionTestCase
assertEquals(folderSize, session.searchContacts(ExchangeSession.CONTACTS, ExchangeSession.CONTACT_ATTRIBUTES, null, folderSize+1).size()); assertEquals(folderSize, session.searchContacts(ExchangeSession.CONTACTS, ExchangeSession.CONTACT_ATTRIBUTES, null, folderSize+1).size());
} }
public void testHashInName() throws IOException {
testCreateFolder();
VCardWriter vCardWriter = new VCardWriter();
vCardWriter.startCard();
vCardWriter.appendProperty("N", "sn", "givenName", "middlename", "personaltitle", "namesuffix");
vCardWriter.appendProperty("FN", "common name");
vCardWriter.endCard();
itemName = "Capital 7654#.vcf";
ExchangeSession.ItemResult result = session.createOrUpdateContact("testcontactfolder", itemName, vCardWriter.toString(), null, null);
assertEquals(201, result.status);
ExchangeSession.Contact contact = getCurrentContact();
assertEquals("common name", contact.get("cn"));
}
} }

View File

@ -383,6 +383,228 @@ public class TestExchangeSessionEvent extends TestCase {
"END:VCALENDAR"; "END:VCALENDAR";
String toClient = fixICS(icsBody, true); String toClient = fixICS(icsBody, true);
System.out.println(toClient); System.out.println(toClient);
}
public void testInvalidTimezone() throws IOException {
String icsBody = "BEGIN:VCALENDAR\n" +
"PRODID:-//K Desktop Environment//NONSGML libkcal 4.3//EN\n" +
"VERSION:2.0\n" +
"METHOD:PUBLISH\n" +
"BEGIN:VTIMEZONE\n" +
"TZID:Europe/Amsterdam\n" +
"BEGIN:DAYLIGHT\n" +
"TZNAME:NST\n" +
"TZOFFSETFROM:+001932\n" +
"TZOFFSETTO:+011932\n" +
"DTSTART:19160501T234028\n" +
"RDATE;VALUE=DATE-TIME:19160501T234028\n" +
"RDATE;VALUE=DATE-TIME:19170417T014028\n" +
"RDATE;VALUE=DATE-TIME:19180402T014028\n" +
"RDATE;VALUE=DATE-TIME:19190408T014028\n" +
"RDATE;VALUE=DATE-TIME:19200406T014028\n" +
"RDATE;VALUE=DATE-TIME:19210405T014028\n" +
"RDATE;VALUE=DATE-TIME:19220327T014028\n" +
"RDATE;VALUE=DATE-TIME:19230602T014028\n" +
"RDATE;VALUE=DATE-TIME:19240331T014028\n" +
"RDATE;VALUE=DATE-TIME:19250606T014028\n" +
"RDATE;VALUE=DATE-TIME:19260516T014028\n" +
"RDATE;VALUE=DATE-TIME:19270516T014028\n" +
"RDATE;VALUE=DATE-TIME:19280516T014028\n" +
"RDATE;VALUE=DATE-TIME:19290516T014028\n" +
"RDATE;VALUE=DATE-TIME:19300516T014028\n" +
"RDATE;VALUE=DATE-TIME:19310516T014028\n" +
"RDATE;VALUE=DATE-TIME:19320523T014028\n" +
"RDATE;VALUE=DATE-TIME:19330516T014028\n" +
"RDATE;VALUE=DATE-TIME:19340516T014028\n" +
"RDATE;VALUE=DATE-TIME:19350516T014028\n" +
"RDATE;VALUE=DATE-TIME:19360516T014028\n" +
"RDATE;VALUE=DATE-TIME:19370523T014028\n" +
"END:DAYLIGHT\n" +
"BEGIN:STANDARD\n" +
"TZNAME:AMT\n" +
"TZOFFSETFROM:+011932\n" +
"TZOFFSETTO:+001932\n" +
"DTSTART:19161001T224028\n" +
"RDATE;VALUE=DATE-TIME:19161001T224028\n" +
"RDATE;VALUE=DATE-TIME:19170918T024028\n" +
"RDATE;VALUE=DATE-TIME:19181001T024028\n" +
"RDATE;VALUE=DATE-TIME:19190930T024028\n" +
"RDATE;VALUE=DATE-TIME:19200928T024028\n" +
"RDATE;VALUE=DATE-TIME:19210927T024028\n" +
"RDATE;VALUE=DATE-TIME:19221009T024028\n" +
"RDATE;VALUE=DATE-TIME:19231008T024028\n" +
"RDATE;VALUE=DATE-TIME:19241006T024028\n" +
"RDATE;VALUE=DATE-TIME:19251005T024028\n" +
"RDATE;VALUE=DATE-TIME:19261004T024028\n" +
"RDATE;VALUE=DATE-TIME:19271003T024028\n" +
"RDATE;VALUE=DATE-TIME:19281008T024028\n" +
"RDATE;VALUE=DATE-TIME:19291007T024028\n" +
"RDATE;VALUE=DATE-TIME:19301006T024028\n" +
"RDATE;VALUE=DATE-TIME:19311005T024028\n" +
"RDATE;VALUE=DATE-TIME:19321003T024028\n" +
"RDATE;VALUE=DATE-TIME:19331009T024028\n" +
"RDATE;VALUE=DATE-TIME:19341008T024028\n" +
"RDATE;VALUE=DATE-TIME:19351007T024028\n" +
"RDATE;VALUE=DATE-TIME:19361005T024028\n" +
"END:STANDARD\n" +
"BEGIN:DAYLIGHT\n" +
"TZNAME:NEST\n" +
"TZOFFSETFROM:+011932\n" +
"TZOFFSETTO:+0120\n" +
"DTSTART:19370701T224028\n" +
"RDATE;VALUE=DATE-TIME:19370701T224028\n" +
"END:DAYLIGHT\n" +
"BEGIN:STANDARD\n" +
"TZNAME:NET\n" +
"TZOFFSETFROM:+0120\n" +
"TZOFFSETTO:+0020\n" +
"DTSTART:19371004T024028\n" +
"RDATE;VALUE=DATE-TIME:19371004T024028\n" +
"RDATE;VALUE=DATE-TIME:19381003T024000\n" +
"RDATE;VALUE=DATE-TIME:19391009T024000\n" +
"END:STANDARD\n" +
"BEGIN:DAYLIGHT\n" +
"TZNAME:NEST\n" +
"TZOFFSETFROM:+0020\n" +
"TZOFFSETTO:+0120\n" +
"DTSTART:19380516T014000\n" +
"RDATE;VALUE=DATE-TIME:19380516T014000\n" +
"RDATE;VALUE=DATE-TIME:19390516T014000\n" +
"END:DAYLIGHT\n" +
"BEGIN:DAYLIGHT\n" +
"TZNAME:CEST\n" +
"TZOFFSETFROM:+0020\n" +
"TZOFFSETTO:+0200\n" +
"DTSTART:19400516T234000\n" +
"RDATE;VALUE=DATE-TIME:19400516T234000\n" +
"END:DAYLIGHT\n" +
"BEGIN:STANDARD\n" +
"TZNAME:CET\n" +
"TZOFFSETFROM:+0200\n" +
"TZOFFSETTO:+0100\n" +
"DTSTART:19790930T030000\n" +
"RRULE:FREQ=YEARLY;COUNT=17;BYDAY=-1SU;BYMONTH=9\n" +
"END:STANDARD\n" +
"BEGIN:STANDARD\n" +
"TZNAME:CET\n" +
"TZOFFSETFROM:+0200\n" +
"TZOFFSETTO:+0100\n" +
"DTSTART:19961027T030000\n" +
"RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10\n" +
"END:STANDARD\n" +
"BEGIN:STANDARD\n" +
"TZNAME:CET\n" +
"TZOFFSETFROM:+0200\n" +
"TZOFFSETTO:+0100\n" +
"DTSTART:19421103T024000\n" +
"RDATE;VALUE=DATE-TIME:19421103T024000\n" +
"RDATE;VALUE=DATE-TIME:19431004T020000\n" +
"RDATE;VALUE=DATE-TIME:19441002T020000\n" +
"RDATE;VALUE=DATE-TIME:19450916T020000\n" +
"RDATE;VALUE=DATE-TIME:19770925T030000\n" +
"RDATE;VALUE=DATE-TIME:19781001T030000\n" +
"END:STANDARD\n" +
"BEGIN:DAYLIGHT\n" +
"TZNAME:CEST\n" +
"TZOFFSETFROM:+0100\n" +
"TZOFFSETTO:+0200\n" +
"DTSTART:19810329T020000\n" +
"RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3\n" +
"END:DAYLIGHT\n" +
"BEGIN:DAYLIGHT\n" +
"TZNAME:CEST\n" +
"TZOFFSETFROM:+0100\n" +
"TZOFFSETTO:+0200\n" +
"DTSTART:19430329T010000\n" +
"RDATE;VALUE=DATE-TIME:19430329T010000\n" +
"RDATE;VALUE=DATE-TIME:19440403T010000\n" +
"RDATE;VALUE=DATE-TIME:19450402T010000\n" +
"RDATE;VALUE=DATE-TIME:19770403T020000\n" +
"RDATE;VALUE=DATE-TIME:19780402T020000\n" +
"RDATE;VALUE=DATE-TIME:19790401T020000\n" +
"RDATE;VALUE=DATE-TIME:19800406T020000\n" +
"END:DAYLIGHT\n" +
"END:VTIMEZONE\n" +
"BEGIN:VEVENT\n" +
"DTSTAMP:20111022T175835Z\n" +
"CREATED:20111022T175832Z\n" +
"UID:libkcal-797112054.882\n" +
"LAST-MODIFIED:20111022T175832Z\n" +
"SUMMARY:Test Event 000\n" +
"DTSTART;TZID=\"Europe/Amsterdam\":20111027T120000\n" +
"DTEND;TZID=\"Europe/Amsterdam\":20111027T174500\n" +
"TRANSP:OPAQUE\n" +
"X-MICROSOFT-CDO-REPLYTIME:20111022T175835Z\n" +
"X-MICROSOFT-CDO-ALLDAYEVENT:FALSE\n" +
"X-MICROSOFT-CDO-BUSYSTATUS:BUSY\n" +
"END:VEVENT\n" +
"END:VCALENDAR";
String toServer = fixICS(icsBody, false);
System.out.println(toServer);
}
public void testResourceComma() throws IOException {
String icsBody = "BEGIN:VCALENDAR\n" +
"PRODID:-//Microsoft Corporation//Outlook 14.0 MIMEDIR//EN\n" +
"VERSION:2.0\n" +
"METHOD:REQUEST\n" +
"X-MS-OLK-FORCEINSPECTOROPEN:TRUE\n" +
"BEGIN:VTIMEZONE\n" +
"TZID:Eastern Standard Time\n" +
"BEGIN:STANDARD\n" +
"DTSTART:16011104T020000\n" +
"RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11\n" +
"TZOFFSETFROM:-0400\n" +
"TZOFFSETTO:-0500\n" +
"END:STANDARD\n" +
"BEGIN:DAYLIGHT\n" +
"DTSTART:16010311T020000\n" +
"RRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3\n" +
"TZOFFSETFROM:-0500\n" +
"TZOFFSETTO:-0400\n" +
"END:DAYLIGHT\n" +
"END:VTIMEZONE\n" +
"BEGIN:VEVENT\n" +
"ATTENDEE;CN=Robert.P.Lindman@delphi.com;RSVP=TRUE:mailto:Robert.P.Lindman@d\n" +
"\telphi.com\n" +
"ATTENDEE;CN=\"CRUSINKOK, CTC4B\";CUTYPE=RESOURCE;ROLE=NON-PARTICIPANT;RSVP=TR\n" +
"\tUE:mailto:ctc4b.crusinkok@delphi.com\n" +
"CLASS:PUBLIC\n" +
"CREATED:20111020T134050Z\n" +
"DESCRIPTION:Sample meeting with a conference room added\\n\n" +
"DTEND;TZID=\"Eastern Standard Time\":20111021T060000\n" +
"DTSTAMP:20111020T134035Z\n" +
"DTSTART;TZID=\"Eastern Standard Time\":20111021T053000\n" +
"LAST-MODIFIED:20111020T134050Z\n" +
"LOCATION:CRUSINKOK\\, CTC4B\n" +
"ORGANIZER;CN=\"Lindman, Robert P\":mailto:Robert.P.Lindman@delphi.com\n" +
"PRIORITY:5\n" +
"RESOURCES:CRUSINKOK\\, CTC4A,CRUSINKOK\\, CTC4C,CRUSINKOK\\, CTC4D,CRUSINKOK\\,\n" +
"\t CTC4E,CRUSINKOK\\, CTC3A,CRUSINKOK\\, CTC3B,CRUSINKOK\\, CTC3C,CRUSINKOK\\, C\n" +
"\tTC3D,CRUSINKOK\\, CTC2A,CRUSINKOK\\, CTC2B,CRUSINKOK\\, CTC2C,CRUSINKOK\\, CTC\n" +
"\t2D,CRUSINKOK\\, CTC1A,CRUSINKOK\\, CTC1B,CRUSINKOK\\, CTC1C,CRUSINKOK\\, CTC1D\n" +
"\t,CRUSINKOK\\, CTC1E1\n" +
"SEQUENCE:1\n" +
"SUMMARY;LANGUAGE=en-us:Sample Meeting\n" +
"TRANSP:OPAQUE\n" +
"UID:040000008200E00074C5B7101A82E0080000000090B4D422078FCC01000000000000000\n" +
"\t0100000000AFB9CCA2DE4D54794C2D688292D570B\n" +
"X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//E\n" +
"\tN\">\\n<HTML>\\n<HEAD>\\n<META NAME=\"Generator\" CONTENT=\"MS Exchange Server ve\n" +
"\trsion 08.01.0240.003\">\\n<TITLE></TITLE>\\n</HEAD>\\n<BODY>\\n<!-- Converted f\n" +
"\trom text/rtf format -->\\n\\n<P DIR=LTR><SPAN LANG=\"en-us\"><FONT FACE=\"Calib\n" +
"\tri\">Sample meeting with a conference room added</FONT></SPAN><SPAN LANG=\"e\n" +
"\tn-us\"></SPAN></P>\\n\\n</BODY>\\n</HTML>\n" +
"X-MICROSOFT-CDO-BUSYSTATUS:BUSY\n" +
"X-MICROSOFT-CDO-IMPORTANCE:1\n" +
"X-MICROSOFT-DISALLOW-COUNTER:FALSE\n" +
"X-MS-OLK-APPTLASTSEQUENCE:1\n" +
"X-MS-OLK-APPTSEQTIME:20111020T134035Z\n" +
"X-MS-OLK-AUTOFILLLOCATION:TRUE\n" +
"X-MS-OLK-CONFTYPE:0\n" +
"END:VEVENT\n" +
"END:VCALENDAR";
String toClient = fixICS(icsBody, true);
System.out.println(toClient);
} }
} }

View File

@ -47,6 +47,11 @@ public class TestExchangeSessionMessage extends AbstractExchangeSessionTestCase
assertNotNull(messageList); assertNotNull(messageList);
} }
public void testSearchTrash() throws IOException, MessagingException {
ExchangeSession.MessageList messageList = session.searchMessages("Trash");
assertNotNull(messageList);
}
public void testSearchMessage() throws IOException, MessagingException { public void testSearchMessage() throws IOException, MessagingException {
ExchangeSession.MessageList messageList = session.searchMessages("testfolder"); ExchangeSession.MessageList messageList = session.searchMessages("testfolder");
assertNotNull(messageList); assertNotNull(messageList);
@ -147,4 +152,10 @@ public class TestExchangeSessionMessage extends AbstractExchangeSessionTestCase
public void testDeleteFolder() throws IOException { public void testDeleteFolder() throws IOException {
session.deleteFolder("testfolder"); session.deleteFolder("testfolder");
} }
public void testSearchAaa() throws IOException, MessagingException {
ExchangeSession.MessageList messageList = session.searchMessages("aabb");
assertNotNull(messageList);
}
} }

View File

@ -79,4 +79,73 @@ public class TestICSBufferedReader extends TestCase {
} }
assertEquals("END:VCALENDAR", lastLine); assertEquals("END:VCALENDAR", lastLine);
} }
public void testBrokenAttendee() throws IOException {
String itemBody = "BEGIN:VCALENDAR\n" +
"BEGIN:VEVENT\n" +
"ATTENDEE;CN=\"Daniel " +
"William Doe\";PARTSTAT=ACCEPTED;RSVP=TRUE:MAILTO:email@company.com\n" +
"END:VEVENT\n" +
"END:VCALENDAR";
VObject vcalendar = new VCalendar(new ICSBufferedReader(new StringReader(itemBody)), "email@company.com", null);
System.out.println(vcalendar);
}
public void testBrokenTask() throws IOException {
String value = "BEGIN:VCALENDAR\n" +
"BEGIN:VTIMEZONE\n" +
"TZID:Central Standard Time\n" +
"BEGIN:STANDARD\n" +
"DTSTART:16010101T020000\n" +
"TZOFFSETFROM:-0500\n" +
"TZOFFSETTO:-0600\n" +
"RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11\n" +
"END:STANDARD\n" +
"BEGIN:DAYLIGHT\n" +
"DTSTART:16010101T020000\n" +
"TZOFFSETFROM:-0600\n" +
"TZOFFSETTO:-0500\n" +
"RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3\n" +
"END:DAYLIGHT\n" +
"END:VTIMEZONE\n" +
"BEGIN:VTODO\n" +
"LAST-MODIFIED:20110606T080802Z\n" +
"CREATED:20110527T085302Z\n" +
"UID:AAMkADQwOGRjMjIyLTQwNDUtNDE5OS05YWExLWZlOTM5Yjc2NTg0YgBGAAAAAAAi3Ph1JgynT\n" +
" ILoGH8BTtfjBwAzPlOmuBONTIJTcNQH4CUkAAAAAACEAABeoDOEjEPERLNIwtCsV4KdAAABv75hA\n" +
" AA=\n" +
"SUMMARY:Get everyone view the videos\n" +
"DESCRIPTION:They are on local dev server. Update on-boarding correspondingly\n" +
" \\n\n" +
"PERCENT-COMPLETE:100\n" +
"STATUS:COMPLETED\n" +
"DUE;VALUE=DATE:20110527\n" +
"DTSTART;VALUE=DATE:20110527\n" +
"COMPLETED;VALUE=DATE:20110605\n" +
"END:VTODO\n" +
"END:VCALENDAR";
ICSBufferedReader reader = new ICSBufferedReader(new StringReader(value));
String line;
String lastLine = null;
while ((line =reader.readLine())!= null) {
System.out.println(line);
lastLine = line;
}
assertEquals("END:VCALENDAR", lastLine);
new VCalendar(value, null, null);
}
public void testVCard() throws IOException {
String itemBody = "BEGIN:VCARD\n" +
"VERSION:3.0\n" +
"PRODID:-//Inverse inc.//SOGo Connector 1.0//EN\n" +
"UID:C54E78FE-98B0-0001-2339-1D761540DA50\n" +
"N:bb;aa\n" +
"FN:aa bb\n" +
"X-MOZILLA-HTML:FALSE\n" +
"REV:20120713T130308Z\n" +
"END:VCARD\n" +
"\n";
VObject vcard = new VObject(new ICSBufferedReader(new StringReader(itemBody)));
}
} }

View File

@ -37,4 +37,12 @@ public class TestVProperty extends TestCase {
assertNotNull(vProperty); assertNotNull(vProperty);
assertEquals(line, vProperty.toString()); assertEquals(line, vProperty.toString());
} }
public void testBackslash() {
String line = "SUMMARY:Electric Meter change 08:30\\";
VProperty vProperty = new VProperty(line);
assertNotNull(vProperty);
assertEquals(line, vProperty.toString());
}
} }

View File

@ -488,4 +488,17 @@ public class TestImap extends AbstractImapTestCase {
writeLine(". UID FETCH "+messageUid+":* (INTERNALDATE UID RFC822.SIZE FLAGS BODY.PEEK[HEADER.FIELDS (date subject from to cc message-id in-reply-to references x-priority x-uniform-type-identifier x-universally-unique-identifier received-spf x-spam-status x-spam-flag)])"); writeLine(". UID FETCH "+messageUid+":* (INTERNALDATE UID RFC822.SIZE FLAGS BODY.PEEK[HEADER.FIELDS (date subject from to cc message-id in-reply-to references x-priority x-uniform-type-identifier x-universally-unique-identifier received-spf x-spam-status x-spam-flag)])");
assertEquals(". OK UID FETCH completed", readFullAnswer(".")); assertEquals(". OK UID FETCH completed", readFullAnswer("."));
} }
public void testSelectInboxTimeout() throws IOException {
writeLine(". SELECT INBOX");
// simulate client timeout
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// ignore
}
socketWriter.close();
System.in.read();
}
} }

View File

@ -50,13 +50,14 @@ public class TestLdap extends AbstractExchangeSessionTestCase {
} }
if (ldapContext == null) { if (ldapContext == null) {
Hashtable<String, String> env = new Hashtable<String, String>(); Hashtable<String, String> env = new Hashtable<String, String>();
//env.put("java.naming.security.authentication", "CRAM-MD5");
env.put("java.naming.security.authentication", "simple"); env.put("java.naming.security.authentication", "simple");
env.put("java.naming.security.principal", Settings.getProperty("davmail.username")); env.put("java.naming.security.principal", Settings.getProperty("davmail.username"));
env.put("java.naming.security.credentials", Settings.getProperty("davmail.password")); env.put("java.naming.security.credentials", Settings.getProperty("davmail.password"));
env.put("com.sun.jndi.ldap.connect.pool", "true"); env.put("com.sun.jndi.ldap.connect.pool", "true");
env.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory"); env.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory");
env.put("java.naming.provider.url", "ldap://localhost:" + Settings.getIntProperty("davmail.ldapPort")); env.put("java.naming.provider.url", "ldap://127.0.0.1:" + Settings.getIntProperty("davmail.ldapPort"));
env.put("java.naming.referral", "follow"); env.put("java.naming.referral", "follow");
try { try {
@ -168,4 +169,28 @@ public class TestLdap extends AbstractExchangeSessionTestCase {
searchControls.setReturningAttributes(new String[]{"mail"}); searchControls.setReturningAttributes(new String[]{"mail"});
NamingEnumeration<SearchResult> searchResults = ldapContext.search("ou=people", "(!(objectclass=test))", searchControls); NamingEnumeration<SearchResult> searchResults = ldapContext.search("ou=people", "(!(objectclass=test))", searchControls);
} }
public void testEmailSearch() throws NamingException {
SearchControls searchControls = new SearchControls();
searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
searchControls.setReturningAttributes(new String[]{"uid", "mail", "sn", "cn", "description", "apple-generateduid", "givenname", "apple-serviceslocator", "uidnumber"});
NamingEnumeration<SearchResult> searchResults = ldapContext.search("cn=users, o=od",
"(mail="+"CHARLEPG@intersmtp.com"+")", searchControls);
}
public void testIcalLionInitialSearch() throws NamingException {
SearchControls searchControls = new SearchControls();
searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
searchControls.setReturningAttributes(new String[]{"gidnumber", "altsecurityidentities", "uid", "mail", "cn", "apple-generateduid", "givenname", "apple-serviceslocator", "objectclass", "uidnumber"});
NamingEnumeration<SearchResult> searchResults = ldapContext.search("cn=users, ou=people",
"(&(|(mail=702820784)(uid=702820784)(cn=702820784)(altsecurityidentities=702820784))(&(objectclass=extensibleObject)(objectclass=posixAccount)(objectclass=shadowAccount)(objectclass=inetOrgPerson)(objectclass=apple-user)))", searchControls);
}
public void testTBGalSearch() throws NamingException {
SearchControls searchControls = new SearchControls();
searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
searchControls.setReturningAttributes(new String[]{"mail", "cn"});
NamingEnumeration<SearchResult> searchResults = ldapContext.search("ou=people",
"(|(sn=mich*)(mail=mich*)(cn=mich*))", searchControls);
}
} }

View File

@ -24,6 +24,7 @@ import davmail.Settings;
import davmail.exchange.DoubleDotOutputStream; import davmail.exchange.DoubleDotOutputStream;
import davmail.exchange.ExchangeSession; import davmail.exchange.ExchangeSession;
import davmail.exchange.ExchangeSessionFactory; import davmail.exchange.ExchangeSessionFactory;
import davmail.util.IOUtil;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import javax.mail.MessagingException; import javax.mail.MessagingException;
@ -152,6 +153,7 @@ public class TestSmtp extends AbstractDavMailTestCase {
public void testSendSimpleMessage() throws IOException, MessagingException, InterruptedException { public void testSendSimpleMessage() throws IOException, MessagingException, InterruptedException {
String body = "Test message"; String body = "Test message";
MimeMessage mimeMessage = new MimeMessage((Session) null); MimeMessage mimeMessage = new MimeMessage((Session) null);
mimeMessage.addHeader("From", session.getEmail());
mimeMessage.addHeader("To", Settings.getProperty("davmail.to")); mimeMessage.addHeader("To", Settings.getProperty("davmail.to"));
mimeMessage.setSubject("Test subject"); mimeMessage.setSubject("Test subject");
mimeMessage.setText(body); mimeMessage.setText(body);
@ -245,10 +247,4 @@ public class TestSmtp extends AbstractDavMailTestCase {
sendAndCheckMessage(mimeMessage); sendAndCheckMessage(mimeMessage);
} }
public void testBrokenMessage2() throws MessagingException, IOException, InterruptedException {
MimeMessage mimeMessage = new MimeMessage(null, new org.apache.commons.codec.binary.Base64InputStream(new FileInputStream("broken64.txt")));
mimeMessage.addHeader("To", Settings.getProperty("davmail.to"));
sendAndCheckMessage(mimeMessage);
}
} }