Mercurial > prosody-hg
annotate spec/util_jsonpointer_spec.lua @ 12659:c0eea4f6c739
usermanager: Add back temporary is_admin to warn about deprecated API usage
Goal: Introduce role-auth with minimal disruption
is_admin() is unsafe in a system with per-session permissions, so it has been
deprecated.
Roll-out approach:
1) First, log a warning when is_admin() is used. It should continue to
function normally, backed by the new role API. Nothing is really using
per-session authz yet, so there is minimal security concern.
The 'strict_deprecate_is_admin' global setting can be set to 'true' to
force a hard failure of is_admin() attempts (it will log an error and
always return false).
2) In some time (at least 1 week), but possibly longer depending on the number
of affected deployments: switch 'strict_deprecate_is_admin' to 'true' by
default. It can still be disabled for systems that need it.
3) Further in the future, before the next release, the option will be removed
and is_admin() will be permanently disabled.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 15 Aug 2022 15:25:07 +0100 |
| parents | 5bf9056dca2c |
| children | 4d5549de27e6 |
| rev | line source |
|---|---|
| 12495 | 1 describe("util.jsonpointer", function() |
| 2 local json, jp; | |
| 3 setup(function() | |
| 4 json = require "util.json"; | |
| 5 jp = require "util.jsonpointer"; | |
| 6 end) | |
| 7 describe("resolve()", function() | |
| 8 local example; | |
| 9 setup(function() | |
| 10 example = json.decode([[{ | |
| 11 "foo": ["bar", "baz"], | |
| 12 "": 0, | |
| 13 "a/b": 1, | |
| 14 "c%d": 2, | |
| 15 "e^f": 3, | |
| 16 "g|h": 4, | |
| 17 "i\\j": 5, | |
| 18 "k\"l": 6, | |
| 19 " ": 7, | |
| 20 "m~n": 8 | |
| 21 }]]) | |
| 22 end) | |
| 23 it("works", function() | |
| 24 assert.same(example, jp.resolve(example, "")); | |
| 25 assert.same({ "bar", "baz" }, jp.resolve(example, "/foo")); | |
| 26 assert.same("bar", jp.resolve(example, "/foo/0")); | |
| 27 assert.same(0, jp.resolve(example, "/")); | |
| 28 assert.same(1, jp.resolve(example, "/a~1b")); | |
| 29 assert.same(2, jp.resolve(example, "/c%d")); | |
| 30 assert.same(3, jp.resolve(example, "/e^f")); | |
| 31 assert.same(4, jp.resolve(example, "/g|h")); | |
| 32 assert.same(5, jp.resolve(example, "/i\\j")); | |
| 33 assert.same(6, jp.resolve(example, "/k\"l")); | |
| 34 assert.same(7, jp.resolve(example, "/ ")); | |
| 35 assert.same(8, jp.resolve(example, "/m~0n")); | |
| 36 end) | |
| 37 end) | |
| 38 end) |
