Annotate

spec/util_paths_spec.lua @ 12187:94253e02d47d

mod_http: Limit unencrypted http port (5280) to loopback by default Since accessing this port directly over the wider Internet is unlikely to intentional anymore. Most uses will likely be by reverse proxies, by mistake or because of trouble configuring HTTPS. Blocking mistaken uses is just a good thing, letting users send potentially private things unencrypted tends to be Strongly Discouraged these days. Many reverse proxy setups operate over loopback, so listening there instead of all interfaces is a net improvement. Improved automatic certificate location and SNI support has mostly eliminated the need for manual certificate configuration so HTTPS should Just Work once certificates have been provided. For local testing during development, connecting over loopback is likely fine as well. When really needed, `http_interfaces` can still be set. Suggested by Link Mauve
author Kim Alvefur <zash@zash.se>
date Sat, 15 Jan 2022 15:13:41 +0100
parent 11182:bab8d01e139a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11181
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 local sep = package.config:match("(.)\n");
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2 describe("util.paths", function ()
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 local paths = require "util.paths";
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4 describe("#join()", function ()
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 it("returns single component as-is", function ()
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6 assert.equal("foo", paths.join("foo"));
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 end);
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8 it("joins paths", function ()
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9 assert.equal("foo"..sep.."bar", paths.join("foo", "bar"))
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
10 end);
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
11 it("joins longer paths", function ()
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
12 assert.equal("foo"..sep.."bar"..sep.."baz", paths.join("foo", "bar", "baz"))
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13 end);
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14 it("joins even longer paths", function ()
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15 assert.equal("foo"..sep.."bar"..sep.."baz"..sep.."moo", paths.join("foo", "bar", "baz", "moo"))
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
16 end);
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
17 end)
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
18
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
19 describe("#glob_to_pattern()", function ()
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
20 it("works", function ()
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
21 assert.equal("^thing.%..*$", paths.glob_to_pattern("thing?.*"))
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
22 end);
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
23 end)
11182
bab8d01e139a util_paths_spec: Trim trailing white space
Kim Alvefur <zash@zash.se>
parents: 11181
diff changeset
24
11181
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
25 describe("#resolve_relative_path()", function ()
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
26 it("returns absolute paths as-is", function ()
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
27 if sep == "/" then
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
28 assert.equal("/tmp/path", paths.resolve_relative_path("/run", "/tmp/path"));
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
29 elseif sep == "\\" then
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
30 assert.equal("C:\\Program Files", paths.resolve_relative_path("A:\\", "C:\\Program Files"));
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
31 end
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
32 end);
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
33 it("resolves relative paths", function ()
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
34 if sep == "/" then
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
35 assert.equal("/run/path", paths.resolve_relative_path("/run", "path"));
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
36 end
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
37 end);
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
38 end)
d2b19560150d util.paths: Add some tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
39 end)