JAMES-1982 Add integration test for some CLI commands
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/b052f86a Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/b052f86a Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/b052f86a Branch: refs/heads/master Commit: b052f86a7a1919f2eabcae7c687e024b431b9522 Parents: 8942eaf Author: benwa <btell...@linagora.com> Authored: Sat Apr 1 12:11:14 2017 +0700 Committer: benwa <btell...@linagora.com> Committed: Mon Apr 3 18:09:32 2017 +0700 ---------------------------------------------------------------------- server/container/cli-integration/pom.xml | 237 +++++++++++++++++++ .../james/cli/DataCommandsIntegrationTest.java | 168 +++++++++++++ .../cli/MailboxCommandsIntegrationTest.java | 102 ++++++++ .../james/cli/QuotaCommandsIntegrationTest.java | 105 ++++++++ .../cli/SieveQuotaCommandsIntegrationTest.java | 118 +++++++++ .../src/test/resources/conf/jmx.properties | 22 ++ .../src/test/resources/dnsservice.xml | 29 +++ .../src/test/resources/imapserver.xml | 54 +++++ .../src/test/resources/jmap.properties | 11 + .../src/test/resources/jwt_publickey | 9 + .../src/test/resources/lmtpserver.xml | 41 ++++ .../src/test/resources/logback-test.xml | 15 ++ .../src/test/resources/mailetcontainer.xml | 105 ++++++++ .../src/test/resources/mailrepositorystore.xml | 31 +++ .../src/test/resources/managesieveserver.xml | 65 +++++ .../src/test/resources/pop3server.xml | 42 ++++ .../src/test/resources/smtpserver.xml | 105 ++++++++ .../org/apache/james/MemoryJmapTestRule.java | 13 +- .../james/util/RestrictingRMISocketFactory.java | 8 + server/pom.xml | 1 + 20 files changed, 1276 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/container/cli-integration/pom.xml ---------------------------------------------------------------------- diff --git a/server/container/cli-integration/pom.xml b/server/container/cli-integration/pom.xml new file mode 100644 index 0000000..dbe8f0a --- /dev/null +++ b/server/container/cli-integration/pom.xml @@ -0,0 +1,237 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <artifactId>james-server</artifactId> + <groupId>org.apache.james</groupId> + <version>3.0.0-beta6-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> + </parent> + + <artifactId>james-server-cli-integration</artifactId> + <name>Apache James :: Server :: Cli :: Integretion</name> + + <profiles> + <profile> + <id>disable-build-for-older-jdk</id> + <activation> + <jdk>(,1.8)</jdk> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <executions> + <execution> + <id>default-jar</id> + <phase>none</phase> + </execution> + <execution> + <id>jar</id> + <phase>none</phase> + </execution> + <execution> + <id>test-jar</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <executions> + <execution> + <id>default-compile</id> + <phase>none</phase> + </execution> + <execution> + <id>default-testCompile</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <executions> + <execution> + <id>default-test</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-source-plugin</artifactId> + <executions> + <execution> + <id>attach-sources</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-install-plugin</artifactId> + <executions> + <execution> + <id>default-install</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <executions> + <execution> + <id>default-resources</id> + <phase>none</phase> + </execution> + <execution> + <id>default-testResources</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-site-plugin</artifactId> + <executions> + <execution> + <id>attach-descriptor</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>build-for-jdk-8</id> + <activation> + <jdk>[1.8,)</jdk> + </activation> + <dependencies> + <dependency> + <groupId>org.apache.james</groupId> + <artifactId>james-server-cli</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>james-server-guice-common</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>james-server-guice-jmap</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.james</groupId> + <artifactId>james-server-memory-guice</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.james</groupId> + <artifactId>james-server-memory-guice</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>com.github.fge</groupId> + <artifactId>throwing-lambdas</artifactId> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <version>${assertj-3.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>animal-sniffer-java-8</id> + <activation> + <jdk>[1.8,)</jdk> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>animal-sniffer-maven-plugin</artifactId> + <configuration> + <signature> + <groupId>org.codehaus.mojo.signature</groupId> + <artifactId>java18</artifactId> + <version>1.0</version> + </signature> + </configuration> + <executions> + <execution> + <id>check_java_8</id> + <phase>test</phase> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/container/cli-integration/src/test/java/org/apache/james/cli/DataCommandsIntegrationTest.java ---------------------------------------------------------------------- diff --git a/server/container/cli-integration/src/test/java/org/apache/james/cli/DataCommandsIntegrationTest.java b/server/container/cli-integration/src/test/java/org/apache/james/cli/DataCommandsIntegrationTest.java new file mode 100644 index 0000000..d1e4ee9 --- /dev/null +++ b/server/container/cli-integration/src/test/java/org/apache/james/cli/DataCommandsIntegrationTest.java @@ -0,0 +1,168 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.cli; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; + +import java.util.AbstractMap; + +import javax.inject.Singleton; + +import org.apache.james.GuiceJamesServer; +import org.apache.james.MemoryJmapTestRule; +import org.apache.james.mailbox.inmemory.InMemoryMailboxManager; +import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex; +import org.apache.james.modules.server.JMXServerModule; +import org.apache.james.rrt.lib.MappingImpl; +import org.apache.james.rrt.lib.Mappings; +import org.apache.james.rrt.lib.MappingsImpl; +import org.apache.james.utils.DataProbeImpl; +import org.apache.james.utils.MailboxManagerDefinition; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import com.google.inject.Inject; +import com.google.inject.multibindings.Multibinder; + +public class DataCommandsIntegrationTest { + + public static final String DOMAIN_COM = "domain.com"; + public static final String USER = "user"; + public static final String MAIL_ADDRESS = USER + "@" + DOMAIN_COM; + public static final String PASSWORD = "12345"; + + @Singleton + private static class MemoryMailboxManagerDefinition extends MailboxManagerDefinition { + @Inject + private MemoryMailboxManagerDefinition(InMemoryMailboxManager manager) { + super("memory-mailboxmanager", manager); + } + } + + @Rule + public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule(); + private GuiceJamesServer guiceJamesServer; + private DataProbeImpl dataProbe; + + @Before + public void setUp() throws Exception { + guiceJamesServer = memoryJmap.jmapServer(new JMXServerModule(), + binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class)), + binder -> Multibinder.newSetBinder(binder, MailboxManagerDefinition.class) + .addBinding() + .to(MemoryMailboxManagerDefinition.class)); + guiceJamesServer.start(); + dataProbe = guiceJamesServer.getProbe(DataProbeImpl.class); + } + + @After + public void tearDown() { + guiceJamesServer.stop(); + } + + @Test + public void addDomainShouldWork() throws Exception { + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "ADDDOMAIN", DOMAIN_COM}); + + assertThat(dataProbe.containsDomain(DOMAIN_COM)).isTrue(); + } + + @Test + public void removeDomainShouldWork() throws Exception { + dataProbe.addDomain(DOMAIN_COM); + + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "REMOVEDOMAIN", DOMAIN_COM}); + + assertThat(dataProbe.containsDomain(DOMAIN_COM)).isFalse(); + } + + @Test + public void addUserShouldWork() throws Exception { + dataProbe.addDomain(DOMAIN_COM); + + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "ADDUSER", MAIL_ADDRESS, PASSWORD}); + + assertThat(dataProbe.listUsers()).contains(MAIL_ADDRESS); + } + + @Test + public void removeUserShouldWork() throws Exception { + dataProbe.addDomain(DOMAIN_COM); + dataProbe.addUser(MAIL_ADDRESS, PASSWORD); + + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "REMOVEUSER", MAIL_ADDRESS}); + + assertThat(dataProbe.listUsers()).doesNotContain(MAIL_ADDRESS); + } + + @Test + public void addAddressMappingShouldWork() throws Exception { + String redirectionAddress = "redir...@apache.org"; + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "addaddressmapping", USER, DOMAIN_COM, redirectionAddress}); + + assertThat(dataProbe.listMappings()) + .containsOnly( + new AbstractMap.SimpleEntry<String, Mappings>( + MAIL_ADDRESS, + MappingsImpl.builder() + .add(MappingImpl.address(redirectionAddress)) + .build())); + } + + @Test + public void removeAddressMappingShouldWork() throws Exception { + String redirectionAddress = "redir...@apache.org"; + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "addaddressmapping", USER, DOMAIN_COM, redirectionAddress}); + + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "removeaddressmapping", USER, DOMAIN_COM, redirectionAddress}); + + assertThat(dataProbe.listMappings()) + .isNull(); + } + + @Test + public void addRegexMappingShouldWork() throws Exception { + String regex = "regex"; + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "addregexmapping", USER, DOMAIN_COM, regex}); + + assertThat(dataProbe.listMappings()) + .containsOnly( + new AbstractMap.SimpleEntry<String, Mappings>( + MAIL_ADDRESS, + MappingsImpl.builder() + .add(MappingImpl.regex(regex)) + .build())); + } + + @Test + public void removeRegexMappingShouldWork() throws Exception { + String regex = "regex"; + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "addregexmapping", USER, DOMAIN_COM, regex}); + + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "removeregexmapping", USER, DOMAIN_COM, regex}); + + assertThat(dataProbe.listMappings()) + .isNull(); + } + +} http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/container/cli-integration/src/test/java/org/apache/james/cli/MailboxCommandsIntegrationTest.java ---------------------------------------------------------------------- diff --git a/server/container/cli-integration/src/test/java/org/apache/james/cli/MailboxCommandsIntegrationTest.java b/server/container/cli-integration/src/test/java/org/apache/james/cli/MailboxCommandsIntegrationTest.java new file mode 100644 index 0000000..4aabb44 --- /dev/null +++ b/server/container/cli-integration/src/test/java/org/apache/james/cli/MailboxCommandsIntegrationTest.java @@ -0,0 +1,102 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.cli; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; + +import javax.inject.Singleton; + +import org.apache.james.GuiceJamesServer; +import org.apache.james.MemoryJmapTestRule; +import org.apache.james.mailbox.inmemory.InMemoryMailboxManager; +import org.apache.james.mailbox.model.MailboxConstants; +import org.apache.james.mailbox.model.QuotaRoot; +import org.apache.james.mailbox.store.quota.QuotaRootImpl; +import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex; +import org.apache.james.modules.MailboxProbeImpl; +import org.apache.james.modules.server.JMXServerModule; +import org.apache.james.utils.MailboxManagerDefinition; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import com.google.inject.Inject; +import com.google.inject.multibindings.Multibinder; + +public class MailboxCommandsIntegrationTest { + public static final String USER = "user"; + public static final String MAILBOX = "mailbox"; + + @Singleton + private static class MemoryMailboxManagerDefinition extends MailboxManagerDefinition { + @Inject + private MemoryMailboxManagerDefinition(InMemoryMailboxManager manager) { + super("memory-mailboxmanager", manager); + } + } + + @Rule + public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule(); + private GuiceJamesServer guiceJamesServer; + private MailboxProbeImpl mailboxProbe; + + @Before + public void setUp() throws Exception { + guiceJamesServer = memoryJmap.jmapServer(new JMXServerModule(), + binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class)), + binder -> Multibinder.newSetBinder(binder, MailboxManagerDefinition.class) + .addBinding() + .to(MemoryMailboxManagerDefinition.class)); + guiceJamesServer.start(); + mailboxProbe = guiceJamesServer.getProbe(MailboxProbeImpl.class); + } + + @After + public void tearDown() { + guiceJamesServer.stop(); + } + + @Test + public void createMailboxShouldWork() throws Exception { + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "createmailbox", MailboxConstants.USER_NAMESPACE, USER, MAILBOX}); + + assertThat(mailboxProbe.listUserMailboxes(USER)).containsOnly(MAILBOX); + } + + @Test + public void deleteUserMailboxesShouldWork() throws Exception { + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "createmailbox", MailboxConstants.USER_NAMESPACE, USER, MAILBOX}); + + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "deleteusermailboxes", USER}); + + assertThat(mailboxProbe.listUserMailboxes(USER)).isEmpty(); + } + + @Test + public void deleteMailboxeShouldWork() throws Exception { + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "createmailbox", MailboxConstants.USER_NAMESPACE, USER, MAILBOX}); + + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "deletemailbox", MailboxConstants.USER_NAMESPACE, USER, MAILBOX}); + + assertThat(mailboxProbe.listUserMailboxes(USER)).isEmpty(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/container/cli-integration/src/test/java/org/apache/james/cli/QuotaCommandsIntegrationTest.java ---------------------------------------------------------------------- diff --git a/server/container/cli-integration/src/test/java/org/apache/james/cli/QuotaCommandsIntegrationTest.java b/server/container/cli-integration/src/test/java/org/apache/james/cli/QuotaCommandsIntegrationTest.java new file mode 100644 index 0000000..b20dd87 --- /dev/null +++ b/server/container/cli-integration/src/test/java/org/apache/james/cli/QuotaCommandsIntegrationTest.java @@ -0,0 +1,105 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.cli; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; + +import javax.inject.Singleton; + +import org.apache.james.GuiceJamesServer; +import org.apache.james.MemoryJmapTestRule; +import org.apache.james.mailbox.inmemory.InMemoryMailboxManager; +import org.apache.james.mailbox.model.QuotaRoot; +import org.apache.james.mailbox.store.quota.QuotaRootImpl; +import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex; +import org.apache.james.modules.QuotaProbesImpl; +import org.apache.james.modules.server.JMXServerModule; +import org.apache.james.utils.MailboxManagerDefinition; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import com.google.inject.Inject; +import com.google.inject.multibindings.Multibinder; + +public class QuotaCommandsIntegrationTest { + public static final String USER = "user"; + public static final QuotaRoot QUOTA_ROOT = QuotaRootImpl.quotaRoot("#private&" + USER); + + @Singleton + private static class MemoryMailboxManagerDefinition extends MailboxManagerDefinition { + @Inject + private MemoryMailboxManagerDefinition(InMemoryMailboxManager manager) { + super("memory-mailboxmanager", manager); + } + } + + @Rule + public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule(); + private GuiceJamesServer guiceJamesServer; + private QuotaProbesImpl quotaProbe; + + @Before + public void setUp() throws Exception { + guiceJamesServer = memoryJmap.jmapServer(new JMXServerModule(), + binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class)), + binder -> Multibinder.newSetBinder(binder, MailboxManagerDefinition.class) + .addBinding() + .to(MemoryMailboxManagerDefinition.class)); + guiceJamesServer.start(); + quotaProbe = guiceJamesServer.getProbe(QuotaProbesImpl.class); + } + + @After + public void tearDown() { + guiceJamesServer.stop(); + } + + @Test + public void setDefaultMaxStorageShouldWork() throws Exception { + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setdefaultmaxstoragequota", "36"}); + + assertThat(quotaProbe.getDefaultMaxStorage()).isEqualTo(36); + } + + @Test + public void setDefaultMaxMessageCountShouldWork() throws Exception { + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setdefaultmaxmessagecountquota", "36"}); + + assertThat(quotaProbe.getDefaultMaxMessageCount()).isEqualTo(36); + } + + @Test + public void setMaxStorageShouldWork() throws Exception { + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setmaxstoragequota", QUOTA_ROOT.getValue(), "36"}); + + assertThat(quotaProbe.getMaxStorage(QUOTA_ROOT.getValue())).isEqualTo(36); + } + + @Test + public void setMaxMessageCountShouldWork() throws Exception { + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setmaxmessagecountquota", QUOTA_ROOT.getValue(), "36"}); + + assertThat(quotaProbe.getMaxMessageCount(QUOTA_ROOT.getValue())).isEqualTo(36); + } + +} http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/container/cli-integration/src/test/java/org/apache/james/cli/SieveQuotaCommandsIntegrationTest.java ---------------------------------------------------------------------- diff --git a/server/container/cli-integration/src/test/java/org/apache/james/cli/SieveQuotaCommandsIntegrationTest.java b/server/container/cli-integration/src/test/java/org/apache/james/cli/SieveQuotaCommandsIntegrationTest.java new file mode 100644 index 0000000..3cf3a1b --- /dev/null +++ b/server/container/cli-integration/src/test/java/org/apache/james/cli/SieveQuotaCommandsIntegrationTest.java @@ -0,0 +1,118 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.cli; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; + +import javax.inject.Singleton; + +import org.apache.james.GuiceJamesServer; +import org.apache.james.MemoryJmapTestRule; +import org.apache.james.mailbox.inmemory.InMemoryMailboxManager; +import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex; +import org.apache.james.modules.TestFilesystemModule; +import org.apache.james.modules.protocols.SieveProbeImpl; +import org.apache.james.modules.server.JMXServerModule; +import org.apache.james.sieverepository.api.exception.QuotaNotFoundException; +import org.apache.james.utils.MailboxManagerDefinition; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.rules.TemporaryFolder; + +import com.google.inject.Inject; +import com.google.inject.multibindings.Multibinder; + +public class SieveQuotaCommandsIntegrationTest { + public static final String USER = "user"; + + @Singleton + private static class MemoryMailboxManagerDefinition extends MailboxManagerDefinition { + @Inject + private MemoryMailboxManagerDefinition(InMemoryMailboxManager manager) { + super("memory-mailboxmanager", manager); + } + } + + @Rule + public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule(); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + @Rule + public TemporaryFolder temporaryFolder = new TemporaryFolder(); + private GuiceJamesServer guiceJamesServer; + private SieveProbeImpl sieveProbe; + + @Before + public void setUp() throws Exception { + guiceJamesServer = memoryJmap.jmapServer(new JMXServerModule(), + binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class)), + binder -> Multibinder.newSetBinder(binder, MailboxManagerDefinition.class) + .addBinding() + .to(MemoryMailboxManagerDefinition.class)) + .overrideWith(new TestFilesystemModule(temporaryFolder)); + guiceJamesServer.start(); + sieveProbe = guiceJamesServer.getProbe(SieveProbeImpl.class); + } + + @After + public void tearDown() { + guiceJamesServer.stop(); + } + + @Test + public void setSieveUserQuotaShouldWork() throws Exception { + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setsieveuserquota", USER, "36"}); + + assertThat(sieveProbe.getSieveQuota(USER)).isEqualTo(36); + } + + @Test + public void setSieveQuotaShouldWork() throws Exception { + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setsievequota", "36"}); + + assertThat(sieveProbe.getSieveQuota()).isEqualTo(36); + } + + + @Test + public void removeSieveUserQuotaShouldWork() throws Exception { + sieveProbe.setSieveQuota(USER, 36); + + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "removesieveuserquota", USER}); + + expectedException.expect(QuotaNotFoundException.class); + sieveProbe.getSieveQuota(USER); + } + + @Test + public void removeSieveQuotaShouldWork() throws Exception { + sieveProbe.setSieveQuota(36); + + ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "removesievequota"}); + + expectedException.expect(QuotaNotFoundException.class); + sieveProbe.getSieveQuota(); + } + +} http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/container/cli-integration/src/test/resources/conf/jmx.properties ---------------------------------------------------------------------- diff --git a/server/container/cli-integration/src/test/resources/conf/jmx.properties b/server/container/cli-integration/src/test/resources/conf/jmx.properties new file mode 100644 index 0000000..0437d95 --- /dev/null +++ b/server/container/cli-integration/src/test/resources/conf/jmx.properties @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# See http://james.apache.org/server/3/config.html for usage + +jmx.address=127.0.0.1 +jmx.port=9999 http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/container/cli-integration/src/test/resources/dnsservice.xml ---------------------------------------------------------------------- diff --git a/server/container/cli-integration/src/test/resources/dnsservice.xml b/server/container/cli-integration/src/test/resources/dnsservice.xml new file mode 100644 index 0000000..0978a00 --- /dev/null +++ b/server/container/cli-integration/src/test/resources/dnsservice.xml @@ -0,0 +1,29 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> + +<dnsservice> + <servers> + <server>8.8.8.8</server> + <server>62.210.16.6</server> + </servers> + <autodiscover>false</autodiscover> + <authoritative>false</authoritative> + <maxcachesize>50000</maxcachesize> +</dnsservice> http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/container/cli-integration/src/test/resources/imapserver.xml ---------------------------------------------------------------------- diff --git a/server/container/cli-integration/src/test/resources/imapserver.xml b/server/container/cli-integration/src/test/resources/imapserver.xml new file mode 100644 index 0000000..ff478a9 --- /dev/null +++ b/server/container/cli-integration/src/test/resources/imapserver.xml @@ -0,0 +1,54 @@ +<?xml version="1.0"?> + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + + +<imapservers> + <imapserver enabled="true"> + <jmxName>imapserver</jmxName> + <bind>0.0.0.0:1143</bind> + <connectionBacklog>200</connectionBacklog> + <tls socketTLS="false" startTLS="false"> + <!-- To create a new keystore execute: + keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore + --> + <keystore>file://conf/keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + </tls> + <connectionLimit>0</connectionLimit> + <connectionLimitPerIP>0</connectionLimitPerIP> + </imapserver> + <imapserver enabled="true"> + <jmxName>imapserver-ssl</jmxName> + <bind>0.0.0.0:1993</bind> + <connectionBacklog>200</connectionBacklog> + <tls socketTLS="false" startTLS="false"> + <!-- To create a new keystore execute: + keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore + --> + <keystore>file://conf/keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + </tls> + <connectionLimit>0</connectionLimit> + <connectionLimitPerIP>0</connectionLimitPerIP> + </imapserver> +</imapservers> http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/container/cli-integration/src/test/resources/jmap.properties ---------------------------------------------------------------------- diff --git a/server/container/cli-integration/src/test/resources/jmap.properties b/server/container/cli-integration/src/test/resources/jmap.properties new file mode 100644 index 0000000..34ab451 --- /dev/null +++ b/server/container/cli-integration/src/test/resources/jmap.properties @@ -0,0 +1,11 @@ +# Configuration file for JMAP + +tls.keystoreURL=file://conf/keystore +tls.secret=james72laBalle + +# +# If you wish to use OAuth authentication, you should provide a valid JWT public key. +# The following entry specify the link to the URL of the public key file, +# which should be a PEM format file. +# +jwt.publickeypem.url=file://conf/jwt_publickey http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/container/cli-integration/src/test/resources/jwt_publickey ---------------------------------------------------------------------- diff --git a/server/container/cli-integration/src/test/resources/jwt_publickey b/server/container/cli-integration/src/test/resources/jwt_publickey new file mode 100644 index 0000000..53914e0 --- /dev/null +++ b/server/container/cli-integration/src/test/resources/jwt_publickey @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtlChO/nlVP27MpdkG0Bh +16XrMRf6M4NeyGa7j5+1UKm42IKUf3lM28oe82MqIIRyvskPc11NuzSor8HmvH8H +lhDs5DyJtx2qp35AT0zCqfwlaDnlDc/QDlZv1CoRZGpQk1Inyh6SbZwYpxxwh0fi ++d/4RpE3LBVo8wgOaXPylOlHxsDizfkL8QwXItyakBfMO6jWQRrj7/9WDhGf4Hi+ +GQur1tPGZDl9mvCoRHjFrD5M/yypIPlfMGWFVEvV5jClNMLAQ9bYFuOc7H1fEWw6 +U1LZUUbJW9/CH45YXz82CYqkrfbnQxqRb2iVbVjs/sHopHd1NTiCfUtwvcYJiBVj +kwIDAQAB +-----END PUBLIC KEY----- http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/container/cli-integration/src/test/resources/lmtpserver.xml ---------------------------------------------------------------------- diff --git a/server/container/cli-integration/src/test/resources/lmtpserver.xml b/server/container/cli-integration/src/test/resources/lmtpserver.xml new file mode 100644 index 0000000..5c4a9c7 --- /dev/null +++ b/server/container/cli-integration/src/test/resources/lmtpserver.xml @@ -0,0 +1,41 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> + +<lmtpservers> + + <lmtpserver enabled="true"> + <jmxName>lmtpserver</jmxName> + <!-- LMTP should not be reachable from outside your network so bind it to loopback--> + <bind>127.0.0.1:1024</bind> + <connectionBacklog>200</connectionBacklog> + <connectiontimeout>1200</connectiontimeout> + <!-- Set the maximum simultaneous incoming connections for this service --> + <connectionLimit>0</connectionLimit> + <!-- Set the maximum simultaneous incoming connections per IP for this service --> + <connectionLimitPerIP>0</connectionLimitPerIP> + <!-- This sets the maximum allowed message size (in kilobytes) for this --> + <!-- LMTP service. If unspecified, the value defaults to 0, which means no limit. --> + <maxmessagesize>0</maxmessagesize> + <handlerchain> + <handler class="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/> + </handlerchain> + </lmtpserver> + +</lmtpservers> http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/container/cli-integration/src/test/resources/logback-test.xml ---------------------------------------------------------------------- diff --git a/server/container/cli-integration/src/test/resources/logback-test.xml b/server/container/cli-integration/src/test/resources/logback-test.xml new file mode 100644 index 0000000..6f13ac9 --- /dev/null +++ b/server/container/cli-integration/src/test/resources/logback-test.xml @@ -0,0 +1,15 @@ +<configuration> + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%date %-5level [%thread] - [%logger]- %msg%n</pattern> + </encoder> + </appender> + + <root level="WARN"> + <appender-ref ref="STDOUT" /> + </root> + + <logger name="com.datastax.driver.core.QueryLogger.SLOW" level="DEBUG" /> + +</configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/container/cli-integration/src/test/resources/mailetcontainer.xml ---------------------------------------------------------------------- diff --git a/server/container/cli-integration/src/test/resources/mailetcontainer.xml b/server/container/cli-integration/src/test/resources/mailetcontainer.xml new file mode 100644 index 0000000..28bdcee --- /dev/null +++ b/server/container/cli-integration/src/test/resources/mailetcontainer.xml @@ -0,0 +1,105 @@ +<?xml version="1.0"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> + +<mailetcontainer enableJmx="false"> + + <context> + <postmaster>postmas...@james.minet.net</postmaster> + </context> + + <spooler> + <threads>20</threads> + </spooler> + + <processors> + <processor state="root" enableJmx="false"> + <mailet match="All" class="PostmasterAlias"/> + <mailet match="RelayLimit=30" class="Null"/> + <!-- Hook on sievemana...@james.linagora.com + Mail send to this address will get interpreted with SIEVE Manage --> + <mailet match="All" class="ToProcessor"> + <processor>transport</processor> + </mailet> + </processor> + + <processor state="error" enableJmx="false"> + <mailet match="All" class="Bounce"/> + </processor> + + + <processor state="transport" enableJmx="false"> + <mailet match="SMTPAuthSuccessful" class="SetMimeHeader"> + <name>X-UserIsAuth</name> + <value>true</value> + </mailet> + <mailet match="All" class="RemoveMimeHeader"> + <name>bcc</name> + </mailet> + <mailet match="RecipientIsLocal" class="org.apache.james.jmap.mailet.VacationMailet"/> + <mailet match="RecipientIsLocal" class="Sieve"/> + <mailet match="RecipientIsLocal" class="LocalDelivery"/> + <mailet match="HostIsLocal" class="ToProcessor"> + <processor>local-address-error</processor> + <notice>550 - Requested action not taken: no such user here</notice> + </mailet> + <mailet match="SMTPAuthSuccessful" class="RemoteDelivery"> + <outgoingQueue>outgoing</outgoingQueue> + <delayTime>5000, 100000, 500000</delayTime> + <maxRetries>25</maxRetries> + <maxDnsProblemRetries>0</maxDnsProblemRetries> + <deliveryThreads>10</deliveryThreads> + <sendpartial>true</sendpartial> + <bounceProcessor>bounces</bounceProcessor> + </mailet> + <mailet match="All" class="ToProcessor"> + <processor>relay-denied</processor> + </mailet> + </processor> + + <processor state="spam" enableJmx="false"> + <mailet match="All" class="ToRepository"> + <repositoryPath>file://var/mail/spam/</repositoryPath> + </mailet> + </processor> + + <processor state="local-address-error" enableJmx="false"> + <mailet match="All" class="Bounce"> + <attachment>none</attachment> + </mailet> + </processor> + + <processor state="relay-denied" enableJmx="false"> + <mailet match="All" class="Bounce"> + <attachment>none</attachment> + </mailet> + </processor> + + <processor state="bounces" enableJmx="false"> + <mailet match="All" class="DSNBounce"> + <passThrough>false</passThrough> + </mailet> + </processor> + + </processors> + +</mailetcontainer> + + http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/container/cli-integration/src/test/resources/mailrepositorystore.xml ---------------------------------------------------------------------- diff --git a/server/container/cli-integration/src/test/resources/mailrepositorystore.xml b/server/container/cli-integration/src/test/resources/mailrepositorystore.xml new file mode 100644 index 0000000..3ca4a1d --- /dev/null +++ b/server/container/cli-integration/src/test/resources/mailrepositorystore.xml @@ -0,0 +1,31 @@ +<?xml version="1.0"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> + +<mailrepositorystore> + <mailrepositories> + <mailrepository class="org.apache.james.mailrepository.file.FileMailRepository"> + <protocols> + <protocol>file</protocol> + </protocols> + <config FIFO="false" CACHEKEYS="true"/> + </mailrepository> + </mailrepositories> +</mailrepositorystore> http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/container/cli-integration/src/test/resources/managesieveserver.xml ---------------------------------------------------------------------- diff --git a/server/container/cli-integration/src/test/resources/managesieveserver.xml b/server/container/cli-integration/src/test/resources/managesieveserver.xml new file mode 100644 index 0000000..ec57e09 --- /dev/null +++ b/server/container/cli-integration/src/test/resources/managesieveserver.xml @@ -0,0 +1,65 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> + +<!-- + This template file can be used as example for James Server configuration + DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS +--> + +<!-- See http://james.apache.org/server/3/config.html for usage --> + +<managesieveservers> + + <managesieveserver enabled="true"> + + <jmxName>managesieveserver</jmxName> + + <bind>0.0.0.0:4190</bind> + + <connectionBacklog>200</connectionBacklog> + + <tls socketTLS="false" startTLS="false"> + <!-- To create a new keystore execute: + keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore + --> + <keystore>file://conf/keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + <!-- The algorithm is optional and only needs to be specified when using something other + than the Sun JCE provider - You could use IbmX509 with IBM Java runtime. --> + <algorithm>SunX509</algorithm> + </tls> + + <!-- connection timeout in secconds --> + <connectiontimeout>360</connectiontimeout> + + <!-- Set the maximum simultaneous incoming connections for this service --> + <connectionLimit>0</connectionLimit> + + <!-- Set the maximum simultaneous incoming connections per IP for this service --> + <connectionLimitPerIP>0</connectionLimitPerIP> + <maxmessagesize>0</maxmessagesize> + <addressBracketsEnforcement>true</addressBracketsEnforcement> + + </managesieveserver> + +</managesieveservers> + + http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/container/cli-integration/src/test/resources/pop3server.xml ---------------------------------------------------------------------- diff --git a/server/container/cli-integration/src/test/resources/pop3server.xml b/server/container/cli-integration/src/test/resources/pop3server.xml new file mode 100644 index 0000000..e4187da --- /dev/null +++ b/server/container/cli-integration/src/test/resources/pop3server.xml @@ -0,0 +1,42 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> + + +<pop3servers> + <pop3server enabled="true"> + <jmxName>pop3server</jmxName> + <bind>0.0.0.0:1110</bind> + <connectionBacklog>200</connectionBacklog> + <tls socketTLS="false" startTLS="false"> + <!-- To create a new keystore execute: + keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore + --> + <keystore>file://conf/keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + </tls> + <connectiontimeout>1200</connectiontimeout> + <connectionLimit>0</connectionLimit> + <connectionLimitPerIP>0</connectionLimitPerIP> + <handlerchain> + <handler class="org.apache.james.pop3server.core.CoreCmdHandlerLoader"/> + </handlerchain> + </pop3server> +</pop3servers> http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/container/cli-integration/src/test/resources/smtpserver.xml ---------------------------------------------------------------------- diff --git a/server/container/cli-integration/src/test/resources/smtpserver.xml b/server/container/cli-integration/src/test/resources/smtpserver.xml new file mode 100644 index 0000000..a3d4b8f --- /dev/null +++ b/server/container/cli-integration/src/test/resources/smtpserver.xml @@ -0,0 +1,105 @@ +<?xml version="1.0"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> + +<smtpservers> + <smtpserver enabled="true"> + <jmxName>smtpserver-global</jmxName> + <bind>0.0.0.0:1025</bind> + <connectionBacklog>200</connectionBacklog> + <tls socketTLS="false" startTLS="false"> + <keystore>file://conf/keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + <algorithm>SunX509</algorithm> + </tls> + <connectiontimeout>360</connectiontimeout> + <connectionLimit>0</connectionLimit> + <connectionLimitPerIP>0</connectionLimitPerIP> + <authRequired>false</authRequired> + <authorizedAddresses>0.0.0.0/0</authorizedAddresses> + <verifyIdentity>true</verifyIdentity> + <maxmessagesize>0</maxmessagesize> + <addressBracketsEnforcement>true</addressBracketsEnforcement> + <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting> + <handlerchain> + <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/> + <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/> + </handlerchain> + </smtpserver> + <smtpserver enabled="true"> + <jmxName>smtpserver-TLS</jmxName> + <bind>0.0.0.0:10465</bind> + <connectionBacklog>200</connectionBacklog> + <tls socketTLS="false" startTLS="false"> + <keystore>file://conf/keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + <algorithm>SunX509</algorithm> + </tls> + <connectiontimeout>360</connectiontimeout> + <connectionLimit>0</connectionLimit> + <connectionLimitPerIP>0</connectionLimitPerIP> + <!-- + Authorize only local users + --> + <authRequired>true</authRequired> + <authorizedAddresses>0.0.0.0/0</authorizedAddresses> + <!-- Trust authenticated users --> + <verifyIdentity>false</verifyIdentity> + <maxmessagesize>0</maxmessagesize> + <addressBracketsEnforcement>true</addressBracketsEnforcement> + <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting> + <handlerchain> + <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/> + <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/> + </handlerchain> + </smtpserver> + <smtpserver enabled="true"> + <jmxName>smtpserver-authenticated</jmxName> + <bind>0.0.0.0:1587</bind> + <connectionBacklog>200</connectionBacklog> + <tls socketTLS="false" startTLS="false"> + <keystore>file://conf/keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + <algorithm>SunX509</algorithm> + </tls> + <connectiontimeout>360</connectiontimeout> + <connectionLimit>0</connectionLimit> + <connectionLimitPerIP>0</connectionLimitPerIP> + <!-- + Authorize only local users + --> + <authRequired>true</authRequired> + <authorizedAddresses>0.0.0.0/0</authorizedAddresses> + <!-- Trust authenticated users --> + <verifyIdentity>false</verifyIdentity> + <maxmessagesize>0</maxmessagesize> + <addressBracketsEnforcement>true</addressBracketsEnforcement> + <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting> + <handlerchain> + <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/> + <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/> + </handlerchain> + </smtpserver> +</smtpservers> + + http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/container/guice/memory-guice/src/test/java/org/apache/james/MemoryJmapTestRule.java ---------------------------------------------------------------------- diff --git a/server/container/guice/memory-guice/src/test/java/org/apache/james/MemoryJmapTestRule.java b/server/container/guice/memory-guice/src/test/java/org/apache/james/MemoryJmapTestRule.java index 6653cd9..5a3dd07 100644 --- a/server/container/guice/memory-guice/src/test/java/org/apache/james/MemoryJmapTestRule.java +++ b/server/container/guice/memory-guice/src/test/java/org/apache/james/MemoryJmapTestRule.java @@ -28,18 +28,21 @@ import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; +import com.google.inject.Module; + public class MemoryJmapTestRule implements TestRule { private static final int LIMIT_TO_3_MESSAGES = 3; public TemporaryFolder temporaryFolder = new TemporaryFolder(); - public GuiceJamesServer jmapServer() { + public GuiceJamesServer jmapServer(Module... modules) { return new GuiceJamesServer() - .combineWith(MemoryJamesServerMain.inMemoryServerModule) - .overrideWith(new TestFilesystemModule(temporaryFolder), - new TestJMAPServerModule(LIMIT_TO_3_MESSAGES)) - .overrideWith((binder) -> binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class)); + .combineWith(MemoryJamesServerMain.inMemoryServerModule) + .combineWith(modules) + .overrideWith(new TestFilesystemModule(temporaryFolder), + new TestJMAPServerModule(LIMIT_TO_3_MESSAGES)) + .overrideWith((binder) -> binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class)); } @Override http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/container/util/src/main/java/org/apache/james/util/RestrictingRMISocketFactory.java ---------------------------------------------------------------------- diff --git a/server/container/util/src/main/java/org/apache/james/util/RestrictingRMISocketFactory.java b/server/container/util/src/main/java/org/apache/james/util/RestrictingRMISocketFactory.java index 1b53bba..f0f706d 100644 --- a/server/container/util/src/main/java/org/apache/james/util/RestrictingRMISocketFactory.java +++ b/server/container/util/src/main/java/org/apache/james/util/RestrictingRMISocketFactory.java @@ -23,6 +23,8 @@ import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; import java.rmi.server.RMISocketFactory; +import java.util.ArrayList; +import java.util.List; /** * {@link RMISocketFactory} implementation which allow to bind JMX to a specific @@ -32,6 +34,8 @@ public class RestrictingRMISocketFactory extends RMISocketFactory { private final String address; + private final List<ServerSocket> sockets = new ArrayList<ServerSocket>(); + public RestrictingRMISocketFactory(String address) { this.address = address; } @@ -48,6 +52,7 @@ public class RestrictingRMISocketFactory extends RMISocketFactory { public ServerSocket createServerSocket(int port) throws IOException { ServerSocket socket = new ServerSocket(); socket.bind(new InetSocketAddress(address, port)); + sockets.add(socket); return socket; } @@ -58,4 +63,7 @@ public class RestrictingRMISocketFactory extends RMISocketFactory { return new Socket(host, port); } + public List<ServerSocket> getSockets() { + return sockets; + } } http://git-wip-us.apache.org/repos/asf/james-project/blob/b052f86a/server/pom.xml ---------------------------------------------------------------------- diff --git a/server/pom.xml b/server/pom.xml index cfffd6f..a46f7dd 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -57,6 +57,7 @@ <module>karaf/integration</module> <module>container/cli</module> + <module>container/cli-integration</module> <module>container/core</module> <module>container/filesystem-api</module> <module>container/guice</module> --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org