Merge "res_rtp_asterisk.c: Fix rtp source address learning for broken clients"
[asterisk/asterisk.git] / tests / test_utils.c
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2010, Digium, Inc.
5  *
6  * David Vossel <dvossel@digium.com>
7  * Russell Bryant <russell@digium.com>
8  *
9  * See http://www.asterisk.org for more information about
10  * the Asterisk project. Please do not directly contact
11  * any of the maintainers of this project for assistance;
12  * the project provides a web site, mailing lists and IRC
13  * channels for your use.
14  *
15  * This program is free software, distributed under the terms of
16  * the GNU General Public License Version 2. See the LICENSE file
17  * at the top of the source tree.
18  */
19
20 /*!
21  * \file
22  * \brief Unit Tests for utils API
23  *
24  * \author David Vossel <dvossel@digium.com>
25  * \author Russell Bryant <russell@digium.com>
26  */
27
28 /*** MODULEINFO
29         <depend>TEST_FRAMEWORK</depend>
30         <use type="module">res_agi</use>
31         <use type="module">res_crypto</use>
32         <support_level>core</support_level>
33  ***/
34
35 #include "asterisk.h"
36
37 #include "asterisk/utils.h"
38 #include "asterisk/test.h"
39 #include "asterisk/crypto.h"
40 #include "asterisk/adsi.h"
41 #include "asterisk/agi.h"
42 #include "asterisk/channel.h"
43 #include "asterisk/module.h"
44
45 #include <sys/stat.h>
46
47 AST_TEST_DEFINE(uri_encode_decode_test)
48 {
49         int res = AST_TEST_PASS;
50         const char *in = "abcdefghijklmnopurstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 ~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/";
51         char out[256] = { 0 };
52         char small[4] = { 0 };
53         const struct ast_flags none = {0};
54         int i = 0;
55
56         static struct {
57                 const char *spec_str;
58                 struct ast_flags spec;
59
60                 char *buf;
61                 size_t buflen;
62
63                 const char *input;
64                 const char *output;
65                 const char *decoded_output;
66         } tests[5];
67
68 #define INIT_ENCODE_TEST(s, buffer, in, out, dec_out) do { \
69         if (i < ARRAY_LEN(tests)) { \
70                 tests[i].spec_str = #s; \
71                 tests[i].spec = s; \
72                 tests[i].buf = buffer; \
73                 tests[i].buflen = sizeof(buffer); \
74                 tests[i].input = in; \
75                 tests[i].output = out; \
76                 tests[i].decoded_output = dec_out; \
77                 i++; \
78         } else { \
79                         ast_test_status_update(test, "error: 'tests' array too small\n"); \
80                         res = AST_TEST_FAIL; \
81         } \
82         } while (0)
83
84         INIT_ENCODE_TEST(ast_uri_http, out, in,
85                 "abcdefghijklmnopurstuvwxyz%20ABCDEFGHIJKLMNOPQRSTUVWXYZ%201234567890%20~%60!%40%23%24%25%5E%26*()_-%2B%3D%7B%5B%7D%5D%7C%5C%3A%3B%22'%3C%2C%3E.%3F%2F", in);
86         INIT_ENCODE_TEST(ast_uri_http_legacy, out, in,
87                 "abcdefghijklmnopurstuvwxyz+ABCDEFGHIJKLMNOPQRSTUVWXYZ+1234567890+~%60!%40%23%24%25%5E%26*()_-%2B%3D%7B%5B%7D%5D%7C%5C%3A%3B%22'%3C%2C%3E.%3F%2F", in);
88         INIT_ENCODE_TEST(ast_uri_sip_user, out, in,
89                 "abcdefghijklmnopurstuvwxyz%20ABCDEFGHIJKLMNOPQRSTUVWXYZ%201234567890%20~%60!%40%23$%25%5E&*()_-+=%7B%5B%7D%5D%7C%5C%3A;%22'%3C,%3E.?/", in);
90         INIT_ENCODE_TEST(none, small, in, "%61", "a");
91         INIT_ENCODE_TEST(ast_uri_http, small, in, "abc", "abc");
92
93         switch (cmd) {
94         case TEST_INIT:
95                 info->name = "uri_encode_decode_test";
96                 info->category = "/main/utils/";
97                 info->summary = "encode and decode a hex escaped string";
98                 info->description = "encode a string, verify encoded string matches what we expect.  Decode the encoded string, verify decoded string matches the original string.";
99                 return AST_TEST_NOT_RUN;
100         case TEST_EXECUTE:
101                 break;
102         }
103
104         for (i = 0; i < ARRAY_LEN(tests); i++) {
105                 ast_uri_encode(tests[i].input, tests[i].buf, tests[i].buflen, tests[i].spec);
106                 if (strcmp(tests[i].output, tests[i].buf)) {
107                         ast_test_status_update(test, "encoding with %s did not match expected output, FAIL\n", tests[i].spec_str);
108                         ast_test_status_update(test, "original: %s\n", tests[i].input);
109                         ast_test_status_update(test, "expected: %s\n", tests[i].output);
110                         ast_test_status_update(test, "result: %s\n", tests[i].buf);
111                         res = AST_TEST_FAIL;
112                         continue;
113                 }
114
115                 ast_uri_decode(tests[i].buf, tests[i].spec);
116                 if (strcmp(tests[i].decoded_output, tests[i].buf)) {
117                         ast_test_status_update(test, "decoding with %s did not match the original input (or expected decoded output)\n", tests[i].spec_str);
118                         ast_test_status_update(test, "original: %s\n", tests[i].input);
119                         ast_test_status_update(test, "expected: %s\n", tests[i].decoded_output);
120                         ast_test_status_update(test, "decoded: %s\n", tests[i].buf);
121                         res = AST_TEST_FAIL;
122                 }
123         }
124
125         return res;
126 }
127
128 AST_TEST_DEFINE(quoted_escape_test)
129 {
130         int res = AST_TEST_PASS;
131         const char *in = "a\"bcdefg\"hijkl\\mnopqrs tuv\twxyz";
132         char out[256] = { 0 };
133         char small[4] = { 0 };
134         int i;
135
136         static struct {
137                 char *buf;
138                 const size_t buflen;
139
140                 const char *output;
141         } tests[] = {
142                 {0, sizeof(out),
143                         "a\\\"bcdefg\\\"hijkl\\\\mnopqrs tuv\twxyz"},
144                 {0, sizeof(small),
145                         "a\\\""},
146         };
147
148         tests[0].buf = out;
149         tests[1].buf = small;
150
151         switch (cmd) {
152         case TEST_INIT:
153                 info->name = "quoted_escape_test";
154                 info->category = "/main/utils/";
155                 info->summary = "escape a quoted string";
156                 info->description = "Escape a string to be quoted and check the result.";
157                 return AST_TEST_NOT_RUN;
158         case TEST_EXECUTE:
159                 break;
160         }
161
162         for (i = 0; i < ARRAY_LEN(tests); i++) {
163                 ast_escape_quoted(in, tests[i].buf, tests[i].buflen);
164                 if (strcmp(tests[i].output, tests[i].buf)) {
165                         ast_test_status_update(test, "ESCAPED DOES NOT MATCH EXPECTED, FAIL\n");
166                         ast_test_status_update(test, "original: %s\n", in);
167                         ast_test_status_update(test, "expected: %s\n", tests[i].output);
168                         ast_test_status_update(test, "result: %s\n", tests[i].buf);
169                         res = AST_TEST_FAIL;
170                 }
171         }
172
173         return res;
174 }
175
176 AST_TEST_DEFINE(md5_test)
177 {
178         static const struct {
179                 const char *input;
180                 const char *expected_output;
181         } tests[] = {
182                 { "apples",                          "daeccf0ad3c1fc8c8015205c332f5b42" },
183                 { "bananas",                         "ec121ff80513ae58ed478d5c5787075b" },
184                 { "reallylongstringaboutgoatcheese", "0a2d9280d37e2e37545cfef6e7e4e890" },
185         };
186         enum ast_test_result_state res = AST_TEST_PASS;
187         int i;
188
189         switch (cmd) {
190         case TEST_INIT:
191                 info->name = "md5_test";
192                 info->category = "/main/utils/";
193                 info->summary = "MD5 test";
194                 info->description =
195                         "This test exercises MD5 calculations."
196                         "";
197                 return AST_TEST_NOT_RUN;
198         case TEST_EXECUTE:
199                 break;
200         }
201
202         ast_test_status_update(test, "Testing MD5 ...\n");
203
204         for (i = 0; i < ARRAY_LEN(tests); i++) {
205                 char md5_hash[33];
206                 ast_md5_hash(md5_hash, tests[i].input);
207                 if (strcasecmp(md5_hash, tests[i].expected_output)) {
208                         ast_test_status_update(test,
209                                         "input: '%s'  hash: '%s'  expected hash: '%s'\n",
210                                         tests[i].input, md5_hash, tests[i].expected_output);
211                         res = AST_TEST_FAIL;
212                 }
213         }
214
215         return res;
216 }
217
218 AST_TEST_DEFINE(sha1_test)
219 {
220         static const struct {
221                 const char *input;
222                 const char *expected_output;
223         } tests[] = {
224                 { "giraffe",
225                         "fac8f1a31d2998734d6a5253e49876b8e6a08239" },
226                 { "platypus",
227                         "1dfb21b7a4d35e90d943e3a16107ccbfabd064d5" },
228                 { "ParastratiosphecomyiaStratiosphecomyioides",
229                         "58af4e8438676f2bd3c4d8df9e00ee7fe06945bb" },
230         };
231         enum ast_test_result_state res = AST_TEST_PASS;
232         int i;
233
234         switch (cmd) {
235         case TEST_INIT:
236                 info->name = "sha1_test";
237                 info->category = "/main/utils/";
238                 info->summary = "SHA1 test";
239                 info->description =
240                         "This test exercises SHA1 calculations."
241                         "";
242                 return AST_TEST_NOT_RUN;
243         case TEST_EXECUTE:
244                 break;
245         }
246
247         ast_test_status_update(test, "Testing SHA1 ...\n");
248
249         for (i = 0; i < ARRAY_LEN(tests); i++) {
250                 char sha1_hash[64];
251                 ast_sha1_hash(sha1_hash, tests[i].input);
252                 if (strcasecmp(sha1_hash, tests[i].expected_output)) {
253                         ast_test_status_update(test,
254                                         "input: '%s'  hash: '%s'  expected hash: '%s'\n",
255                                         tests[i].input, sha1_hash, tests[i].expected_output);
256                         res = AST_TEST_FAIL;
257                 }
258         }
259
260         return res;
261 }
262
263 AST_TEST_DEFINE(base64_test)
264 {
265         static const struct {
266                 const char *input;
267                 const char *decoded;
268         } tests[] = {
269                 { "giraffe",
270                         "Z2lyYWZmZQ==" },
271                 { "platypus",
272                         "cGxhdHlwdXM=" },
273                 { "ParastratiosphecomyiaStratiosphecomyioides",
274                         "UGFyYXN0cmF0aW9zcGhlY29teWlhU3RyYXRpb3NwaGVjb215aW9pZGVz" },
275         };
276         int i;
277         enum ast_test_result_state res = AST_TEST_PASS;
278
279         switch (cmd) {
280         case TEST_INIT:
281                 info->name = "base64_test";
282                 info->category = "/main/utils/";
283                 info->summary = "base64 test";
284                 info->description = "This test exercises the base64 conversions.";
285                 return AST_TEST_NOT_RUN;
286         case TEST_EXECUTE:
287                 break;
288         }
289
290
291         for (i = 0; i < ARRAY_LEN(tests); i++) {
292                 char tmp[64];
293                 ast_base64encode(tmp, (unsigned char *)tests[i].input, strlen(tests[i].input), sizeof(tmp));
294                 if (strcasecmp(tmp, tests[i].decoded)) {
295                         ast_test_status_update(test,
296                                         "input: '%s'  base64 output: '%s'  expected base64 output: '%s'\n",
297                                         tests[i].input, tmp, tests[i].decoded);
298                         res = AST_TEST_FAIL;
299                 }
300
301                 memset(tmp, 0, sizeof(tmp));
302                 ast_base64decode((unsigned char *) tmp, tests[i].decoded, (sizeof(tmp) - 1));
303                 if (strcasecmp(tmp, tests[i].input)) {
304                         ast_test_status_update(test,
305                                         "base64 input: '%s'  output: '%s'  expected output: '%s'\n",
306                                         tests[i].decoded, tmp, tests[i].input);
307                         res = AST_TEST_FAIL;
308                 }
309         }
310
311         return res;
312 }
313
314 AST_TEST_DEFINE(crypto_loaded_test)
315 {
316         switch (cmd) {
317         case TEST_INIT:
318                 info->name = "crypto_loaded_test";
319                 info->category = "/res/crypto/";
320                 info->summary = "Crypto loaded into memory";
321                 info->description = "Verifies whether the crypto functions overrode the stubs";
322                 return AST_TEST_NOT_RUN;
323         case TEST_EXECUTE:
324                 break;
325         }
326
327         return ast_crypto_loaded() ? AST_TEST_PASS : AST_TEST_FAIL;
328 }
329
330 AST_TEST_DEFINE(adsi_loaded_test)
331 {
332         struct ast_channel *c;
333         int res;
334         switch (cmd) {
335         case TEST_INIT:
336                 info->name = "adsi_loaded_test";
337                 info->category = "/res/adsi/";
338                 info->summary = "ADSI loaded into memory";
339                 info->description = "Verifies whether the adsi functions overrode the stubs";
340                 return AST_TEST_NOT_RUN;
341         case TEST_EXECUTE:
342                 break;
343         }
344
345         if (!(c = ast_dummy_channel_alloc())) {
346                 return AST_TEST_FAIL;
347         }
348         ast_channel_adsicpe_set(c, AST_ADSI_AVAILABLE);
349         res = ast_adsi_available(c) ? AST_TEST_PASS : AST_TEST_FAIL;
350         c = ast_channel_unref(c);
351         return res;
352 }
353
354 static int handle_noop(struct ast_channel *chan, AGI *agi, int arg, const char * const argv[])
355 {
356         ast_agi_send(agi->fd, chan, "200 result=0\n");
357         return RESULT_SUCCESS;
358 }
359
360 AST_TEST_DEFINE(agi_loaded_test)
361 {
362         int res = AST_TEST_PASS;
363         struct agi_command noop_command =
364                 { { "testnoop", NULL }, handle_noop, NULL, NULL, 0 };
365
366         switch (cmd) {
367         case TEST_INIT:
368                 info->name = "agi_loaded_test";
369                 info->category = "/res/agi/";
370                 info->summary = "AGI loaded into memory";
371                 info->description = "Verifies whether the agi functions overrode the stubs";
372                 return AST_TEST_NOT_RUN;
373         case TEST_EXECUTE:
374                 break;
375         }
376
377         if (ast_agi_register(ast_module_info->self, &noop_command) == AST_OPTIONAL_API_UNAVAILABLE) {
378                 ast_test_status_update(test, "Unable to register testnoop command, because res_agi is not loaded.\n");
379                 return AST_TEST_FAIL;
380         }
381
382 #ifndef HAVE_NULLSAFE_PRINTF
383         /* Test for condition without actually crashing Asterisk */
384         if (noop_command.usage == NULL) {
385                 ast_test_status_update(test, "AGI testnoop usage was not updated properly.\n");
386                 res = AST_TEST_FAIL;
387         }
388         if (noop_command.syntax == NULL) {
389                 ast_test_status_update(test, "AGI testnoop syntax was not updated properly.\n");
390                 res = AST_TEST_FAIL;
391         }
392 #endif
393
394         ast_agi_unregister(ast_module_info->self, &noop_command);
395         return res;
396 }
397
398 AST_TEST_DEFINE(safe_mkdir_test)
399 {
400         char base_path[] = "/tmp/safe_mkdir.XXXXXX";
401         char path[80] = {};
402         int res;
403         struct stat actual;
404
405         switch (cmd) {
406         case TEST_INIT:
407                 info->name = __func__;
408                 info->category = "/main/utils/";
409                 info->summary = "Safe mkdir test";
410                 info->description =
411                         "This test ensures that ast_safe_mkdir does what it is "
412                         "supposed to";
413                 return AST_TEST_NOT_RUN;
414         case TEST_EXECUTE:
415                 break;
416         }
417
418         if (mkdtemp(base_path) == NULL) {
419                 ast_test_status_update(test, "Failed to create tmpdir for test\n");
420                 return AST_TEST_FAIL;
421         }
422
423         snprintf(path, sizeof(path), "%s/should_work", base_path);
424         res = ast_safe_mkdir(base_path, path, 0777);
425         ast_test_validate(test, 0 == res);
426         res = stat(path, &actual);
427         ast_test_validate(test, 0 == res);
428         ast_test_validate(test, S_ISDIR(actual.st_mode));
429
430         snprintf(path, sizeof(path), "%s/should/also/work", base_path);
431         res = ast_safe_mkdir(base_path, path, 0777);
432         ast_test_validate(test, 0 == res);
433         res = stat(path, &actual);
434         ast_test_validate(test, 0 == res);
435         ast_test_validate(test, S_ISDIR(actual.st_mode));
436
437         snprintf(path, sizeof(path), "%s/even/this/../should/work", base_path);
438         res = ast_safe_mkdir(base_path, path, 0777);
439         ast_test_validate(test, 0 == res);
440         snprintf(path, sizeof(path), "%s/even/should/work", base_path);
441         res = stat(path, &actual);
442         ast_test_validate(test, 0 == res);
443         ast_test_validate(test, S_ISDIR(actual.st_mode));
444
445         snprintf(path, sizeof(path),
446                 "%s/surprisingly/this/should//////////////////work", base_path);
447         res = ast_safe_mkdir(base_path, path, 0777);
448         ast_test_validate(test, 0 == res);
449         snprintf(path, sizeof(path),
450                 "%s/surprisingly/this/should/work", base_path);
451         res = stat(path, &actual);
452         ast_test_validate(test, 0 == res);
453         ast_test_validate(test, S_ISDIR(actual.st_mode));
454
455         snprintf(path, sizeof(path), "/should_not_work");
456         res = ast_safe_mkdir(base_path, path, 0777);
457         ast_test_validate(test, 0 != res);
458         ast_test_validate(test, EPERM == errno);
459         res = stat(path, &actual);
460         ast_test_validate(test, 0 != res);
461         ast_test_validate(test, ENOENT == errno);
462
463         snprintf(path, sizeof(path), "%s/../nor_should_this", base_path);
464         res = ast_safe_mkdir(base_path, path, 0777);
465         ast_test_validate(test, 0 != res);
466         ast_test_validate(test, EPERM == errno);
467         strncpy(path, "/tmp/nor_should_this", sizeof(path));
468         res = stat(path, &actual);
469         ast_test_validate(test, 0 != res);
470         ast_test_validate(test, ENOENT == errno);
471
472         snprintf(path, sizeof(path),
473                 "%s/this/especially/should/not/../../../../../work", base_path);
474         res = ast_safe_mkdir(base_path, path, 0777);
475         ast_test_validate(test, 0 != res);
476         ast_test_validate(test, EPERM == errno);
477         strncpy(path, "/tmp/work", sizeof(path));
478         res = stat(path, &actual);
479         ast_test_validate(test, 0 != res);
480         ast_test_validate(test, ENOENT == errno);
481
482         return AST_TEST_PASS;
483 }
484
485 AST_TEST_DEFINE(crypt_test)
486 {
487         RAII_VAR(char *, password_crypted, NULL, ast_free);
488         RAII_VAR(char *, blank_crypted, NULL, ast_free);
489         const char *password = "Passw0rd";
490         const char *not_a_password = "not-a-password";
491
492         switch (cmd) {
493         case TEST_INIT:
494                 info->name = "crypt_test";
495                 info->category = "/main/utils/";
496                 info->summary = "Test ast_crypt wrappers";
497                 info->description = "Verifies that the ast_crypt wrappers work as expected.";
498                 return AST_TEST_NOT_RUN;
499         case TEST_EXECUTE:
500                 break;
501         }
502
503         password_crypted = ast_crypt_encrypt(password);
504         ast_test_validate(test, NULL != password_crypted);
505         ast_test_validate(test, 0 != strcmp(password, password_crypted));
506         ast_test_validate(test, ast_crypt_validate(password, password_crypted));
507         ast_test_validate(test,
508                 !ast_crypt_validate(not_a_password, password_crypted));
509
510         blank_crypted = ast_crypt_encrypt("");
511         ast_test_validate(test, NULL != blank_crypted);
512         ast_test_validate(test, 0 != strcmp(blank_crypted, ""));
513         ast_test_validate(test, ast_crypt_validate("", blank_crypted));
514         ast_test_validate(test,
515                 !ast_crypt_validate(not_a_password, blank_crypted));
516
517         return AST_TEST_PASS;
518 }
519
520
521 struct quote_set {
522         char *input;
523         char *output;
524 };
525
526 AST_TEST_DEFINE(quote_mutation)
527 {
528         char escaped[64];
529         static const struct quote_set escape_sets[] = {
530                 {"\"string\"", "\\\"string\\\""},
531                 {"\"string", "\\\"string"},
532                 {"string\"", "string\\\""},
533                 {"string", "string"},
534                 {"str\"ing", "str\\\"ing"},
535                 {"\"", "\\\""},
536                 {"\\\"", "\\\\\\\""},
537         };
538         int i;
539
540         switch (cmd) {
541         case TEST_INIT:
542                 info->name = "quote_mutation";
543                 info->category = "/main/utils/";
544                 info->summary = "Test mutation of quotes in strings";
545                 info->description =
546                         "This tests escaping and unescaping of quotes in strings to "
547                         "verify that the original string is recovered.";
548                 return AST_TEST_NOT_RUN;
549         case TEST_EXECUTE:
550                 break;
551         }
552
553         for (i = 0; i < ARRAY_LEN(escape_sets); i++) {
554                 ast_escape_quoted(escape_sets[i].input, escaped, sizeof(escaped));
555
556                 if (strcmp(escaped, escape_sets[i].output)) {
557                         ast_test_status_update(test,
558                                 "Expected escaped string '%s' instead of '%s'\n",
559                                 escape_sets[i].output, escaped);
560                         return AST_TEST_FAIL;
561                 }
562
563                 ast_unescape_quoted(escaped);
564                 if (strcmp(escaped, escape_sets[i].input)) {
565                         ast_test_status_update(test,
566                                 "Expected unescaped string '%s' instead of '%s'\n",
567                                 escape_sets[i].input, escaped);
568                         return AST_TEST_FAIL;
569                 }
570         }
571
572         return AST_TEST_PASS;
573 }
574
575 AST_TEST_DEFINE(quote_unescaping)
576 {
577         static const struct quote_set escape_sets[] = {
578                 {"\"string\"", "\"string\""},
579                 {"\\\"string\"", "\"string\""},
580                 {"\"string\\\"", "\"string\""},
581                 {"str\\ing", "string"},
582                 {"string\\", "string"},
583                 {"\\string", "string"},
584         };
585         int i;
586
587         switch (cmd) {
588         case TEST_INIT:
589                 info->name = "quote_unescaping";
590                 info->category = "/main/utils/";
591                 info->summary = "Test unescaping of off-nominal strings";
592                 info->description =
593                         "This tests unescaping of strings which contain a mix of "
594                         "escaped and unescaped sequences.";
595                 return AST_TEST_NOT_RUN;
596         case TEST_EXECUTE:
597                 break;
598         }
599
600         for (i = 0; i < ARRAY_LEN(escape_sets); i++) {
601                 RAII_VAR(char *, escaped, ast_strdup(escape_sets[i].input), ast_free);
602
603                 ast_unescape_quoted(escaped);
604                 if (strcmp(escaped, escape_sets[i].output)) {
605                         ast_test_status_update(test,
606                                 "Expected unescaped string '%s' instead of '%s'\n",
607                                 escape_sets[i].output, escaped);
608                         return AST_TEST_FAIL;
609                 }
610         }
611
612         return AST_TEST_PASS;
613 }
614
615 static int unload_module(void)
616 {
617         AST_TEST_UNREGISTER(uri_encode_decode_test);
618         AST_TEST_UNREGISTER(quoted_escape_test);
619         AST_TEST_UNREGISTER(md5_test);
620         AST_TEST_UNREGISTER(sha1_test);
621         AST_TEST_UNREGISTER(base64_test);
622         AST_TEST_UNREGISTER(crypto_loaded_test);
623         AST_TEST_UNREGISTER(adsi_loaded_test);
624         AST_TEST_UNREGISTER(agi_loaded_test);
625         AST_TEST_UNREGISTER(safe_mkdir_test);
626         AST_TEST_UNREGISTER(crypt_test);
627         AST_TEST_UNREGISTER(quote_mutation);
628         AST_TEST_UNREGISTER(quote_unescaping);
629         return 0;
630 }
631
632 static int load_module(void)
633 {
634         AST_TEST_REGISTER(uri_encode_decode_test);
635         AST_TEST_REGISTER(quoted_escape_test);
636         AST_TEST_REGISTER(md5_test);
637         AST_TEST_REGISTER(sha1_test);
638         AST_TEST_REGISTER(base64_test);
639         AST_TEST_REGISTER(crypto_loaded_test);
640         AST_TEST_REGISTER(adsi_loaded_test);
641         AST_TEST_REGISTER(agi_loaded_test);
642         AST_TEST_REGISTER(safe_mkdir_test);
643         AST_TEST_REGISTER(crypt_test);
644         AST_TEST_REGISTER(quote_mutation);
645         AST_TEST_REGISTER(quote_unescaping);
646         return AST_MODULE_LOAD_SUCCESS;
647 }
648
649 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Utils test module");