-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
240 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
myconext-server/src/test/java/myconext/cron/InactivityMailDryRunTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package myconext.cron; | ||
|
||
import lombok.SneakyThrows; | ||
import myconext.AbstractMailBoxTest; | ||
import myconext.model.User; | ||
import myconext.model.UserInactivity; | ||
import myconext.repository.UserRepository; | ||
import org.awaitility.core.ConditionTimeoutException; | ||
import org.junit.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
import javax.mail.internet.MimeMessage; | ||
import java.util.List; | ||
import java.util.stream.Stream; | ||
|
||
import static myconext.cron.InactivityMail.ONE_DAY_IN_MILLIS; | ||
import static myconext.cron.InactivityMailTest.DELETED_EMAIL; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, | ||
properties = { | ||
"mongodb_db=surf_id_test", | ||
"cron.node-cron-job-responsible=true", | ||
"email_guessing_sleep_millis=1", | ||
"sp_entity_id=https://engine.test.surfconext.nl/authentication/sp/metadata", | ||
"sp_entity_metadata_url=https://engine.test.surfconext.nl/authentication/sp/metadata", | ||
"spring.main.lazy-initialization=true", | ||
"eduid_api.oidcng_introspection_uri=http://localhost:8098/introspect", | ||
"cron.service-name-resolver-initial-delay-milliseconds=60000", | ||
"oidc.base-url=http://localhost:8098/", | ||
"sso_mfa_duration_seconds=-1000", | ||
"feature.requires_signed_authn_request=false", | ||
"feature.deny_disposable_email_providers=false", | ||
"verify.base_uri=http://localhost:8098", | ||
"cron.dry-run-email=true" | ||
}) | ||
public class InactivityMailDryRunTest extends AbstractMailBoxTest { | ||
|
||
@Autowired | ||
protected InactivityMail inactivityMail; | ||
|
||
@SneakyThrows | ||
@Test | ||
public void mailInactivityMail() { | ||
inactivityUserSeed("en"); | ||
|
||
inactivityMail.mailInactiveUsers(); | ||
|
||
assertThrows(ConditionTimeoutException.class, this::mailMessages); | ||
} | ||
|
||
@SneakyThrows | ||
@Test | ||
public void mailInactivityFirstRun() { | ||
//See https://github.com/OpenConext/OpenConext-myconext/issues/656 | ||
User user = new User(); | ||
long yesterday = System.currentTimeMillis() - ONE_DAY_IN_MILLIS; | ||
user.setLastLogin(yesterday - (UserInactivity.WEEK_1_BEFORE_5_YEARS.getInactivityDays() * ONE_DAY_IN_MILLIS)); | ||
user.setEmail(UserInactivity.WEEK_1_BEFORE_5_YEARS.name()); | ||
//Explicit set userInactivity to null for self-explanation of the test code | ||
user.setUserInactivity(null); | ||
userRepository.save(user); | ||
|
||
inactivityMail.mailInactiveUsers(); | ||
|
||
assertThrows(ConditionTimeoutException.class, this::mailMessages); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.