Annotate

spec/core_configmanager_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
parent 10495:8ea685ec0979
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8236
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
1
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
2 local configmanager = require "core.configmanager";
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
3
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
4 describe("core.configmanager", function()
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
5 describe("#get()", function()
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
6 it("should work", function()
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
7 configmanager.set("example.com", "testkey", 123);
9168
29de7ad20250 spec: Correct order of arguments to asserts in configmanager tests
Kim Alvefur <zash@zash.se>
parents: 8236
diff changeset
8 assert.are.equal(123, configmanager.get("example.com", "testkey"), "Retrieving a set key");
8236
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
9
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
10 configmanager.set("*", "testkey1", 321);
9168
29de7ad20250 spec: Correct order of arguments to asserts in configmanager tests
Kim Alvefur <zash@zash.se>
parents: 8236
diff changeset
11 assert.are.equal(321, configmanager.get("*", "testkey1"), "Retrieving a set global key");
10495
8ea685ec0979 configmanager tests: Split long line
Matthew Wild <mwild1@gmail.com>
parents: 9168
diff changeset
12 assert.are.equal(321, configmanager.get("example.com", "testkey1"),
8ea685ec0979 configmanager tests: Split long line
Matthew Wild <mwild1@gmail.com>
parents: 9168
diff changeset
13 "Retrieving a set key of undefined host, of which only a globally set one exists"
8ea685ec0979 configmanager tests: Split long line
Matthew Wild <mwild1@gmail.com>
parents: 9168
diff changeset
14 );
8236
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
15
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
16 configmanager.set("example.com", ""); -- Creates example.com host in config
9168
29de7ad20250 spec: Correct order of arguments to asserts in configmanager tests
Kim Alvefur <zash@zash.se>
parents: 8236
diff changeset
17 assert.are.equal(321, configmanager.get("example.com", "testkey1"), "Retrieving a set key, of which only a globally set one exists");
8236
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
18
9168
29de7ad20250 spec: Correct order of arguments to asserts in configmanager tests
Kim Alvefur <zash@zash.se>
parents: 8236
diff changeset
19 assert.are.equal(nil, configmanager.get(), "No parameters to get()");
29de7ad20250 spec: Correct order of arguments to asserts in configmanager tests
Kim Alvefur <zash@zash.se>
parents: 8236
diff changeset
20 assert.are.equal(nil, configmanager.get("undefined host"), "Getting for undefined host");
29de7ad20250 spec: Correct order of arguments to asserts in configmanager tests
Kim Alvefur <zash@zash.se>
parents: 8236
diff changeset
21 assert.are.equal(nil, configmanager.get("undefined host", "undefined key"), "Getting for undefined host & key");
8236
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
22 end);
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
23 end);
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
24
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
25 describe("#set()", function()
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
26 it("should work", function()
9168
29de7ad20250 spec: Correct order of arguments to asserts in configmanager tests
Kim Alvefur <zash@zash.se>
parents: 8236
diff changeset
27 assert.are.equal(false, configmanager.set("*"), "Set with no key");
8236
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
28
9168
29de7ad20250 spec: Correct order of arguments to asserts in configmanager tests
Kim Alvefur <zash@zash.se>
parents: 8236
diff changeset
29 assert.are.equal(true, configmanager.set("*", "set_test", "testkey"), "Setting a nil global value");
29de7ad20250 spec: Correct order of arguments to asserts in configmanager tests
Kim Alvefur <zash@zash.se>
parents: 8236
diff changeset
30 assert.are.equal(true, configmanager.set("*", "set_test", "testkey", 123), "Setting a global value");
8236
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
31 end);
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
32 end);
4878e4159e12 Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
33 end);