Skip to content

Commit

Permalink
Changed disposable email domain in integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Aug 13, 2024
1 parent e6bb4a6 commit bf21e67
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("[email protected]");

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"));
}
}

0 comments on commit bf21e67

Please sign in to comment.