Software / code / prosody
Annotate
spec/util_paths_spec.lua @ 13765:7c57fb2ffbb0 13.0
mod_websocket: Merge session close handling changes from mod_c2s (bug fixes)
This should bring some fixes and general robustness that mod_websocket had
missed out on. The duplicated code here is not at all ideal. To prevent this
happening again, we should figure out how to have the common logic in a single
place, while still being able to do the websocket-specific parts that we need.
The main known bug that this fixes is that it's possible for a session to get
into a non-destroyable state. For example, if we try to session:close() a
hibernating session, then session.conn is nil and the function will simply
return without doing anything. In the mod_c2s code we already handle this, and
just destroy the session. But if a hibernating websocket session is never
resumed or becomes non-resumable, it will become immortal!
By merging the fix from mod_c2s, the session should now be correctly
destroyed.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 11 Mar 2025 18:44:40 +0000 |
| parent | 11182:bab8d01e139a |
| rev | line source |
|---|---|
| 11181 | 1 local sep = package.config:match("(.)\n"); |
| 2 describe("util.paths", function () | |
| 3 local paths = require "util.paths"; | |
| 4 describe("#join()", function () | |
| 5 it("returns single component as-is", function () | |
| 6 assert.equal("foo", paths.join("foo")); | |
| 7 end); | |
| 8 it("joins paths", function () | |
| 9 assert.equal("foo"..sep.."bar", paths.join("foo", "bar")) | |
| 10 end); | |
| 11 it("joins longer paths", function () | |
| 12 assert.equal("foo"..sep.."bar"..sep.."baz", paths.join("foo", "bar", "baz")) | |
| 13 end); | |
| 14 it("joins even longer paths", function () | |
| 15 assert.equal("foo"..sep.."bar"..sep.."baz"..sep.."moo", paths.join("foo", "bar", "baz", "moo")) | |
| 16 end); | |
| 17 end) | |
| 18 | |
| 19 describe("#glob_to_pattern()", function () | |
| 20 it("works", function () | |
| 21 assert.equal("^thing.%..*$", paths.glob_to_pattern("thing?.*")) | |
| 22 end); | |
| 23 end) | |
|
11182
bab8d01e139a
util_paths_spec: Trim trailing white space
Kim Alvefur <zash@zash.se>
parents:
11181
diff
changeset
|
24 |
| 11181 | 25 describe("#resolve_relative_path()", function () |
| 26 it("returns absolute paths as-is", function () | |
| 27 if sep == "/" then | |
| 28 assert.equal("/tmp/path", paths.resolve_relative_path("/run", "/tmp/path")); | |
| 29 elseif sep == "\\" then | |
| 30 assert.equal("C:\\Program Files", paths.resolve_relative_path("A:\\", "C:\\Program Files")); | |
| 31 end | |
| 32 end); | |
| 33 it("resolves relative paths", function () | |
| 34 if sep == "/" then | |
| 35 assert.equal("/run/path", paths.resolve_relative_path("/run", "path")); | |
| 36 end | |
| 37 end); | |
| 38 end) | |
| 39 end) |