aboutsummaryrefslogtreecommitdiff
path: root/server/test/src/ServerSpec.scala
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-01-02 22:18:57 +0000
committerJuan J. Martinez <jjm@usebox.net>2022-01-02 22:24:48 +0000
commit21f8ae5db73be083340bb65b4e1ab7ec3abb41b7 (patch)
treeb3421907d2133b06d0800a1c6dc0c6a47abff64d /server/test/src/ServerSpec.scala
parentb5b419ad0a89b36e136f4509a59a145f991e833d (diff)
downloadspacebeans-21f8ae5db73be083340bb65b4e1ab7ec3abb41b7.tar.gz
spacebeans-21f8ae5db73be083340bb65b4e1ab7ec3abb41b7.zip
Resolve CGI directories from more to less specific
Closes issue #2.
Diffstat (limited to 'server/test/src/ServerSpec.scala')
-rw-r--r--server/test/src/ServerSpec.scala39
1 files changed, 39 insertions, 0 deletions
diff --git a/server/test/src/ServerSpec.scala b/server/test/src/ServerSpec.scala
index dd6bf20..7d8c1fa 100644
--- a/server/test/src/ServerSpec.scala
+++ b/server/test/src/ServerSpec.scala
@@ -692,6 +692,21 @@ class ServerSpec extends AnyFlatSpec with Matchers {
cgi.body should include("PATH_INFO=/path/info")
}
+ it should "resolve CGI directories from more to less specific" in {
+ // issue: https://gitlab.com/reidrac/spacebeans/-/issues/2
+ val cgi = Server(TestData.cgiPrefConf)
+ .handleReq(
+ "gemini://localhost/dir/sub/cgiOk/path/info",
+ "127.0.0.1"
+ )
+ .asInstanceOf[Cgi]
+
+ cgi.status should be(20)
+ cgi.meta should be("text/gemini")
+ cgi.body should include("GATEWAY_INTERFACE=CGI/1.1")
+ cgi.body should include("PATH_INFO=/path/info")
+ }
+
object TestData {
val host = "localhost"
@@ -733,6 +748,30 @@ class ServerSpec extends AnyFlatSpec with Matchers {
)
)
+ val cgiPrefConf = ServiceConf.initConf(
+ conf.copy(virtualHosts =
+ List(
+ conf
+ .virtualHosts(0)
+ .copy(
+ directoryListing = true,
+ directories = List(
+ Directory(
+ "dir/",
+ directoryListing = Some(false),
+ allowCgi = Some(true)
+ ),
+ Directory(
+ "dir/sub/",
+ directoryListing = Some(false),
+ allowCgi = Some(true)
+ )
+ )
+ )
+ )
+ )
+ )
+
val cgiEnvConf = cgiConf.copy(virtualHosts =
List(
cgiConf