Hi all,

As explained in the issue JAMES-1594 <https://issues.apache.org/jira/browse/JAMES-1594>, we would like to write the specification on rewrite table. The existing implementations are not all equivalent, and so we introduce issues related:

 * JAMES-1595 <https://issues.apache.org/jira/browse/JAMES-1595>
 * JAMES-1596 <https://issues.apache.org/jira/browse/JAMES-1596>
 * JAMES-1597 <https://issues.apache.org/jira/browse/JAMES-1597>
 * JAMES-1598 <https://issues.apache.org/jira/browse/JAMES-1598>
 * JAMES-1599 <https://issues.apache.org/jira/browse/JAMES-1599>

We are currently implementing the Cassandra backend related to this feature,
and so we would like to improve the behaviour of it.


Before sending the pull request with full implementation of the specification,
we would like to have some feedback from the community.

Attached to this mail, the specification written in Gherkin, full code available at
https://github.com/aduprat/james/tree/Issue-9
commits list:

 * 3230ac2e836c28673dd22646a0da8f4af60a9c41 - Antoine Duprat Issue-9
   add tests on recursive mappings
 * 742e8bbe6aa21a3925310ab7847c8750707a5487 - Antoine Duprat Issue-9
   add tests on alias mappings
 * c4c52758f6b7f7ea756b52b1936c92efaf39a236 - Antoine Duprat Issue-9
   add tests on wildcard address mappings
 * 2cadf4503573264752957481567a59d2a8669e39 - Antoine Duprat Issue-9
   add tests on error mappings
 * a47e9e64cd15c348df7559b1f7e88aa8e4e25108 - Antoine Duprat Issue-9
   add tests on address mappings
 * cd99601bf29279441976b75b3d58f80ffbd029af - Antoine Duprat Issue-9
   add tests on regexp mappings
 * 1e4fb25027030b7234d914708de6b18cfdb5e6dc - Antoine Duprat Issue-9
   First test on empty mapping
 * 9c98e06a95ceffd1ae4d282ca164e49cff698005 - Antoine Duprat Issue-9
   Introduce Cucumber tests on rewrite tables on each backend

Thanks and regards,

--
Antoine Duprat
Développeur LGS/OBM/R&D

------------------

GROUPE LINAGORA
74-80 rue Roque de Fillol
92800 Puteaux

+33 (0)8 10 25 12 51
+33 (0)6 45 63 27 17
[email protected]

------------------

La présente transmission contient des informations confidentielles
appartenant à Linagora, exclusivement destinées au(x) destinataire(s)
identifié(s) ci-dessus. Si vous n'en faites pas partie, toute
reproduction, distribution ou divulgation de tout ou partie des
informations de cette transmission, ou toute action effectuée sur la
base de celles-ci vous sont formellement interdites.
Si vous avez reçu cette transmission par erreur, nous vous remercions de
nous en avertir et de la détruire de votre système d'information.

The present transmission contains privileged and confidential
information belonging to Linagora, exclusively intended for the
recipient(s) thereabove identified. If you are not one of these
aforementioned recipients, any reproduction, distribution, disclosure of
said information in whole or in part, as well as any action undertaken
on the basis of said information are strictly prohbited. If you received
the present transmission by mistake, please inform us and destroy it
from your messenging and information systems.

Feature: Rewrite Tables tests

  Scenario: rewrite tables should be empty when none defined
    Then mappings should be empty

# Regexp mapping

  Scenario: stored regexp mapping should be retrieved when one mapping matching
    Given store "(.*)@localhost" regexp mapping for user "test" at domain 
"localhost"
    Then mappings for user "test" at domain "localhost" should contains only 
"regex:(.*)@localhost"

  Scenario: stored regexp mapping should be retrieved when two mappings matching
    Given store "(.*)@localhost" regexp mapping for user "test" at domain 
"localhost"
    And store "(.+)@test" regexp mapping for user "test" at domain "localhost"
    Then mappings for user "test" at domain "localhost" should contains only 
"regex:(.*)@localhost, regex:(.+)@test"

  Scenario: stored regexp mapping should not be retrieved by another user
    Given store "(.*)@localhost" regexp mapping for user "test" at domain 
"localhost"
    And store "(.+)@test" regexp mapping for user "test" at domain "localhost"
    Then mappings for user "test2" at domain "localhost" should be empty

  Scenario: removing a stored regexp mapping should work
    Given store "(.*)@localhost" regexp mapping for user "test" at domain 
