import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired
import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired.WRITING
import net.pterodactylus.sone.test.whenever
-import net.pterodactylus.sone.web.WebTestUtils.redirectsTo
import net.pterodactylus.util.web.Method.GET
import net.pterodactylus.util.web.Method.POST
import org.hamcrest.MatcherAssert.assertThat
private val page = OptionsPage(template, webInterface)
+ override fun getPage() = page
+
@Before
fun setupPreferences() {
core.preferences.insertionDelay = 1
private fun <T> verifyThatOptionCanBeSet(option: String, setValue: Any?, expectedValue: T, getter: () -> T) {
request("", POST)
+ addHttpRequestParameter(option, setValue.toString())
addHttpRequestParameter("show-custom-avatars", "ALWAYS")
addHttpRequestParameter("load-linked-images", "ALWAYS")
- addHttpRequestParameter(option, setValue.toString())
- expectedException.expect(redirectsTo("options.html"))
- try {
- page.handleRequest(freenetRequest, templateContext)
- } finally {
+ verifyRedirect("options.html") {
assertThat(getter(), equalTo(expectedValue))
}
}
unsetCurrentSone()
request("", POST)
addHttpRequestParameter(name, setValue)
- expectedException.expect(redirectsTo("options.html"))
- try {
- page.handleRequest(freenetRequest, templateContext)
- } finally {
+ verifyRedirect("options.html") {
assertThat(getter(), equalTo(expectedValue))
}
}