This is an automated email from the ASF dual-hosted git repository.
kao pushed a commit to branch 3.8.x
in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/3.8.x by this push:
new 834652aeb3 JAMES-3991 Vacation handling should be case insensitive
834652aeb3 is described below
commit 834652aeb36f759c0de7b30c3ca79e4d59eceec1
Author: Karsten Otto <[email protected]>
AuthorDate: Wed Feb 14 12:01:01 2024 +0100
JAMES-3991 Vacation handling should be case insensitive
---
.../org/apache/james/vacation/api/AccountId.java | 2 +-
.../vacation/api/NotificationRegistryContract.java | 27 ++++++++++++++++++++++
.../vacation/api/VacationRepositoryContract.java | 23 ++++++++++++++++++
3 files changed, 51 insertions(+), 1 deletion(-)
diff --git
a/server/data/data-api/src/main/java/org/apache/james/vacation/api/AccountId.java
b/server/data/data-api/src/main/java/org/apache/james/vacation/api/AccountId.java
index a5cf60a559..b86df978df 100644
---
a/server/data/data-api/src/main/java/org/apache/james/vacation/api/AccountId.java
+++
b/server/data/data-api/src/main/java/org/apache/james/vacation/api/AccountId.java
@@ -40,7 +40,7 @@ public class AccountId {
private final String identifier;
private AccountId(String identifier) {
- this.identifier = identifier;
+ this.identifier = identifier.toLowerCase();
}
public String getIdentifier() {
diff --git
a/server/data/data-api/src/test/java/org/apache/james/vacation/api/NotificationRegistryContract.java
b/server/data/data-api/src/test/java/org/apache/james/vacation/api/NotificationRegistryContract.java
index 4742d9bd90..77ec6fe5c6 100644
---
a/server/data/data-api/src/test/java/org/apache/james/vacation/api/NotificationRegistryContract.java
+++
b/server/data/data-api/src/test/java/org/apache/james/vacation/api/NotificationRegistryContract.java
@@ -100,4 +100,31 @@ public interface NotificationRegistryContract {
assertThat(notificationRegistry().isRegistered(ACCOUNT_ID,
recipientId()).block()).isTrue();
}
+
+ @Test
+ default void isRegisteredShouldIgnoreCase() {
+ notificationRegistry().register(ACCOUNT_ID, recipientId(),
Optional.empty()).block();
+
+ AccountId upperCaseAccount =
AccountId.fromString(ACCOUNT_ID.getIdentifier().toUpperCase());
+ assertThat(notificationRegistry().isRegistered(upperCaseAccount,
recipientId()).block()).isTrue();
+ }
+
+ @Test
+ default void registerShouldIgnoreCase() {
+ AccountId upperCaseAccount =
AccountId.fromString(ACCOUNT_ID.getIdentifier().toUpperCase());
+ notificationRegistry().register(upperCaseAccount, recipientId(),
Optional.empty()).block();
+
+ assertThat(notificationRegistry().isRegistered(ACCOUNT_ID,
recipientId()).block()).isTrue();
+ }
+
+ @Test
+ default void flushShouldIgnoreCase() {
+ when(zonedDateTimeProvider.get()).thenReturn(ZONED_DATE_TIME);
+ notificationRegistry().register(ACCOUNT_ID, recipientId(),
Optional.empty()).block();
+
+ AccountId upperCaseAccount =
AccountId.fromString(ACCOUNT_ID.getIdentifier().toUpperCase());
+ notificationRegistry().flush(upperCaseAccount).block();
+
+ assertThat(notificationRegistry().isRegistered(ACCOUNT_ID,
recipientId()).block()).isFalse();
+ }
}
diff --git
a/server/data/data-api/src/test/java/org/apache/james/vacation/api/VacationRepositoryContract.java
b/server/data/data-api/src/test/java/org/apache/james/vacation/api/VacationRepositoryContract.java
index 9b21367dc5..814545d9d5 100644
---
a/server/data/data-api/src/test/java/org/apache/james/vacation/api/VacationRepositoryContract.java
+++
b/server/data/data-api/src/test/java/org/apache/james/vacation/api/VacationRepositoryContract.java
@@ -337,4 +337,27 @@ public interface VacationRepositoryContract {
.isInstanceOf(NullPointerException.class);
}
+ @Test
+ default void retrieveVacationShouldIgnoreCase() {
+ vacationRepository().modifyVacation(ACCOUNT_ID,
+ VacationPatch.builderFrom(VACATION)
+ .build())
+ .block();
+
+ AccountId upperCaseAccount =
AccountId.fromString(ACCOUNT_ID.getIdentifier().toUpperCase());
+ Vacation vacation =
vacationRepository().retrieveVacation(upperCaseAccount).block();
+ assertThat(vacation).isNotNull();
+ }
+
+ @Test
+ default void modifiyVacationShouldIgnoreCase() {
+ AccountId upperCaseAccount =
AccountId.fromString(ACCOUNT_ID.getIdentifier().toUpperCase());
+ vacationRepository().modifyVacation(upperCaseAccount,
+ VacationPatch.builderFrom(VACATION)
+ .build())
+ .block();
+
+ Vacation vacation =
vacationRepository().retrieveVacation(ACCOUNT_ID).block();
+ assertThat(vacation).isNotNull();
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]