Annotate

tests/test_core_configmanager.lua @ 8791:8da11142fabf

muc: Allow clients to change multiple affiliations or roles at once (#345) According to XEP-0045 sections 9.2, 9.5 and 9.8 affiliation lists and role lists should allow mass-modification. Prosody however would just use the first entry of the list and ignore the rest. This is fixed by introducing a `for` loop to `set` stanzas of the respective `muc#admin` namespace. In order for this loop to work, the error handling was changed a little. Prosody no longer returns after the first error. Instead, an error reply is sent for each malformed or otherwise wrong entry, but the loop keeps going over the other entries. This may lead to multiple error messages being sent for one client request. A notable exception from this is when the XML Schema for `muc#admin` requests is violated. In that case the loop is aborted with an error message to the client. The change is a bit bigger than that in order to have the loop only for `set` stanzas without changing the behaviour of the `get` stanzas. This is now more in line with trunk, where there are separate methods for each stanza type. References: #345
author Lennart Sauerbeck <devel@lennart.sauerbeck.org>
date Sat, 18 Mar 2017 18:47:28 +0100
parent 5776:bd0ff8ae98a8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1523
841d61be198f Remove version number from copyright headers
Matthew Wild <mwild1@gmail.com>
parents: 896
diff changeset
1 -- Prosody IM
2923
b7049746bd29 Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents: 1523
diff changeset
2 -- Copyright (C) 2008-2010 Matthew Wild
b7049746bd29 Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents: 1523
diff changeset
3 -- Copyright (C) 2008-2010 Waqas Hussain
5776
bd0ff8ae98a8 Remove all trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 5605
diff changeset
4 --
758
b1885732e979 GPL->MIT!
Matthew Wild <mwild1@gmail.com>
parents: 615
diff changeset
5 -- This project is MIT/X11 licensed. Please see the
b1885732e979 GPL->MIT!
Matthew Wild <mwild1@gmail.com>
parents: 615
diff changeset
6 -- COPYING file in the source package for more information.
519
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 371
diff changeset
7 --
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 371
diff changeset
8
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 371
diff changeset
9
371
0dc5819660e8 Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10
0dc5819660e8 Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 function get(get, config)
5605
468d7a2f85ba tests/test_core_configmanager.lua: Update to remove tests based on sections (now removed)
Matthew Wild <mwild1@gmail.com>
parents: 3540
diff changeset
12 config.set("example.com", "testkey", 123);
468d7a2f85ba tests/test_core_configmanager.lua: Update to remove tests based on sections (now removed)
Matthew Wild <mwild1@gmail.com>
parents: 3540
diff changeset
13 assert_equal(get("example.com", "testkey"), 123, "Retrieving a set key");
371
0dc5819660e8 Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14
5605
468d7a2f85ba tests/test_core_configmanager.lua: Update to remove tests based on sections (now removed)
Matthew Wild <mwild1@gmail.com>
parents: 3540
diff changeset
15 config.set("*", "testkey1", 321);
468d7a2f85ba tests/test_core_configmanager.lua: Update to remove tests based on sections (now removed)
Matthew Wild <mwild1@gmail.com>
parents: 3540
diff changeset
16 assert_equal(get("*", "testkey1"), 321, "Retrieving a set global key");
468d7a2f85ba tests/test_core_configmanager.lua: Update to remove tests based on sections (now removed)
Matthew Wild <mwild1@gmail.com>
parents: 3540
diff changeset
17 assert_equal(get("example.com", "testkey1"), 321, "Retrieving a set key of undefined host, of which only a globally set one exists");
5776
bd0ff8ae98a8 Remove all trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 5605
diff changeset
18
5605
468d7a2f85ba tests/test_core_configmanager.lua: Update to remove tests based on sections (now removed)
Matthew Wild <mwild1@gmail.com>
parents: 3540
diff changeset
19 config.set("example.com", ""); -- Creates example.com host in config
468d7a2f85ba tests/test_core_configmanager.lua: Update to remove tests based on sections (now removed)
Matthew Wild <mwild1@gmail.com>
parents: 3540
diff changeset
20 assert_equal(get("example.com", "testkey1"), 321, "Retrieving a set key, of which only a globally set one exists");
5776
bd0ff8ae98a8 Remove all trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 5605
diff changeset
21
371
0dc5819660e8 Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 assert_equal(get(), nil, "No parameters to get()");
0dc5819660e8 Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 assert_equal(get("undefined host"), nil, "Getting for undefined host");
5605
468d7a2f85ba tests/test_core_configmanager.lua: Update to remove tests based on sections (now removed)
Matthew Wild <mwild1@gmail.com>
parents: 3540
diff changeset
24 assert_equal(get("undefined host", "undefined key"), nil, "Getting for undefined host & key");
371
0dc5819660e8 Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 end
0dc5819660e8 Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26
0dc5819660e8 Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 function set(set, u)
5605
468d7a2f85ba tests/test_core_configmanager.lua: Update to remove tests based on sections (now removed)
Matthew Wild <mwild1@gmail.com>
parents: 3540
diff changeset
28 assert_equal(set("*"), false, "Set with no key");
371
0dc5819660e8 Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29
0dc5819660e8 Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
30 assert_equal(set("*", "set_test", "testkey"), true, "Setting a nil global value");
0dc5819660e8 Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 assert_equal(set("*", "set_test", "testkey", 123), true, "Setting a global value");
0dc5819660e8 Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32 end
0dc5819660e8 Import initial configmanager, not sure if it works yet, but it does pass the unit tests ;)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33