Annotate

tests/test_util_sasl_scram.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 5537:15464633d8fb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3406
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
1
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
2
5537
15464633d8fb util.hmac, util.hashes: Implement HMAC functions in C, and move to util.hashes
Florian Zeitz <florob@babelmonkeys.de>
parents: 3406
diff changeset
3 local hmac_sha1 = require "util.hashes".hmac_sha1;
3406
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
4 local function toHex(s)
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
5 return s and (s:gsub(".", function (c) return ("%02x"):format(c:byte()); end));
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
6 end
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
7
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
8 function Hi(Hi)
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
9 assert( toHex(Hi(hmac_sha1, "password", "salt", 1)) == "0c60c80f961f0e71f3a9b524af6012062fe037a6",
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
10 [[FAIL: toHex(Hi(hmac_sha1, "password", "salt", 1)) == "0c60c80f961f0e71f3a9b524af6012062fe037a6"]])
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
11 assert( toHex(Hi(hmac_sha1, "password", "salt", 2)) == "ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957",
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
12 [[FAIL: toHex(Hi(hmac_sha1, "password", "salt", 2)) == "ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957"]])
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
13 assert( toHex(Hi(hmac_sha1, "password", "salt", 64)) == "a7bc9b6efea2cbd717da72d83bfcc4e17d0b6280",
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
14 [[FAIL: toHex(Hi(hmac_sha1, "password", "salt", 64)) == "a7bc9b6efea2cbd717da72d83bfcc4e17d0b6280"]])
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
15 assert( toHex(Hi(hmac_sha1, "password", "salt", 4096)) == "4b007901b765489abead49d926f721d065a429c1",
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
16 [[FAIL: toHex(Hi(hmac_sha1, "password", "salt", 4096)) == "4b007901b765489abead49d926f721d065a429c1"]])
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
17 -- assert( toHex(Hi(hmac_sha1, "password", "salt", 16777216)) == "eefe3d61cd4da4e4e9945b3d6ba2158c2634e984",
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
18 -- [[FAIL: toHex(Hi(hmac_sha1, "password", "salt", 16777216)) == "eefe3d61cd4da4e4e9945b3d6ba2158c2634e984"]])
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
19 end
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
20
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
21 function init(init)
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
22 -- no tests
748246005893 tests: Added tests for util.sasl.scram.Hi().
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
23 end