From cfbb8d48a22bd8c905b5e247c52a949d73c363be Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Wed, 1 Sep 2021 21:14:35 +0100 Subject: FIX: index file can be a CGI and should be executed --- server/test/src/ServerSpec.scala | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'server/test/src') diff --git a/server/test/src/ServerSpec.scala b/server/test/src/ServerSpec.scala index d3027e3..ea40798 100644 --- a/server/test/src/ServerSpec.scala +++ b/server/test/src/ServerSpec.scala @@ -621,6 +621,46 @@ class ServerSpec extends AnyFlatSpec with Matchers { cgi.body should include("env1=value") } + it should "execute a CGI when it is the index document" in { + val cgi = Server(TestData.cgiIndexConf) + .handleReq( + "gemini://localhost/dir/", + "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") + } + + it should "execute a CGI when it is the index document (full name)" in { + val cgi = Server(TestData.cgiIndexConf) + .handleReq( + "gemini://localhost/dir/cgi", + "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") + } + + it should "execute a CGI when it is the index document (full name, path info)" in { + val cgi = Server(TestData.cgiIndexConf) + .handleReq( + "gemini://localhost/dir/cgi/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" @@ -672,6 +712,16 @@ class ServerSpec extends AnyFlatSpec with Matchers { ) ) + val cgiIndexConf = cgiConf.copy(virtualHosts = + List( + cgiConf + .virtualHosts(0) + .copy( + indexFile = "cgi" + ) + ) + ) + val confUserDir = conf.copy(virtualHosts = List( conf -- cgit v1.2.3