forked from WebGoat/WebGoat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unable to save email send to WebWolf WebGoat#419
- Loading branch information
Showing
3 changed files
with
60 additions
and
1 deletion.
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
49 changes: 49 additions & 0 deletions
49
webwolf/src/test/java/org/owasp/webwolf/mailbox/MailboxRepositoryTest.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,49 @@ | ||
package org.owasp.webwolf.mailbox; | ||
|
||
import org.hamcrest.CoreMatchers; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
@DataJpaTest | ||
@RunWith(SpringRunner.class) | ||
public class MailboxRepositoryTest { | ||
|
||
|
||
@Autowired | ||
private MailboxRepository mailboxRepository; | ||
|
||
@Test | ||
public void emailShouldBeSaved() { | ||
Email email = new Email(); | ||
email.setTime(LocalDateTime.now()); | ||
email.setTitle("test"); | ||
email.setSender("[email protected]"); | ||
email.setContents("test"); | ||
email.setRecipient("[email protected]"); | ||
mailboxRepository.save(email); | ||
} | ||
|
||
@Test | ||
public void savedEmailShouldBeFoundByReceipient() { | ||
Email email = new Email(); | ||
email.setTime(LocalDateTime.now()); | ||
email.setTitle("test"); | ||
email.setSender("[email protected]"); | ||
email.setContents("test"); | ||
email.setRecipient("[email protected]"); | ||
mailboxRepository.saveAndFlush(email); | ||
|
||
List<Email> emails = mailboxRepository.findByRecipientOrderByTimeDesc("[email protected]"); | ||
|
||
assertThat(emails.size(), CoreMatchers.is(1)); | ||
} | ||
|
||
} |