@@ -23,6 +23,7 @@ import io.netty.channel.socket.DatagramChannel
23
23
import io.netty.channel.socket.DatagramPacket
24
24
import io.netty.util.concurrent.DefaultThreadFactory
25
25
import org.assertj.core.api.Assertions.assertThatThrownBy
26
+ import org.awaitility.kotlin.await
26
27
import org.junit.jupiter.api.AfterAll
27
28
import org.junit.jupiter.api.AfterEach
28
29
import org.junit.jupiter.api.Assertions.assertEquals
@@ -224,4 +225,29 @@ class NettyTest {
224
225
assertEquals(0 , dtlsServer.numberOfSessions)
225
226
client.close()
226
227
}
228
+
229
+ @Test
230
+ fun `server should store session if hinted to do so` () {
231
+ val client = NettyTransportAdapter .connect(clientConf, srvAddress).mapToString()
232
+
233
+ // when normal packet is sent
234
+ assertTrue(client.send(" hi" ).await())
235
+ assertEquals(" ECHO:hi" , client.receive(5 .seconds).await())
236
+
237
+ // then session should not be stored
238
+ assertEquals(1 , dtlsServer.numberOfSessions)
239
+ assertEquals(0 , sessionStore.size())
240
+
241
+ // when a packet with session expiration hint is sent
242
+ assertTrue(client.send(" hi:sleep" ).await())
243
+ assertEquals(" ECHO:hi:sleep" , client.receive(5 .seconds).await())
244
+
245
+ // then session must be stored
246
+ await.atMost(5 .seconds).untilAsserted {
247
+ assertEquals(0 , dtlsServer.numberOfSessions)
248
+ assertEquals(1 , sessionStore.size())
249
+ }
250
+
251
+ client.close()
252
+ }
227
253
}
0 commit comments