Search in sources :

Example 41 with ServerSettings

use of com.fsck.k9.mail.ServerSettings in project k-9 by k9mail.

the class ImapStoreUriTest method testDecodeStoreUriImapAllExtras.

@Test
public void testDecodeStoreUriImapAllExtras() {
    String uri = "imap://PLAIN:user:pass@server:143/0%7CcustomPathPrefix";
    ServerSettings settings = RemoteStore.decodeStoreUri(uri);
    assertEquals(AuthType.PLAIN, settings.authenticationType);
    assertEquals("user", settings.username);
    assertEquals("pass", settings.password);
    assertEquals("server", settings.host);
    assertEquals(143, settings.port);
    assertEquals("false", settings.getExtra().get("autoDetectNamespace"));
    assertEquals("customPathPrefix", settings.getExtra().get("pathPrefix"));
}
Also used : ServerSettings(com.fsck.k9.mail.ServerSettings) Test(org.junit.Test)

Example 42 with ServerSettings

use of com.fsck.k9.mail.ServerSettings in project k-9 by k9mail.

the class ImapStoreUriTest method testCreateStoreUriImapAutoDetectNamespace.

@Test
public void testCreateStoreUriImapAutoDetectNamespace() {
    Map<String, String> extra = new HashMap<String, String>();
    extra.put("autoDetectNamespace", "true");
    ServerSettings settings = new ServerSettings(ServerSettings.Type.IMAP, "server", 143, ConnectionSecurity.NONE, AuthType.PLAIN, "user", "pass", null, extra);
    String uri = RemoteStore.createStoreUri(settings);
    assertEquals("imap://PLAIN:user:pass@server:143/1%7C", uri);
}
Also used : HashMap(java.util.HashMap) ServerSettings(com.fsck.k9.mail.ServerSettings) Test(org.junit.Test)

Example 43 with ServerSettings

use of com.fsck.k9.mail.ServerSettings in project k-9 by k9mail.

the class ImapStoreUriTest method testDecodeStoreUriImapXOAuth2.

@Test
public void testDecodeStoreUriImapXOAuth2() {
    String uri = "imap://XOAUTH2:user:@server/";
    ServerSettings settings = RemoteStore.decodeStoreUri(uri);
    assertEquals(AuthType.XOAUTH2, settings.authenticationType);
    assertEquals("user", settings.username);
    assertEquals(null, settings.password);
    assertEquals(null, settings.clientCertificateAlias);
    assertEquals("server", settings.host);
}
Also used : ServerSettings(com.fsck.k9.mail.ServerSettings) Test(org.junit.Test)

Example 44 with ServerSettings

use of com.fsck.k9.mail.ServerSettings in project k-9 by k9mail.

the class ImapStoreUriTest method testDecodeStoreUriImapSSL.

@Test
public void testDecodeStoreUriImapSSL() {
    String uri = "imap+tls+://PLAIN:user:pass@server/";
    ServerSettings settings = RemoteStore.decodeStoreUri(uri);
    assertEquals(ConnectionSecurity.STARTTLS_REQUIRED, settings.connectionSecurity);
    assertEquals(AuthType.PLAIN, settings.authenticationType);
    assertEquals("user", settings.username);
    assertEquals("pass", settings.password);
    assertEquals("server", settings.host);
}
Also used : ServerSettings(com.fsck.k9.mail.ServerSettings) Test(org.junit.Test)

Example 45 with ServerSettings

use of com.fsck.k9.mail.ServerSettings in project k-9 by k9mail.

the class ImapStoreUriTest method testDecodeStoreUriImapAutodetectAndPrefix.

@Test
public void testDecodeStoreUriImapAutodetectAndPrefix() {
    String uri = "imap://PLAIN:user:pass@server:143/1%7CcustomPathPrefix";
    ServerSettings settings = RemoteStore.decodeStoreUri(uri);
    assertEquals(AuthType.PLAIN, settings.authenticationType);
    assertEquals("user", settings.username);
    assertEquals("pass", settings.password);
    assertEquals("server", settings.host);
    assertEquals(143, settings.port);
    assertEquals("true", settings.getExtra().get("autoDetectNamespace"));
    assertNull(settings.getExtra().get("pathPrefix"));
}
Also used : ServerSettings(com.fsck.k9.mail.ServerSettings) Test(org.junit.Test)

Aggregations

ServerSettings (com.fsck.k9.mail.ServerSettings)45 Test (org.junit.Test)34 URISyntaxException (java.net.URISyntaxException)9 AuthType (com.fsck.k9.mail.AuthType)8 URI (java.net.URI)7 HashMap (java.util.HashMap)5 ConnectionSecurity (com.fsck.k9.mail.ConnectionSecurity)4 InvalidSettingValueException (com.fsck.k9.preferences.Settings.InvalidSettingValueException)2 Map (java.util.Map)2 SharedPreferences (android.content.SharedPreferences)1 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)1 Account (com.fsck.k9.Account)1 Preferences (com.fsck.k9.Preferences)1 Store (com.fsck.k9.mail.Store)1 RemoteStore (com.fsck.k9.mail.store.RemoteStore)1 StoreConfig (com.fsck.k9.mail.store.StoreConfig)1 ImapStoreSettings (com.fsck.k9.mail.store.imap.ImapStoreSettings)1 WebDavStoreSettings (com.fsck.k9.mail.store.webdav.WebDavStoreSettings)1 SettingsDescription (com.fsck.k9.preferences.Settings.SettingsDescription)1 ArrayList (java.util.ArrayList)1