whenever(sone.isLocal).thenReturn(true)
whenever(reply.sone).thenReturn(sone)
}
-
+
@Test
fun `get request sets reply ID and return page in template context`() {
- request("", GET)
+ request("", GET)
addHttpRequestParameter("reply", "reply-id")
addHttpRequestParameter("returnPage", "return.html")
page.handleRequest(freenetRequest, templateContext)
@Test
fun `post request without any action sets reply ID and return page in template context`() {
- request("", POST)
+ request("", POST)
addPostReply("reply-id", reply)
addHttpRequestParameter("reply", "reply-id")
addHttpRequestParameter("returnPage", "return.html")
@Test
fun `trying to delete a reply from a non-local sone results in no permission page`() {
- request("", POST)
+ request("", POST)
addHttpRequestParameter("reply", "reply-id")
whenever(sone.isLocal).thenReturn(false)
addPostReply("reply-id", reply)
@Test
fun `confirming deletion of reply deletes the reply and redirects to return page`() {
- request("", POST)
+ request("", POST)
addPostReply("reply-id", reply)
addHttpRequestParameter("reply", "reply-id")
addHttpRequestParameter("returnPage", "return.html")
verify(core).deleteReply(reply)
}
}
-
+
@Test
fun `aborting deletion of reply redirects to return page`() {
- request("", POST)
+ request("", POST)
addPostReply("reply-id", reply)
addHttpRequestParameter("reply", "reply-id")
addHttpRequestParameter("returnPage", "return.html")
@Test
fun `get request does not redirect`() {
- request("", GET)
+ request("", GET)
page.handleRequest(freenetRequest, templateContext)
}
@Test
fun `post request with invalid sone redirects to return page`() {
- request("", POST)
+ request("", POST)
addHttpRequestParameter("returnPage", "return.html")
verifyRedirect("return.html")
}
@Test
fun `post request with valid sone distrusts sone and redirects to return page`() {
- request("", POST)
+ request("", POST)
val remoteSone = mock<Sone>()
addSone("remote-sone-id", remoteSone)
addHttpRequestParameter("returnPage", "return.html")