"localhost"
    And store "(.+)@test" regexp mapping for user "test" at domain "localhost"
    When user "test" at domain "localhost" removes a regexp mapping "(.+)@test"
    Then mappings for user "test" at domain "localhost" should contains only 
"regex:(.*)@localhost"

  Scenario: storing an invalid regexp mapping should not work
    When store an invalid ".*):" regexp mapping for user "test" at domain 
"localhost"
    Then a "RecipientRewriteTableException" exception should have been thrown

# Address mapping

  Scenario: stored address mapping should be retrieved when one mapping matching
    Given store "test@localhost2" address mapping for user "test" at domain 
"localhost"
    Then mappings for user "test" at domain "localhost" should contains only 
"test@localhost2"

  Scenario: stored address mapping should be retrieved when two mappings 
matching
    Given store "test@localhost2" address mapping for user "test" at domain 
"localhost"
    And store "test@james" address mapping for user "test" at domain "localhost"
    Then mappings for user "test" at domain "localhost" should contains only 
"test@localhost2, test@james"

  Scenario: stored address mapping should not be retrieved by another user
    Given store "test@localhost2" address mapping for user "test" at domain 
"localhost"
    And store "test@james" address mapping for user "test" at domain "localhost"
    Then mappings for user "test2" at domain "localhost" should be empty

  Scenario: removing a stored address mapping should work
    Given store "test@localhost2" address mapping for user "test" at domain 
"localhost"
    And store "test@james" address mapping for user "test" at domain "localhost"
    When user "test" at domain "localhost" removes a address mapping 
"test@james"
    Then mappings for user "test" at domain "localhost" should contains only 
"test@localhost2"

# Error mapping

  Scenario: stored error mapping should be retrieved when one mapping matching
    Given store "bounce!" error mapping for user "test" at domain "localhost"
    Then retrieving mappings for user "test" at domain "localhost" should raise 
a "ErrorMappingException" exception with message "bounce!"

# Bad messsage: "bounce!;test@localhost2" instead of "bounce!"
  @ignore
  Scenario: stored error mapping should be retrieved when two mappings matching
    Given store "bounce!" error mapping for user "test" at domain "localhost"
    And store "error" error mapping for user "test" at domain "localhost"
    Then retrieving mappings for user "test" at domain "localhost" should raise 
a "ErrorMappingException" exception with message "bounce!"

  Scenario: stored error mapping should not be retrieved by another user
    Given store "bounce!" error mapping for user "test" at domain "localhost"
    And store "error" error mapping for user "test" at domain "localhost"
    Then mappings for user "test2" at domain "localhost" should be empty

  Scenario: removing a stored error mapping should work
    Given store "bounce!" error mapping for user "test" at domain "localhost"
    When user "test" at domain "localhost" removes a error mapping "bounce!"
    Then mappings for user "test" at domain "localhost" should be empty

# Should fail, but not currently
  @ignore
  Scenario: an exception should be thrown when an error mapping is not the 
first stored
    Given store "test@localhost2" address mapping for user "test" at domain 
"localhost"
    And store "bounce!" error mapping for user "test" at domain "localhost"
    Then retrieving mappings for user "test" at domain "localhost" should raise 
a "ErrorMappingException" exception with message "bounce!"

# Bad messsage: "bounce!;test@localhost2" instead of "bounce!"
  @ignore
  Scenario: an exception should be thrown when an error mapping is the first 
stored
    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"

# Alias mapping

  Scenario: address mapping should be retrieved when searching with a domain 
alias
    Given store "aliasdomain" alias domain mapping for domain "localhost"
    Then mappings for user "test" at domain "aliasdomain" should contains only 
"test@localhost"

  Scenario: address mapping should be retrieved when searching with a domain 
alias
    Given store "test2@localhost" address mapping for user "test" at domain 
"localhost"
    And store "aliasdomain" alias domain mapping for domain "localhost"
    Then mappings for user "test" at domain "aliasdomain" should contains only 
"test2@localhost"

  Scenario: address mapping should be retrieved when searching with a domain 
alias (reverse insertion order)
    Given store "aliasdomain" alias domain mapping for domain "localhost"
    And store "test2@localhost" address mapping for user "test" at domain 
"localhost"
    Then mappings for user "test" at domain "aliasdomain" should contains only 
"test2@localhost"

  Scenario: address mapping should be retrieved when searching with the correct 
domain and exists an alias domain
    Given store "test2@localhost" address mapping for user "test" at domain 
