Skip to content

Commit

Permalink
Tests for email template for eduID only invitations
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Jan 8, 2024
1 parent 75cbbfc commit e40fce7
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions server/src/test/java/access/mail/MailBoxTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Set;
import java.util.UUID;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

class MailBoxTest extends AbstractMailTest {
Expand All @@ -21,12 +22,31 @@ class MailBoxTest extends AbstractMailTest {

@Test
void sendInviteMail() {
String htmlContent = doSendInviteMail(true, Authority.INVITER);

assertTrue(htmlContent.contains("Wiki EN"));
assertTrue(htmlContent.contains("SURF bv"));
assertTrue(htmlContent.contains("For access to these applications we use SURFconext"));
assertFalse(htmlContent.contains("For access to these applications eduID is used"));
}

@Test
void sendInviteMailForEduIDOnly() {
String htmlContent = doSendInviteMail(true, Authority.GUEST);

assertTrue(htmlContent.contains("Wiki EN"));
assertTrue(htmlContent.contains("SURF bv"));
assertFalse(htmlContent.contains("For access to these applications we use SURFconext"));
assertTrue(htmlContent.contains("For access to these applications eduID is used"));
}

private String doSendInviteMail(boolean eduIDOnly, Authority intendedAuthority) {
User user = new User(false, "eppn", "sub", "example.com", "John", "Doe", "[email protected]");
Invitation invitation = new Invitation(Authority.GUEST,
Invitation invitation = new Invitation(intendedAuthority,
"hash",
"[email protected]",
false,
false,
eduIDOnly,
false,
"Please join..",
user,
Expand All @@ -45,10 +65,7 @@ void sendInviteMail() {
UUID.randomUUID().toString())
));
MimeMessageParser mimeMessageParser = super.mailMessage();
String htmlContent = mimeMessageParser.getHtmlContent();

assertTrue(htmlContent.contains("Wiki EN"));
assertTrue(htmlContent.contains("SURF bv"));
return mimeMessageParser.getHtmlContent();
}


Expand Down

0 comments on commit e40fce7

Please sign in to comment.