diff options
author | Tyler St. Onge <tylertstonge@gmail.com> | 2020-07-25 22:38:14 -0400 |
---|---|---|
committer | Tyler St. Onge <tylertstonge@gmail.com> | 2020-07-25 22:38:14 -0400 |
commit | 747b6af76b23650756811d896bf76b4331419784 (patch) | |
tree | 2e942c8296567cbe4d57f205f72029a62829bdda /src/test | |
parent | 945332ca057383f258c78fd15cbc22f8b8d58a83 (diff) |
refine ftp component and add configuration capabilities
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/scala/com/tylerstonge/honeypot/ftp/FtpHandlerTest.scala | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/test/scala/com/tylerstonge/honeypot/ftp/FtpHandlerTest.scala b/src/test/scala/com/tylerstonge/honeypot/ftp/FtpHandlerTest.scala new file mode 100644 index 0000000..bc9b799 --- /dev/null +++ b/src/test/scala/com/tylerstonge/honeypot/ftp/FtpHandlerTest.scala @@ -0,0 +1,48 @@ +package com.tylerstonge.honeypot.ftp
+
+import akka.actor.{ActorSystem, Props}
+import akka.io.Tcp.{Received, Write}
+import akka.testkit.{ImplicitSender, TestKit}
+import akka.util.ByteString
+import org.scalatest.BeforeAndAfterAll
+import org.scalatest.matchers.should.Matchers
+import org.scalatest.wordspec.AnyWordSpecLike
+
+/**
+ *
+ * @author Tyler St. Onge <tylertstonge@gmail.com>
+ */
+class FtpHandlerTest extends TestKit(ActorSystem("honeypot-system")) with ImplicitSender with AnyWordSpecLike with Matchers with BeforeAndAfterAll {
+
+ override def afterAll: Unit = {
+ TestKit.shutdownActorSystem(system)
+ }
+
+ "An FtpHandler actor" must {
+ "return 331 in response to USER" in {
+ val handler = system.actorOf(Props[FtpHandler])
+ handler ! Received(ByteString("USER anonymous"))
+ val msg = expectMsgType[Write]
+ assert(msg.data.utf8String.startsWith("331"))
+ }
+ "return 230 in response to PASS" in {
+ val handler = system.actorOf(Props[FtpHandler])
+ handler ! Received(ByteString("PASS password"))
+ val msg = expectMsgType[Write]
+ assert(msg.data.utf8String.startsWith("230"))
+ }
+ "return 257 in response to PWD" in {
+ val handler = system.actorOf(Props[FtpHandler])
+ handler ! Received(ByteString("PWD"))
+ val msg = expectMsgType[Write]
+ assert(msg.data.utf8String.startsWith("257"))
+ }
+ "return 221 in response to QUIT" in {
+ val handler = system.actorOf(Props[FtpHandler])
+ handler ! Received(ByteString("quit"))
+ val msg = expectMsgType[Write]
+ assert(msg.data.utf8String.startsWith("221"))
+ }
+ }
+
+}
|