"localhost"
    And store "aliasdomain" alias domain mapping for domain "localhost"
    Then mappings for user "test" at domain "localhost" should contains only 
"test2@localhost"

  Scenario: wildcard address mapping should be retrieved when searching with a 
domain alias
    Given store "wildcard@localhost" address mapping as wildcard for domain 
"localhost"
    And store "aliasdomain" alias domain mapping for domain "localhost"
    Then mappings for user "test" at domain "aliasdomain" should contains only 
"wildcard@localhost"

  Scenario: wildcard address mapping should be retrieved when searching with a 
domain and exists an alias domain
    Given store "wildcard@localhost" address mapping as wildcard for domain 
"localhost"
    And store "aliasdomain" alias domain mapping for domain "localhost"
    Then mappings for user "test" at domain "localhost" should contains only 
"wildcard@localhost"

  Scenario: both wildcard address mapping and default user address should be 
retrieved when wildcard address mapping on alias domain
    Given store "wildcard@localhost" address mapping as wildcard for domain 
"aliasdomain"
    And store "aliasdomain" alias domain mapping for domain "localhost"
    Then mappings for user "test" at domain "aliasdomain" should contains only 
"test@localhost, wildcard@localhost"

  Scenario: both wildcard address mapping and default user address should be 
retrieved when wildcard address mapping on alias domain (reverse insertion 
order)
    Given store "aliasdomain" alias domain mapping for domain "localhost"
    And store "wildcard@localhost" address mapping as wildcard for domain 
"aliasdomain"
    Then mappings for user "test" at domain "aliasdomain" should contains only 
"test@localhost, wildcard@localhost"

  Scenario: asking for a removed domain alias should fail
    Given store "wildcard@localhost" address mapping as wildcard for domain 
"localhost"
    And store "aliasdomain" alias domain mapping for domain "localhost"
    When alias domain mapping "aliasdomain" for "localhost" domain is removed
    Then mappings for user "test" at domain "aliasdomain" should be empty

# Recursive mapping

  Scenario: direct mapping should be returned when recursive mapping is disable
    Given recursive mapping is disable
    And store "user2@domain2" address mapping for user "user1" at domain 
"domain1"
    And store "user3@domain3" address mapping for user "user2" at domain 
"domain2"
    Then mappings for user "user1" at domain "domain1" should contains only 
"user2@domain2"

  Scenario: recursive mapping should work when two levels
    Given recursive mapping is enable
    And store "user2@domain2" address mapping for user "user1" at domain 
"domain1"
    And store "user3@domain3" address mapping for user "user2" at domain 
"domain2"
    Then mappings for user "user1" at domain "domain1" should contains only 
"user3@domain3"

  Scenario: recursive mapping should work when three levels
    Given recursive mapping is enable
    And store "user2@domain2" address mapping for user "user1" at domain 
"domain1"
    And store "user3@domain3" address mapping for user "user2" at domain 
"domain2"
    And store "user4@domain4" address mapping for user "user3" at domain 
"domain3"
    Then mappings for user "user1" at domain "domain1" should contains only 
"user4@domain4"

  Scenario: recursive mapping should throw exception when a loop exists
    Given recursive mapping is enable
    And store "user2@domain2" address mapping for user "user1" at domain 
"domain1"
    And store "user3@domain3" address mapping for user "user2" at domain 
"domain2"
    And store "user1@domain1" address mapping for user "user3" at domain 
"domain3"
    Then retrieving mappings for user "user1" at domain "domain1" should raise 
a "ErrorMappingException" exception with message "554 Too many mappings to 
process"

  Scenario: recursive mapping should work when a level is removed
    Given recursive mapping is enable
    And store "user2@domain2" address mapping for user "user1" at domain 
"domain1"
    And store "user3@domain3" address mapping for user "user2" at domain 
"domain2"
    And store "user4@domain4" address mapping for user "user3" at domain 
"domain3"
    When user "user2" at domain "domain2" removes a address mapping 
"user3@domain3"
    Then mappings for user "user1" at domain "domain1" should contains only 
"user2@domain2"

  Scenario: recursive mapping should work when three levels on alias domains
    Given store "domain2" alias domain mapping for domain "domain1"
    And store "domain3" alias domain mapping for domain "domain2"
    And store "domain4" alias domain mapping for domain "domain3"
    Then mappings for user "test" at domain "domain4" should contains only 
"test@domain1"
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to