Skip to content

Commit

Permalink
Remove redundant getSessionCid method
Browse files Browse the repository at this point in the history
  • Loading branch information
szysas committed Aug 18, 2023
1 parent 9ee12f3 commit 0cc73c3
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ class DtlsServer(
private val sessions = mutableMapOf<InetSocketAddress, DtlsState>()
private val cidSize = sslConfig.cidSupplier.next().size
val numberOfSessions get() = sessions.size
fun getSessionCid(inet: InetSocketAddress): ByteArray? {
val dtlsState = sessions[inet] as? DtlsSession
return dtlsState?.sessionContext?.cid
}

fun handleReceived(adr: InetSocketAddress, buf: ByteBuffer): ReceiveResult {
val cid by lazy { SslContext.peekCID(cidSize, buf) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,4 @@ class DtlsServerTransport private constructor(
executor.supply {
dtlsServer.putSessionAuthenticationContext(adr, key, value)
}

fun getSessionCid(adr: InetSocketAddress) = executor.supply { dtlsServer.getSessionCid(adr) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -226,24 +226,6 @@ class DtlsServerTest {
clientSession.close()
}

@Test
fun `should find session cid`() {
// given
val clientSession = clientHandshake()
val cid = dtlsServer.getSessionCid(localAddress(2_5684))
assert(cid!!.isNotEmpty())
clientSession.close()
}

@Test
fun `shouldn't find session cid`() {
// given
val clientSession = clientHandshake()
val cid = dtlsServer.getSessionCid(localAddress(1234))
assertEquals(null, cid)
clientSession.close()
}

private fun clientHandshake(): SslSession {
val send: (ByteBuffer) -> Unit = { dtlsServer.handleReceived(localAddress(2_5684), it) }
val cliHandshake = clientConf.newContext(localAddress(5684))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import org.awaitility.kotlin.await
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.assertNull
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import org.opencoap.ssl.CertificateAuth
Expand Down Expand Up @@ -438,15 +437,6 @@ class DtlsServerTransportTest {
assertTrue(server.executor() is ScheduledThreadPoolExecutor)
}

@Test
fun `should not return cid`() {
server = DtlsServerTransport.create(conf, lifecycleCallbacks = sslLifecycleCallbacks).listen(echoHandler)
val client = DtlsTransmitter.connect(server, clientConfig).await()
client.send("hello!")
val cid = server.getSessionCid(localAddress(1234)).await()
assertNull(cid)
}

@Test
fun `should set and use session context`() {
// given
Expand Down

0 comments on commit 0cc73c3

Please sign in to comment.