Annotate

spec/util_jsonpointer_spec.lua @ 12960:31b22cc221b5

mod_pubsub, mod_pep: Support per-node configurable inclusion of publisher This matches ejabberd's behaviour, using the 'pubsub#itemreply' config option. Although the current definition of this option in the specification is not as clear as it could be, I think matching what existing deployments do is the best option to resolve the ambiguity and reduce fragmentation. We should update the spec to be clearer about how to use and interpret this option. The 'expose_publisher' option for mod_pubsub is now an override (always expose or never expose). If unset, it will use the per-node config (which defaults to not exposing). Thanks to Link Mauve, edhelas and goffi for sparking this feature.
author Matthew Wild <mwild1@gmail.com>
date Wed, 22 Mar 2023 11:39:19 +0000
parent 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()
12777
4d5549de27e6 util.jsonpointer: Improve tests
Kim Alvefur <zash@zash.se>
parents: 12495
diff changeset
24 assert.is_nil(jp.resolve("string", "/string"))
12495
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
25 assert.same(example, jp.resolve(example, ""));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
26 assert.same({ "bar", "baz" }, jp.resolve(example, "/foo"));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
27 assert.same("bar", jp.resolve(example, "/foo/0"));
12777
4d5549de27e6 util.jsonpointer: Improve tests
Kim Alvefur <zash@zash.se>
parents: 12495
diff changeset
28 assert.same(nil, jp.resolve(example, "/foo/-"));
12495
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
29 assert.same(0, jp.resolve(example, "/"));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
30 assert.same(1, jp.resolve(example, "/a~1b"));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
31 assert.same(2, jp.resolve(example, "/c%d"));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
32 assert.same(3, jp.resolve(example, "/e^f"));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
33 assert.same(4, jp.resolve(example, "/g|h"));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
34 assert.same(5, jp.resolve(example, "/i\\j"));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
35 assert.same(6, jp.resolve(example, "/k\"l"));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
36 assert.same(7, jp.resolve(example, "/ "));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
37 assert.same(8, jp.resolve(example, "/m~0n"));
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
38 end)
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
39 end)
5bf9056dca2c util.jsonpointer: Add basic tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
40 end)