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/TestData.scala | 108 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 server/test/src/TestData.scala (limited to 'server/test/src/TestData.scala') diff --git a/server/test/src/TestData.scala b/server/test/src/TestData.scala new file mode 100644 index 0000000..df3fbd6 --- /dev/null +++ b/server/test/src/TestData.scala @@ -0,0 +1,108 @@ +package net.usebox.gemini.server + +import scala.concurrent.duration._ + +object TestData { + + val host = "localhost" + val port = 1965 + val portStr = port.toString() + + val conf = ServiceConf( + address = "127.0.0.1", + port = port, + defaultMimeType = "text/plain", + idleTimeout = 10.seconds, + virtualHosts = List( + VirtualHost( + host = host, + root = getClass.getResource("/").getPath() + ) + ), + genCertValidFor = 1.day, + enabledProtocols = Nil, + enabledCipherSuites = Nil + ) + + val cgiConf = ServiceConf.initConf( + conf.copy(virtualHosts = + List( + conf + .virtualHosts(0) + .copy( + directoryListing = true, + directories = List( + Directory( + "dir/", + directoryListing = Some(false), + allowCgi = Some(true) + ) + ) + ) + ) + ) + ) + + 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 + .virtualHosts(0) + .copy( + environment = Some(Map("env1" -> "value")) + ) + ) + ) + + val cgiIndexConf = cgiConf.copy(virtualHosts = + List( + cgiConf + .virtualHosts(0) + .copy( + indexFile = "cgi" + ) + ) + ) + + val confUserDir = conf.copy(virtualHosts = + List( + conf + .virtualHosts(0) + .copy( + userDirectories = true, + userDirectoryPath = Some( + getClass.getResource("/").getPath() + "{user}/public_gemini/" + ) + ) + ) + ) + + val mimeTypes = Some( + Map( + "config" -> List(".gmi", ".gemini") + ) + ) +} -- cgit v1.2.3