Author: matthieu Date: Mon Nov 2 13:41:49 2015 New Revision: 1711969 URL: http://svn.apache.org/viewvc?rev=1711969&view=rev Log: JAMES-1594 add tests on wildcard address mappings
Modified: james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RewriteTablesStepdefs.java james/project/trunk/server/data/data-library/src/test/resources/cucumber/rewrite_tables.feature Modified: james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RewriteTablesStepdefs.java URL: http://svn.apache.org/viewvc/james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RewriteTablesStepdefs.java?rev=1711969&r1=1711968&r2=1711969&view=diff ============================================================================== --- james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RewriteTablesStepdefs.java (original) +++ james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RewriteTablesStepdefs.java Mon Nov 2 13:41:49 2015 @@ -23,6 +23,7 @@ import static org.assertj.core.api.Asser import java.util.List; +import org.apache.james.rrt.api.RecipientRewriteTable; import org.apache.james.rrt.api.RecipientRewriteTable.ErrorMappingException; import org.apache.james.rrt.api.RecipientRewriteTableException; @@ -59,6 +60,11 @@ public class RewriteTablesStepdefs { rewriteTable.addErrorMapping(user, domain, error); } + @Given("store \"([^\"]*)\" address mapping as wildcard for domain \"([^\"]*)\"") + public void storeAddressMappingAsWildcardAtDomain(String address, String domain) throws Throwable { + storeAddressMappingForUserAtDomain(address, RecipientRewriteTable.WILDCARD, domain); + } + @When("user \"([^\"]*)\" at domain \"([^\"]*)\" removes a regexp mapping \"([^\"]*)\"") public void userAtDomainRemovesRegexpMapping(String user, String domain, String regexp) throws Throwable { rewriteTable.removeRegexMapping(user, domain, regexp); @@ -74,6 +80,11 @@ public class RewriteTablesStepdefs { rewriteTable.removeErrorMapping(user, domain, error); } + @When("wildcard address mapping \"([^\"]*)\" at domain \"([^\"]*)\" is removed") + public void removeWildcardAddressMappingAtDomain(String address, String domain) throws Throwable { + userAtDomainRemovesAddressMapping(RecipientRewriteTable.WILDCARD, domain, address); + } + @Then("mappings should be empty") public void assertMappingsIsEmpty() throws Throwable { assertThat(rewriteTable.getAllMappings()).isNullOrEmpty(); Modified: james/project/trunk/server/data/data-library/src/test/resources/cucumber/rewrite_tables.feature URL: http://svn.apache.org/viewvc/james/project/trunk/server/data/data-library/src/test/resources/cucumber/rewrite_tables.feature?rev=1711969&r1=1711968&r2=1711969&view=diff ============================================================================== --- james/project/trunk/server/data/data-library/src/test/resources/cucumber/rewrite_tables.feature (original) +++ james/project/trunk/server/data/data-library/src/test/resources/cucumber/rewrite_tables.feature Mon Nov 2 13:41:49 2015 @@ -87,3 +87,44 @@ Feature: Rewrite Tables tests Given store "bounce!" error mapping for user "test" at domain "localhost" And store "test@localhost2" address mapping for user "test" at domain "localhost" Then retrieving mappings for user "test" at domain "localhost" should raise a "ErrorMappingException" exception with message "bounce!" + +# Wildcard mapping + + Scenario: stored address mapping as wildcard should be retrieved by one user when one mapping matching + Given store "test@localhost" address mapping as wildcard for domain "localhost" + Then mappings for user "user" at domain "localhost" should contains only "test@localhost" + + Scenario: stored address mapping as wildcard should be retrieved by two users when one mapping matching + Given store "test@localhost" address mapping as wildcard for domain "localhost" + Then mappings for user "user" at domain "localhost" should contains only "test@localhost" + And mappings for user "user2" at domain "localhost" should contains only "test@localhost" + +# Wildcard is not overridden + @ignore + Scenario: direct mapping should override address mapping as wildcard + Given store "test@localhost" address mapping as wildcard for domain "localhost" + And store "mine@localhost" address mapping for user "user" at domain "localhost" + Then mappings for user "user" at domain "localhost" should contains only "mine@localhost" + +# Wildcard is not overridden + @ignore + Scenario: direct mapping should override address mapping as wildcard (reverse insertion order) + Given store "mine@localhost" address mapping for user "user" at domain "localhost" + And store "test@localhost" address mapping as wildcard for domain "localhost" + Then mappings for user "user" at domain "localhost" should contains only "mine@localhost" + + Scenario: direct mapping should not override address mapping as wildcard when other user + Given store "test@localhost" address mapping as wildcard for domain "localhost" + And store "mine@localhost" address mapping for user "user" at domain "localhost" + Then mappings for user "user2" at domain "localhost" should contains only "test@localhost" + + Scenario: direct mapping should be retrieved when removing address mapping as wildcard + Given store "test@localhost" address mapping as wildcard for domain "localhost" + And store "mine@localhost" address mapping for user "user" at domain "localhost" + When wildcard address mapping "test@localhost" at domain "localhost" is removed + Then mappings for user "user" at domain "localhost" should contains only "mine@localhost" + + Scenario: stored address mappings as wildcard should be retrieved when two address mappings as wildcard + Given store "test@localhost" address mapping as wildcard for domain "localhost" + And store "test2@localhost" address mapping as wildcard for domain "localhost" + Then mappings for user "user" at domain "localhost" should contains only "test@localhost, test2@localhost" \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org