]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dict-extra: test-dict-fs - Parametrize username testing
authorKarl Fleischmann <karl.fleischmann@open-xchange.com>
Wed, 18 Mar 2026 14:08:09 +0000 (15:08 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 20 Mar 2026 08:23:10 +0000 (08:23 +0000)
This will allow testing path traversal behavior in a follow-up commit.

src/lib-dict-extra/test-dict-fs.c

index 4b4ded9d91b3be64c2b316da18492d0e4d18ba73..fb79a40eb225cf525554c3e42fd4e3676c3f7e3d 100644 (file)
@@ -7,12 +7,12 @@
 #include "fs-api.h"
 #include "dict-private.h"
 
-static void test_dict_set_get(struct dict *dict, const char *key,
-                            const char *value)
+static void test_dict_set_get(struct dict *dict, const char *username,
+                             const char *key, const char *value)
 {
        const char *got_value, *error;
        struct dict_op_settings set = {
-               .username = "testuser",
+               .username = username,
        };
        struct dict_transaction_context *t = dict_transaction_begin(dict, &set);
        dict_set(t, key, value);
@@ -75,24 +75,24 @@ static void test_dict_fs_set_get(void)
                { "shared/...key/key", ".test-dict/...key/key" },
        };
        for (size_t i = 0; i < N_ELEMENTS(test_cases); i++) {
-               test_dict_set_get(dict, test_cases[i].key, "1");
+               test_dict_set_get(dict, "testuser", test_cases[i].key, "1");
                test_assert(test_file_exists(test_cases[i].path));
        }
 
        /* per user paths */
-       test_dict_set_get(dict, "priv/value", "priv1");
+       test_dict_set_get(dict, "testuser", "priv/value", "priv1");
        test_assert(test_file_exists(".test-dict/testuser/value"));
-       test_dict_set_get(dict, "priv/path/with/value", "priv2");
+       test_dict_set_get(dict, "testuser", "priv/path/with/value", "priv2");
        test_assert(test_file_exists(".test-dict/testuser/path/with/value"));
 
        /* check that dots work correctly */
-       test_dict_set_get(dict, "shared/../test-dict-fs.c", "3");
+       test_dict_set_get(dict, "testuser", "shared/../test-dict-fs.c", "3");
        test_assert(test_file_exists(".test-dict/..../test-dict-fs.c"));
-       test_dict_set_get(dict, "shared/./test", "4");
+       test_dict_set_get(dict, "testuser", "shared/./test", "4");
        test_assert(test_file_exists(".test-dict/.../test"));
-       test_dict_set_get(dict, "shared/.test", "5");
+       test_dict_set_get(dict, "testuser", "shared/.test", "5");
        test_assert(test_file_exists(".test-dict/.test"));
-       test_dict_set_get(dict, "shared/..test", "6");
+       test_dict_set_get(dict, "testuser", "shared/..test", "6");
        test_assert(test_file_exists(".test-dict/..test"));
        dict_deinit(&dict);