import net.pterodactylus.sone.freenet.wot.OwnIdentity
import net.pterodactylus.sone.test.mock
import net.pterodactylus.sone.test.whenever
-import net.pterodactylus.sone.web.pages.WebPageTest
-import net.pterodactylus.sone.web.pages.CreateSonePage
import net.pterodactylus.util.web.Method.POST
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.contains
@Test
fun `sone is created and logged in`() {
addExistingOwnIdentities()
- request("", POST)
+ setMethod(POST)
addHttpRequestPart("identity", "own-id-3")
val newSone = mock<Sone>()
whenever(core.createSone(ownIdentities_[2])).thenReturn(newSone)
@Test
fun `on invalid identity id a flag is set in the template context`() {
- request("", POST)
+ setMethod(POST)
addHttpRequestParameter("identity", "own-id-3")
page.processTemplate(freenetRequest, templateContext)
assertThat(templateContext["errorNoIdentity"], equalTo<Any>(true))
@Test
fun `if sone is not created user is still redirected to index`() {
addExistingOwnIdentities()
- request("", POST)
+ setMethod(POST)
addHttpRequestPart("identity", "own-id-3")
whenever(core.createSone(ownIdentities_[2])).thenReturn(null)
verifyRedirect("index.html") {