summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2020-04-20 07:16:08 +0200
committerSébastien Helleu <flashcode@flashtux.org>2020-04-20 07:16:08 +0200
commit60b75f4677dc9b89fb3e3153d681e66d842c8998 (patch)
tree1ce32667b0fcc52400988bb5c845c8e38532726c /tests/unit
parent8ac9336d2a0db1ec77720bdc5a612c1d1b9a2717 (diff)
downloadweechat-60b75f4677dc9b89fb3e3153d681e66d842c8998.zip
tests: add tests on functions relay_auth_password_hash_algo_search and relay_auth_generate_nonce
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/plugins/relay/test-relay-auth.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/unit/plugins/relay/test-relay-auth.cpp b/tests/unit/plugins/relay/test-relay-auth.cpp
index 15dc07e3b..8c51bfe46 100644
--- a/tests/unit/plugins/relay/test-relay-auth.cpp
+++ b/tests/unit/plugins/relay/test-relay-auth.cpp
@@ -24,6 +24,8 @@
extern "C"
{
#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
#include "src/plugins/relay/relay-auth.h"
}
@@ -57,6 +59,47 @@ TEST_GROUP(RelayAuth)
/*
* Tests functions:
+ * relay_auth_password_hash_algo_search
+ */
+
+TEST(RelayAuth, PasswordHashAlgoSearch)
+{
+ LONGS_EQUAL(-1, relay_auth_password_hash_algo_search (NULL));
+ LONGS_EQUAL(-1, relay_auth_password_hash_algo_search (""));
+ LONGS_EQUAL(-1, relay_auth_password_hash_algo_search ("zzz"));
+
+ LONGS_EQUAL(0, relay_auth_password_hash_algo_search ("plain"));
+}
+
+/*
+ * Tests functions:
+ * relay_auth_generate_nonce
+ */
+
+TEST(RelayAuth, GenerateNonce)
+{
+ char *nonce;
+
+ POINTERS_EQUAL(NULL, relay_auth_generate_nonce (-1));
+ POINTERS_EQUAL(NULL, relay_auth_generate_nonce (0));
+
+ nonce = relay_auth_generate_nonce (1);
+ LONGS_EQUAL(2, strlen (nonce));
+ CHECK(isxdigit ((int)nonce[0]));
+ CHECK(isxdigit ((int)nonce[1]));
+ free (nonce);
+
+ nonce = relay_auth_generate_nonce (2);
+ LONGS_EQUAL(4, strlen (nonce));
+ CHECK(isxdigit ((int)nonce[0]));
+ CHECK(isxdigit ((int)nonce[1]));
+ CHECK(isxdigit ((int)nonce[2]));
+ CHECK(isxdigit ((int)nonce[3]));
+ free (nonce);
+}
+
+/*
+ * Tests functions:
* relay_auth_parse_sha
*/