Annotate

spec/util_jsonpointer_spec.lua @ 12525:8087f5357f53 0.12

mod_smacks: Fix bounce of stanzas directed to full JID on unclean disconnect Fixes #1758 Introduced in 1ea01660c79a In e62025f949f9 to and from was inverted since it changed from acting on a reply to acting on the original stanza (or a clone thereof) Unsure of the purpose of this check, you don't usually send stanzas to your own full JID. Perhaps guarding against routing loops? The check was present in the original commit of mod_smacks, prosody-modules rev 9a7671720dec
author Kim Alvefur <zash@zash.se>
date Fri, 27 May 2022 12:05:47 +0200
parent 12495:5bf9056dca2c
child 12777:4d5549de27e6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12495
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 describe("util.jsonpointer", function()
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2 local json, jp;
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 setup(function()
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4 json = require "util.json";
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 jp = require "util.jsonpointer";
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6 end)
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 describe("resolve()", function()
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8 local example;
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9 setup(function()
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
10 example = json.decode([[{
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
11 "foo": ["bar", "baz"],
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
12 "": 0,
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13 "a/b": 1,
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14 "c%d": 2,
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15 "e^f": 3,
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
16 "g|h": 4,
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
17 "i\\j": 5,
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
18 "k\"l": 6,
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
19 " ": 7,
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
20 "m~n": 8
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
21 }]])
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
22 end)
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
23 it("works", function()
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
24 assert.same(example, jp.resolve(example, ""));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
25 assert.same({ "bar", "baz" }, jp.resolve(example, "/foo"));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
26 assert.same("bar", jp.resolve(example, "/foo/0"));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
27 assert.same(0, jp.resolve(example, "/"));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
28 assert.same(1, jp.resolve(example, "/a~1b"));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
29 assert.same(2, jp.resolve(example, "/c%d"));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
30 assert.same(3, jp.resolve(example, "/e^f"));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
31 assert.same(4, jp.resolve(example, "/g|h"));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
32 assert.same(5, jp.resolve(example, "/i\\j"));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
33 assert.same(6, jp.resolve(example, "/k\"l"));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
34 assert.same(7, jp.resolve(example, "/ "));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
35 assert.same(8, jp.resolve(example, "/m~0n"));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
36 end)
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
37 end)
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
38 end)