1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose sysdb_utils - Tests for various sysdb calls
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose Sumit Bose <sbose@redhat.com>
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose Copyright (C) 2015 Red Hat
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose This program is free software; you can redistribute it and/or modify
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose it under the terms of the GNU General Public License as published by
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose the Free Software Foundation; either version 3 of the License, or
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose (at your option) any later version.
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose This program is distributed in the hope that it will be useful,
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose but WITHOUT ANY WARRANTY; without even the implied warranty of
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose GNU General Public License for more details.
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose You should have received a copy of the GNU General Public License
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose along with this program. If not, see <http://www.gnu.org/licenses/>.
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose#define IPA_UUID "bcae7c40-97eb-11e4-88ca-525400e96a6b"
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose#define AD_GUID_BIN {0x8d, 0x0d, 0xa8, 0xfe, 0xd5, 0xdb, 0x84, 0x4f, \
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose#define AD_GUID "fea80d8d-dbd5-4f84-8574-7db0477f962e"
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bosestatic void test_sysdb_handle_original_uuid(void **state)
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose ret = sysdb_handle_original_uuid(NULL, NULL, NULL, NULL, NULL);
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose ret = sysdb_handle_original_uuid("xyz", src_attrs, "abc", dest_attrs,
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose ret = sysdb_attrs_add_val(src_attrs, "GUID", &guid_val);
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose ret = sysdb_attrs_add_string(src_attrs, "UUID", IPA_UUID);
e7e61c777e13e0bb07d29b5d1b53e21ca199bf0fJakub Hrozek ret = sysdb_handle_original_uuid(NULL, src_attrs, "GUID",
e7e61c777e13e0bb07d29b5d1b53e21ca199bf0fJakub Hrozek ret = sysdb_handle_original_uuid("objectGUID", NULL, "GUID",
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose ret = sysdb_handle_original_uuid("objectGUID", src_attrs, "GUID",
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose ret = sysdb_attrs_get_string(dest_attrs, "def", &guid);
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose ret = sysdb_handle_original_uuid("ipaUniqueID", src_attrs, "UUID",
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose ret = sysdb_attrs_get_string(dest_attrs, "ghi", &guid);
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose /* check objectGUID with length other than 16 */
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose ret = sysdb_attrs_add_string(src_attrs, "GUID", IPA_UUID);
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose ret = sysdb_handle_original_uuid("objectGUID", src_attrs, "GUID",
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose ret = sysdb_attrs_get_string(dest_attrs, "jkl", &guid);
6cdeb0923c16e3fafe21aaadca6dac1d71474c31Sumit Bosestatic void test_sysdb_attrs_add_base64_blob(void **state)
6cdeb0923c16e3fafe21aaadca6dac1d71474c31Sumit Bose ret = sysdb_attrs_add_base64_blob(attrs, "testAttrABC", TEST_BASE64_ABC);
6cdeb0923c16e3fafe21aaadca6dac1d71474c31Sumit Bose ret = sysdb_attrs_add_base64_blob(attrs, "testAttr000", TEST_BASE64_123);
6cdeb0923c16e3fafe21aaadca6dac1d71474c31Sumit Bose ret = sysdb_attrs_get_el(attrs, "testAttrABC", &el);
6cdeb0923c16e3fafe21aaadca6dac1d71474c31Sumit Bose assert_memory_equal(el->values[0].data, "abc", 3);
6cdeb0923c16e3fafe21aaadca6dac1d71474c31Sumit Bose ret = sysdb_attrs_get_el(attrs, "testAttr000", &el);
6cdeb0923c16e3fafe21aaadca6dac1d71474c31Sumit Bose assert_memory_equal(el->values[0].data, zero, 3);
e2405de14e2fb3d58af4108ecc2726818e6c7c71Jakub Hrozek cmocka_unit_test(test_sysdb_handle_original_uuid),
6cdeb0923c16e3fafe21aaadca6dac1d71474c31Sumit Bose cmocka_unit_test(test_sysdb_attrs_add_base64_blob),
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz /* Set debug level to invalid value so we can decide if -d 0 was used. */
1d93029624d708119bbf803e6647a2cbb271f001Sumit Bose pc = poptGetContext(argv[0], argc, argv, long_options, 0);