1 package net.pterodactylus.sone.web
3 import net.pterodactylus.sone.data.Sone
4 import net.pterodactylus.sone.test.mock
5 import net.pterodactylus.util.web.Method.GET
6 import net.pterodactylus.util.web.Method.POST
8 import org.mockito.Mockito.verify
11 * Unit test for [DistrustPage].
13 class DistrustPageTest : WebPageTest() {
15 private val page = DistrustPage(template, webInterface)
17 override fun getPage() = page
20 fun `get request does not redirect`() {
22 page.handleRequest(freenetRequest, templateContext)
26 fun `post request with invalid sone redirects to return page`() {
28 addHttpRequestParameter("returnPage", "return.html")
29 verifyRedirect("return.html")
33 fun `post request with valid sone distrusts sone and redirects to return page`() {
35 val remoteSone = mock<Sone>()
36 addSone("remote-sone-id", remoteSone)
37 addHttpRequestParameter("returnPage", "return.html")
38 addHttpRequestParameter("sone", "remote-sone-id")
39 verifyRedirect("return.html") {
40 verify(core).distrustSone(currentSone, remoteSone)