-
Notifications
You must be signed in to change notification settings - Fork 181
/
Copy pathworker_file_permissions_spec.lua
59 lines (50 loc) · 2.91 KB
/
worker_file_permissions_spec.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
local http = require "resty.http"
local server = require "spec.support.server"
local shell_blocking = require "shell-games"
describe("worker file permissions", function()
before_each(server.stop)
after_each(server.stop)
it("creates file with expected permissions", function()
server.start({
master_process = "on",
})
local httpc = http.new()
local _, connect_err = httpc:connect("127.0.0.1", 9443)
assert.equal(nil, connect_err)
local _, ssl_err = httpc:ssl_handshake(nil, server.ngrok_hostname, true)
assert.equal(nil, ssl_err)
local res, request_err = httpc:request({ path = "/foo" })
assert.equal(nil, request_err)
assert.equal(200, res.status)
local body, body_err = res:read_body()
assert.equal(nil, body_err)
assert.equal("foo", body)
local result, shell_err = shell_blocking.capture_combined({ "find", server.current_test_dir .. "/auto-ssl", "-printf", [[./%P %u %g %m %y\n]] })
assert.equal(nil, shell_err)
local output = string.gsub(result["output"], "%s+$", "")
local lines = {}
for line in string.gmatch(output, "[^\n]+") do
table.insert(lines, line)
end
table.sort(lines)
assert.same({
"./ nobody root 755 d",
"./letsencrypt root root 777 d",
"./letsencrypt/.acme-challenges " .. server.nobody_user .. " " .. server.nobody_group .. " 755 d",
"./letsencrypt/accounts " .. server.nobody_user .. " " .. server.nobody_group .. " 700 d",
"./letsencrypt/accounts/aHR0cHM6Ly9hY21lLXN0YWdpbmctdjAyLmFwaS5sZXRzZW5jcnlwdC5vcmcvZGlyZWN0b3J5Cg " .. server.nobody_user .. " " .. server.nobody_group .. " 700 d",
"./letsencrypt/accounts/aHR0cHM6Ly9hY21lLXN0YWdpbmctdjAyLmFwaS5sZXRzZW5jcnlwdC5vcmcvZGlyZWN0b3J5Cg/account_id.json " .. server.nobody_user .. " " .. server.nobody_group .. " 600 f",
"./letsencrypt/accounts/aHR0cHM6Ly9hY21lLXN0YWdpbmctdjAyLmFwaS5sZXRzZW5jcnlwdC5vcmcvZGlyZWN0b3J5Cg/account_key.pem " .. server.nobody_user .. " " .. server.nobody_group .. " 600 f",
"./letsencrypt/accounts/aHR0cHM6Ly9hY21lLXN0YWdpbmctdjAyLmFwaS5sZXRzZW5jcnlwdC5vcmcvZGlyZWN0b3J5Cg/registration_info.json " .. server.nobody_user .. " " .. server.nobody_group .. " 600 f",
"./letsencrypt/certs " .. server.nobody_user .. " " .. server.nobody_group .. " 700 d",
"./letsencrypt/chains " .. server.nobody_user .. " " .. server.nobody_group .. " 700 d",
"./letsencrypt/conf.d root root 755 d",
"./letsencrypt/config root root 644 f",
"./letsencrypt/locks " .. server.nobody_user .. " " .. server.nobody_group .. " 755 d",
"./storage " .. server.nobody_user .. " " .. server.nobody_group .. " 755 d",
"./storage/file " .. server.nobody_user .. " " .. server.nobody_group .. " 700 d",
"./storage/file/" .. ngx.escape_uri(server.ngrok_hostname .. ":latest") .. " " .. server.nobody_user .. " " .. server.nobody_group .. " 644 f",
"./tmp root root 777 d",
}, lines)
end)
end)