Add tests for nginx.conf directives #1

Merged
ccm merged 26 commits from ccm-test-nginx-directives into trunk 2025-06-14 21:54:22 +00:00
Showing only changes of commit f364eb6887 - Show all commits

View File

@ -104,24 +104,26 @@ describe "http://miti.sh/posts", ->
assert.same request\body!\match("<title>(.*)</title>"), "miti.sh · Posts"
describe "http://git.miti.sh", ->
it "reverse proxies request to gitea through a unix socket", ->
it "reverse-proxies request to a gitea unix socket", ->
Path = require "sitegen.path"
socket_fname = "unixstreamsrvr.moon"
socket_dir = "/run/gitea"
socket_owner = "nobody"
basepath = Path.basepath debug.getinfo(1).short_src
os.execute "mkdir " .. socket_dir
p = io.popen "moon %s"\format Path.join(basepath, socket_fname)
os.execute "sleep 0.1"
os.execute "chown -R " .. socket_owner .. " " .. socket_dir
Path.mkdir socket_dir
server = io.popen "moon %s"\format Path.join(basepath, socket_fname)
Path.exec "sleep", "0.1"
Path.exec "chown", "-R", socket_owner, socket_dir
result = Path.read_exec "find", socket_dir, "-type", "s", "-ls"
assert.truthy result\match "nobody%s+root.+" .. Path.join(socket_dir, "gitea.socket")
request = req "http://git.miti.sh"
pout = p\read"*a"
p\close!
assert.truthy pout\match "Host: git.miti.sh"
req "http://git.miti.sh"
reqheader = with server\read "*a"
server\close!
assert.truthy reqheader\match "Host: git.miti.sh"
describe "http://apps.miti.sh", ->
it "doesn't find it", ->