diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:44:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:44:51 +0000 |
commit | 9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /comm/chat/protocols/xmpp/test/test_saslPrep.js | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'comm/chat/protocols/xmpp/test/test_saslPrep.js')
-rw-r--r-- | comm/chat/protocols/xmpp/test/test_saslPrep.js | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/comm/chat/protocols/xmpp/test/test_saslPrep.js b/comm/chat/protocols/xmpp/test/test_saslPrep.js new file mode 100644 index 0000000000..b2d0a1f147 --- /dev/null +++ b/comm/chat/protocols/xmpp/test/test_saslPrep.js @@ -0,0 +1,66 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +var { saslPrep } = ChromeUtils.importESModule( + "resource:///modules/xmpp-authmechs.sys.mjs" +); + +// RFC 4013 3.Examples +var TEST_DATA = [ + { + // SOFT HYPHEN mapped to nothing. + input: "I\u00adX", + output: "IX", + isError: false, + }, + { + // No transformation. + input: "user", + output: "user", + isError: false, + }, + { + // Case preserved, will not match #2. + input: "USER", + output: "USER", + isError: false, + }, + { + // Output is NFKC, input in ISO 8859-1. + input: "\u00aa", + output: "a", + isError: false, + }, + { + // Output is NFKC, will match #1. + input: "\u2168", + output: "IX", + isError: false, + }, + { + // Error - prohibited character. + input: "\u0007", + output: "", + isError: true, + }, + { + // Error - bidirectional check. + input: "\u0627\u0031", + output: "", + isError: true, + }, +]; + +function run_test() { + for (let current of TEST_DATA) { + try { + let result = saslPrep(current.input); + equal(current.isError, false); + equal(result, current.output); + } catch (e) { + equal(current.isError, true); + } + } + + run_next_test(); +} |