Move socket test server file into spec dir
This commit is contained in:
@@ -104,14 +104,20 @@ 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 unix socket", ->
|
||||
os.execute "mkdir /run/gitea"
|
||||
p = io.popen "luajit unixstreamsrvr.lua"
|
||||
os.execute("sleep 1")
|
||||
os.execute("chown -R nobody /run/gitea")
|
||||
it "reverse proxies request to gitea through a unix socket", ->
|
||||
Path = require "sitegen.path"
|
||||
filename = "unixstreamsrvr.lua"
|
||||
socket_dir = "/run/gitea"
|
||||
info = debug.getinfo 1
|
||||
basepath = Path.basepath info.short_src
|
||||
|
||||
os.execute "mkdir " .. socket_dir
|
||||
p = io.popen "luajit %s"\format Path.join basepath, filename
|
||||
os.execute "sleep 0"
|
||||
os.execute "chown -R nobody " .. socket_dir
|
||||
|
||||
request = req "http://git.miti.sh"
|
||||
assert.is_not_nil p\read"*a"\match "Host: git.miti.sh"
|
||||
assert.truthy p\read"*a"\match "Host: git.miti.sh"
|
||||
|
||||
describe "http://apps.miti.sh", ->
|
||||
it "doesn't find it", ->
|
||||
|
||||
12
spec/unixstreamsrvr.lua
Normal file
12
spec/unixstreamsrvr.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
socket = require"socket"
|
||||
socket.unix = require"socket.unix"
|
||||
u = assert(socket.unix.stream())
|
||||
assert(u:bind("/run/gitea/gitea.socket"))
|
||||
assert(u:listen())
|
||||
c = assert(u:accept())
|
||||
|
||||
m = assert(c:receive())
|
||||
repeat
|
||||
print(m)
|
||||
m = assert(c:receive())
|
||||
until m == ""
|
||||
Reference in New Issue
Block a user