1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.data.Sone
4 import net.pterodactylus.sone.test.mock
5 import net.pterodactylus.util.web.Method.POST
6 import org.hamcrest.MatcherAssert.assertThat
7 import org.hamcrest.Matchers.equalTo
9 import org.mockito.ArgumentMatchers.any
10 import org.mockito.Mockito.never
11 import org.mockito.Mockito.verify
14 * Unit test for [LockSonePage].
16 class LockSonePageTest: WebPageTest(::LockSonePage) {
19 fun `page returns correct path`() {
20 assertThat(page.path, equalTo("lockSone.html"))
24 fun `page does not require login`() {
25 assertThat(page.requiresLogin(), equalTo(false))
29 fun `page returns correct title`() {
30 addTranslation("Page.LockSone.Title", "lock Sone page title")
31 assertThat(page.getPageTitle(freenetRequest), equalTo("lock Sone page title"))
35 fun `locking an invalid local sone redirects to return page`() {
37 addHttpRequestPart("returnPage", "return.html")
38 verifyRedirect("return.html") {
39 verify(core, never()).lockSone(any<Sone>())
44 fun `locking an valid local sone locks the sone and redirects to return page`() {
46 addHttpRequestPart("sone", "sone-id")
47 val sone = mock<Sone>()
48 addLocalSone("sone-id", sone)
49 addHttpRequestPart("returnPage", "return.html")
50 verifyRedirect("return.html") {
51 verify(core).lockSone(sone)