diff --git a/myconext-server/src/main/java/myconext/cron/DisposableEmailProviders.java b/myconext-server/src/main/java/myconext/cron/DisposableEmailProviders.java index 0a15969c..c6605448 100644 --- a/myconext-server/src/main/java/myconext/cron/DisposableEmailProviders.java +++ b/myconext-server/src/main/java/myconext/cron/DisposableEmailProviders.java @@ -71,7 +71,8 @@ public void verifyDisposableEmailProviders(String email) { resolveIDisposableEmailProviders(); } int beginIndex = email.indexOf("@") + 1; - boolean disposableEmail = disposableEmailProviders.contains(email.substring(beginIndex).toLowerCase()); + String domainLowerCase = email.substring(beginIndex).toLowerCase(); + boolean disposableEmail = disposableEmailProviders.contains(domainLowerCase); if (disposableEmail) { throw new DisposableEmailProviderException(); } diff --git a/myconext-server/src/test/java/myconext/cron/DisposableEmailProvidersTest.java b/myconext-server/src/test/java/myconext/cron/DisposableEmailProvidersTest.java index f6b326a6..8fd0dbf4 100644 --- a/myconext-server/src/test/java/myconext/cron/DisposableEmailProvidersTest.java +++ b/myconext-server/src/test/java/myconext/cron/DisposableEmailProvidersTest.java @@ -10,22 +10,24 @@ class DisposableEmailProvidersTest { + private static final ObjectMapper objectMapper = new ObjectMapper(); + @Test void isDisposableEmailProviders() { Environment environment = new MockEnvironment(); - DisposableEmailProviders subject = new DisposableEmailProviders(new ObjectMapper(), environment, true); - assertThrows(DisposableEmailProviderException.class, () -> subject.verifyDisposableEmailProviders("jdoe@TRASHMAIL.LIVE")); + DisposableEmailProviders subject = new DisposableEmailProviders(objectMapper, environment, true); + assertThrows(DisposableEmailProviderException.class, () -> subject.verifyDisposableEmailProviders("jdoe@TRASHMAIL.WS")); subject.verifyDisposableEmailProviders("jdoe@gmail.com"); - DisposableEmailProviders subjectFeatureOff = new DisposableEmailProviders(new ObjectMapper(), environment, false); - subjectFeatureOff.verifyDisposableEmailProviders("jdoe@trashmail.live"); + DisposableEmailProviders subjectFeatureOff = new DisposableEmailProviders(objectMapper, environment, false); + subjectFeatureOff.verifyDisposableEmailProviders("jdoe@TRASHMAIL.WS"); } @Test void isDisposableEmailProvidersLocalEnvironment() { MockEnvironment environment = new MockEnvironment(); environment.addActiveProfile("test"); - DisposableEmailProviders subject = new DisposableEmailProviders(new ObjectMapper(), environment, true); - assertThrows(DisposableEmailProviderException.class, () -> subject.verifyDisposableEmailProviders("jdoe@ujixlaxpros.tech")); + DisposableEmailProviders subject = new DisposableEmailProviders(objectMapper, environment, true); + assertThrows(DisposableEmailProviderException.class, () -> subject.verifyDisposableEmailProviders("jdoe@UJIXLAXPROS.tech")); } } \ No newline at end of file