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