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.POST
7 import org.mockito.ArgumentMatchers.any
8 import org.mockito.ArgumentMatchers.eq
9 import org.mockito.Mockito.never
10 import org.mockito.Mockito.verify
13 * Unit test for [TrustPage].
15 class TrustPageTest : WebPageTest() {
17 private val page = TrustPage(template, webInterface)
19 override fun getPage() = page
22 fun `get method does not redirect`() {
23 page.handleRequest(freenetRequest, templateContext)
27 fun `post request with missing sone redirects to return page`() {
29 addHttpRequestParameter("returnPage", "return.html")
30 addHttpRequestParameter("sone", "sone-id")
31 verifyRedirect("return.html") {
32 verify(core, never()).trustSone(eq(currentSone), any())
37 fun `post request with existing sone trusts the identity and redirects to return page`() {
39 addHttpRequestParameter("returnPage", "return.html")
40 addHttpRequestParameter("sone", "sone-id")
41 val sone = mock<Sone>()
42 addSone("sone-id", sone)
43 verifyRedirect("return.html") {
44 verify(core).trustSone(eq(currentSone), eq(sone))