From 4f1ab525021ebf8f3d36ff250614bf67e19c2232 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 7 Apr 2020 16:28:12 +0200 Subject: [PATCH] =?utf8?q?=F0=9F=94=A5=20Remove=20session=20access=20from?= =?utf8?q?=20freenet=20request?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../pterodactylus/sone/web/page/FreenetRequest.kt | 11 +-------- .../sone/web/page/FreenetRequestTest.kt | 28 ---------------------- 2 files changed, 1 insertion(+), 38 deletions(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/page/FreenetRequest.kt b/src/main/kotlin/net/pterodactylus/sone/web/page/FreenetRequest.kt index 38e0100..ce2eacb 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/page/FreenetRequest.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/page/FreenetRequest.kt @@ -29,13 +29,4 @@ open class FreenetRequest(uri: URI, method: Method, val httpRequest: HTTPRequest, val toadletContext: ToadletContext, val sessionManager: SessionManager -) : Request(uri, method) { - - val session: Session - get() = - sessionManager.useSession(toadletContext) - ?: sessionManager.createSession(randomUUID().toString(), toadletContext) - - val existingSession: Session? get() = sessionManager.useSession(toadletContext) - -} +) : Request(uri, method) diff --git a/src/test/kotlin/net/pterodactylus/sone/web/page/FreenetRequestTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/page/FreenetRequestTest.kt index 3295bdd..0c3fad9 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/page/FreenetRequestTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/page/FreenetRequestTest.kt @@ -1,14 +1,12 @@ package net.pterodactylus.sone.web.page import freenet.clients.http.* -import freenet.clients.http.SessionManager.* import freenet.support.api.* import net.pterodactylus.sone.test.* import net.pterodactylus.util.web.* import org.hamcrest.MatcherAssert.* import org.hamcrest.Matchers.* import org.junit.* -import org.mockito.* import org.mockito.Mockito.* import java.net.* @@ -41,30 +39,4 @@ class FreenetRequestTest { assertThat(request.toadletContext, equalTo(toadletContext)) } - @Test - fun `null is returned if no session exists`() { - assertThat(request.existingSession, nullValue()) - } - - @Test - fun `existing session can be retrieved`() { - val session = mock() - whenever(sessionManager.useSession(toadletContext)).thenReturn(session) - assertThat(request.existingSession, sameInstance(session)) - } - - @Test - fun `existing session is returned if it exists`() { - val session = mock() - whenever(sessionManager.useSession(toadletContext)).thenReturn(session) - assertThat(request.session, sameInstance(session)) - } - - @Test - fun `new session is returned if none exists`() { - val session = mock() - whenever(sessionManager.createSession(anyString(), ArgumentMatchers.eq(toadletContext))).thenReturn(session) - assertThat(request.session, sameInstance(session)) - } - } -- 2.7.4