From 60d4dce0193fb9d592f2fe065908bfc88da89dff Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sun, 16 Jan 2022 00:22:24 +0000 Subject: Refactor Gemini protocol --- server/test/src/URIUtilsSpec.scala | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 server/test/src/URIUtilsSpec.scala (limited to 'server/test/src/URIUtilsSpec.scala') diff --git a/server/test/src/URIUtilsSpec.scala b/server/test/src/URIUtilsSpec.scala new file mode 100644 index 0000000..ab00c86 --- /dev/null +++ b/server/test/src/URIUtilsSpec.scala @@ -0,0 +1,26 @@ +package net.usebox.gemini.server + +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + +import URIUtils._ + +class URIUtilsSpec extends AnyFlatSpec with Matchers { + + behavior of "validPath" + + it should "return true for the emtpy path" in { + "".isValidPath shouldBe true + } + + it should "return true for valid paths" in { + List("/", "/file", "/./", "/.", "/dir/", "/dir/../").foreach( + _.isValidPath shouldBe true + ) + } + + it should "return false for invalid paths" in { + List("/../", "/..", "/dir/../..", "/dir/../..", "/./../", "/./dir/.././../") + .foreach(_.isValidPath shouldBe false) + } +} -- cgit v1.2.3