This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 5df245169c5272189fcf0ee8699de498547e1c80 Author: Gautier DI FOLCO <[email protected]> AuthorDate: Thu Oct 31 14:15:13 2019 +0100 JAMES-2953 Disambiguate WebAdmin's addresses forwards error messages --- .../org/apache/james/webadmin/routes/ForwardRoutes.java | 17 +++++++++-------- .../apache/james/webadmin/routes/ForwardRoutesTest.java | 10 +++++----- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/ForwardRoutes.java b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/ForwardRoutes.java index ee9f8d6..f4b3226 100644 --- a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/ForwardRoutes.java +++ b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/ForwardRoutes.java @@ -79,7 +79,8 @@ public class ForwardRoutes implements Routes { "targets" + SEPARATOR + ":" + FORWARD_DESTINATION_ADDRESS; private static final String MAILADDRESS_ASCII_DISCLAIMER = "Note that email addresses are restricted to ASCII character set. " + "Mail addresses not matching this criteria will be rejected."; - private static final String ADDRESS_TYPE = "forward"; + private static final String FORWARD_BASE_ADDRESS_TYPE = "base forward"; + private static final String FORWARD_DESTINATION_ADDRESS_TYPE = "target forward"; private final UsersRepository usersRepository; private final JsonTransformer jsonTransformer; @@ -149,9 +150,9 @@ public class ForwardRoutes implements Routes { message = "Internal server error - Something went bad on the server side.") }) public HaltException addToForwardDestinations(Request request, Response response) throws RecipientRewriteTableException, UsersRepositoryException { - MailAddress forwardBaseAddress = MailAddressParser.parseMailAddress(request.params(FORWARD_BASE_ADDRESS), ADDRESS_TYPE); + MailAddress forwardBaseAddress = MailAddressParser.parseMailAddress(request.params(FORWARD_BASE_ADDRESS), FORWARD_BASE_ADDRESS_TYPE); ensureUserExist(forwardBaseAddress); - MailAddress destinationAddress = MailAddressParser.parseMailAddress(request.params(FORWARD_DESTINATION_ADDRESS), ADDRESS_TYPE); + MailAddress destinationAddress = MailAddressParser.parseMailAddress(request.params(FORWARD_DESTINATION_ADDRESS), FORWARD_DESTINATION_ADDRESS_TYPE); MappingSource source = MappingSource.fromUser(User.fromLocalPartWithDomain(forwardBaseAddress.getLocalPart(), forwardBaseAddress.getDomain())); addForward(source, destinationAddress); return halt(HttpStatus.NO_CONTENT_204); @@ -197,8 +198,8 @@ public class ForwardRoutes implements Routes { message = "Internal server error - Something went bad on the server side.") }) public HaltException removeFromForwardDestination(Request request, Response response) throws RecipientRewriteTableException { - MailAddress baseAddress = MailAddressParser.parseMailAddress(request.params(FORWARD_BASE_ADDRESS), ADDRESS_TYPE); - MailAddress destinationAddressToBeRemoved = MailAddressParser.parseMailAddress(request.params(FORWARD_DESTINATION_ADDRESS), ADDRESS_TYPE); + MailAddress baseAddress = MailAddressParser.parseMailAddress(request.params(FORWARD_BASE_ADDRESS), FORWARD_BASE_ADDRESS_TYPE); + MailAddress destinationAddressToBeRemoved = MailAddressParser.parseMailAddress(request.params(FORWARD_DESTINATION_ADDRESS), FORWARD_DESTINATION_ADDRESS_TYPE); MappingSource source = MappingSource.fromUser(User.fromLocalPartWithDomain(baseAddress.getLocalPart(), baseAddress.getDomain())); recipientRewriteTable.removeForwardMapping(source, destinationAddressToBeRemoved.asString()); return halt(HttpStatus.NO_CONTENT_204); @@ -212,13 +213,13 @@ public class ForwardRoutes implements Routes { }) @ApiResponses(value = { @ApiResponse(code = HttpStatus.OK_200, message = "OK", response = List.class), - @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "The forward is not an address"), - @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The forward does not exist"), + @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "The base forward is not an address"), + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The base forward does not exist"), @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.") }) public ImmutableSet<ForwardDestinationResponse> listForwardDestinations(Request request, Response response) throws RecipientRewriteTableException { - MailAddress baseAddress = MailAddressParser.parseMailAddress(request.params(FORWARD_BASE_ADDRESS), ADDRESS_TYPE); + MailAddress baseAddress = MailAddressParser.parseMailAddress(request.params(FORWARD_BASE_ADDRESS), FORWARD_BASE_ADDRESS_TYPE); Mappings mappings = recipientRewriteTable.getStoredMappings(MappingSource.fromMailAddress(baseAddress)) .select(Mapping.Type.Forward); diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/ForwardRoutesTest.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/ForwardRoutesTest.java index e92c665..ef8fbd6 100644 --- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/ForwardRoutesTest.java +++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/ForwardRoutesTest.java @@ -475,7 +475,7 @@ class ForwardRoutesTest { assertThat(errors) .containsEntry("statusCode", HttpStatus.BAD_REQUEST_400) .containsEntry("type", "InvalidArgument") - .containsEntry("message", "The forward is not an email address") + .containsEntry("message", "The base forward is not an email address") .containsEntry("details", "Out of data at position 1 in 'not-an-address'"); } @@ -494,7 +494,7 @@ class ForwardRoutesTest { assertThat(errors) .containsEntry("statusCode", HttpStatus.BAD_REQUEST_400) .containsEntry("type", "InvalidArgument") - .containsEntry("message", "The forward is not an email address") + .containsEntry("message", "The base forward is not an email address") .containsEntry("details", "Out of data at position 1 in 'not-an-address'"); } @@ -550,7 +550,7 @@ class ForwardRoutesTest { assertThat(errors) .containsEntry("statusCode", HttpStatus.BAD_REQUEST_400) .containsEntry("type", "InvalidArgument") - .containsEntry("message", "The forward is not an email address") + .containsEntry("message", "The target forward is not an email address") .containsEntry("details", "Out of data at position 1 in 'not-an-address'"); } @@ -580,7 +580,7 @@ class ForwardRoutesTest { assertThat(errors) .containsEntry("statusCode", HttpStatus.BAD_REQUEST_400) .containsEntry("type", "InvalidArgument") - .containsEntry("message", "The forward is not an email address") + .containsEntry("message", "The base forward is not an email address") .containsEntry("details", "Out of data at position 1 in 'not-an-address'"); } @@ -599,7 +599,7 @@ class ForwardRoutesTest { assertThat(errors) .containsEntry("statusCode", HttpStatus.BAD_REQUEST_400) .containsEntry("type", "InvalidArgument") - .containsEntry("message", "The forward is not an email address") + .containsEntry("message", "The target forward is not an email address") .containsEntry("details", "Out of data at position 1 in 'not-an-address'"); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
