File tree Expand file tree Collapse file tree
myconext-server/src/test/java/myconext/mail Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package myconext .mail ;
2+
3+ import jakarta .mail .internet .MimeMessage ;
4+ import lombok .SneakyThrows ;
5+ import myconext .AbstractMailBoxTest ;
6+ import myconext .security .VerificationCodeGenerator ;
7+ import org .junit .Test ;
8+ import org .springframework .beans .factory .annotation .Autowired ;
9+ import org .springframework .test .context .TestPropertySource ;
10+
11+ import static com .icegreen .greenmail .util .GreenMailUtil .getBody ;
12+ import static org .junit .Assert .assertEquals ;
13+ import static org .junit .Assert .assertTrue ;
14+
15+ @ TestPropertySource (properties = {
16+ "gui.disclaimer.content=SomeTestEnvironment" ,
17+ })
18+ public class MailBoxNotProductionEnvironmentTest extends AbstractMailBoxTest {
19+
20+ @ Autowired
21+ private MailBox mailBox ;
22+
23+ @ Test
24+ @ SneakyThrows
25+ public void mailBoxTest_emailSubjectUppercaseTestEnvironment () {
26+ String code = VerificationCodeGenerator .generateOneTimeLoginCode ();
27+ mailBox .sendOneTimeLoginCode (user ("jdoe@example.com" , "en" ), code );
28+
29+ MimeMessage mimeMessage = mailMessage ();
30+ String subject = mimeMessage .getSubject ();
31+ assertEquals ("[SOMETESTENVIRONMENT environment] eduID login code" , subject );
32+
33+ String body = getBody (mimeMessage );
34+ assertTrue (body .contains (code ));
35+ }
36+ }
Original file line number Diff line number Diff line change 1+ package myconext .mail ;
2+
3+ import jakarta .mail .internet .MimeMessage ;
4+ import lombok .SneakyThrows ;
5+ import myconext .AbstractMailBoxTest ;
6+ import myconext .security .VerificationCodeGenerator ;
7+ import org .junit .Test ;
8+ import org .springframework .beans .factory .annotation .Autowired ;
9+ import org .springframework .test .context .TestPropertySource ;
10+
11+ import static com .icegreen .greenmail .util .GreenMailUtil .getBody ;
12+ import static org .junit .Assert .assertEquals ;
13+ import static org .junit .Assert .assertTrue ;
14+
15+ @ TestPropertySource (properties = {
16+ "gui.disclaimer.content=" ,
17+ })
18+ public class MailBoxProductionEnvironmentTest extends AbstractMailBoxTest {
19+
20+ @ Autowired
21+ private MailBox mailBox ;
22+
23+ @ Test
24+ @ SneakyThrows
25+ public void mailBoxTest_emailSubjectProductionEnvironment () {
26+ String code = VerificationCodeGenerator .generateOneTimeLoginCode ();
27+ mailBox .sendOneTimeLoginCode (user ("jdoe@example.com" , "en" ), code );
28+
29+ MimeMessage mimeMessage = mailMessage ();
30+ String subject = mimeMessage .getSubject ();
31+ assertEquals ("eduID login code" , subject );
32+
33+ String body = getBody (mimeMessage );
34+ assertTrue (body .contains (code ));
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments