f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina Pavel Březina <pbrezina@redhat.com>
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina Copyright (C) 2014 Red Hat
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina This program is free software; you can redistribute it and/or modify
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina it under the terms of the GNU General Public License as published by
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina the Free Software Foundation; either version 3 of the License, or
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina (at your option) any later version.
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina This program is distributed in the hope that it will be useful,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina GNU General Public License for more details.
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina You should have received a copy of the GNU General Public License
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina__wrap_dbus_bus_get(DBusBusType type, DBusError *error)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* we won't use the connection anywhere, so we can just return NULL */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina__wrap_dbus_connection_send_with_reply_and_block(DBusConnection *connection,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinastatic void reply_variant_basic(DBusMessage *reply,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina const void *val)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* Now add the value */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_append_basic(&variant_iter, type[0], val);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_close_container(&iter, &variant_iter);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinastatic void reply_variant_array(DBusMessage *reply,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_open_container(&variant_iter, DBUS_TYPE_ARRAY,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina for (i = 0; i < num_vals; i++) {
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_append_basic(&array_iter, type[0], addr);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_close_container(&iter, &array_iter);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_close_container(&iter, &variant_iter);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina test_ctx.reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* sss_sifp is responsible for freeing the reply */
df9e9a1f9b7dc255eb62c390163c25917b08f5a2Lukas Slebodnik char *dup_str = sss_sifp_strdup(test_ctx.dbus_ctx, str);
df9e9a1f9b7dc255eb62c390163c25917b08f5a2Lukas Slebodnik sss_sifp_free_string(test_ctx.dbus_ctx, &dup_str);
df9e9a1f9b7dc255eb62c390163c25917b08f5a2Lukas Slebodnik char *dup_str = sss_sifp_strdup(test_ctx.dbus_ctx, NULL);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina char *cat = sss_sifp_strcat(test_ctx.dbus_ctx, "hello ", "world");
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina sss_sifp_free_string(test_ctx.dbus_ctx, &cat);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_strcat_left_null(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina char *cat = sss_sifp_strcat(test_ctx.dbus_ctx, NULL, "world");
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina sss_sifp_free_string(test_ctx.dbus_ctx, &cat);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_strcat_right_null(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina char *cat = sss_sifp_strcat(test_ctx.dbus_ctx, "hello ", NULL);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina sss_sifp_free_string(test_ctx.dbus_ctx, &cat);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_strcat_both_null(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina char *cat = sss_sifp_strcat(test_ctx.dbus_ctx, NULL, NULL);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_object_path_valid(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path_in,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_object_path(ctx, reply, &path_out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_object_path_invalid(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_append_args(reply, DBUS_TYPE_UINT16, &path_in,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_object_path(ctx, reply, &path_out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_object_path_list_valid(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina const char *path_in[] = {"/object/path1", "/object/path2"};
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_append_args(reply, DBUS_TYPE_ARRAY,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_object_path_list(ctx, reply, &path_out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_object_path_list_invalid(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path_in,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_object_path_list(ctx, reply, &path_out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_bool(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina reply_variant_basic(reply, DBUS_TYPE_BOOLEAN_AS_STRING, &in);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_BOOL);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_bool(attrs, name, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_int16(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina reply_variant_basic(reply, DBUS_TYPE_INT16_AS_STRING, &in);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_INT16);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_int16(attrs, name, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_uint16(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina reply_variant_basic(reply, DBUS_TYPE_UINT16_AS_STRING, &in);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_UINT16);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_uint16(attrs, name, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_int32(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina reply_variant_basic(reply, DBUS_TYPE_INT32_AS_STRING, &in);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_INT32);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_int32(attrs, name, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_uint32(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina reply_variant_basic(reply, DBUS_TYPE_UINT32_AS_STRING, &in);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_UINT32);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_uint32(attrs, name, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_int64(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina reply_variant_basic(reply, DBUS_TYPE_INT64_AS_STRING, &in);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_INT64);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_int64(attrs, name, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_uint64(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina reply_variant_basic(reply, DBUS_TYPE_UINT64_AS_STRING, &in);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_UINT64);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_uint64(attrs, name, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_string(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina reply_variant_basic(reply, DBUS_TYPE_STRING_AS_STRING, &in);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_STRING);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_string(attrs, name, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_object_path(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina reply_variant_basic(reply, DBUS_TYPE_OBJECT_PATH_AS_STRING, &in);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_STRING);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_string(attrs, name, &out);
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březinavoid test_sss_sifp_parse_attr_string_dict(void **state)
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina /* prepare message */
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina bret = dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina bret = dbus_message_iter_open_container(&var_iter, DBUS_TYPE_ARRAY,
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina bret = dbus_message_iter_open_container(&array_iter,
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina bret = dbus_message_iter_append_basic(&dict_iter, DBUS_TYPE_STRING,
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina bret = dbus_message_iter_append_basic(&dict_iter, DBUS_TYPE_STRING,
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina bret = dbus_message_iter_close_container(&array_iter, &dict_iter);
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina bret = dbus_message_iter_close_container(&var_iter, &array_iter);
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina bret = dbus_message_iter_close_container(&iter, &var_iter);
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_STRING_DICT);
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina ret = sss_sifp_find_attr_as_string_dict(attrs, name, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_bool_array(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina unsigned int i;
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina reply_variant_array(reply, DBUS_TYPE_BOOLEAN_AS_STRING, num_values,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->num_values, num_values);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_BOOL);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_bool_array(attrs, name, &out_num, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina for (i = 0; i < num_values; i++) {
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březinavoid test_sss_sifp_parse_attr_bool_array_empty(void **state)
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina /* prepare message */
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina reply_variant_array(reply, DBUS_TYPE_BOOLEAN_AS_STRING, num_values,
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina assert_int_equal(attrs[0]->num_values, num_values);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_BOOL);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina ret = sss_sifp_find_attr_as_bool_array(attrs, name, &out_num, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_int16_array(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina int16_t in_array[] = {10, 15, -10, -15, 5559};
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina unsigned int i;
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina reply_variant_array(reply, DBUS_TYPE_INT16_AS_STRING, num_values,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->num_values, num_values);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_INT16);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_int16_array(attrs, name, &out_num, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina for (i = 0; i < num_values; i++) {
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březinavoid test_sss_sifp_parse_attr_int16_array_empty(void **state)
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina /* prepare message */
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina reply_variant_array(reply, DBUS_TYPE_INT16_AS_STRING, num_values,
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina assert_int_equal(attrs[0]->num_values, num_values);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_INT16);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina ret = sss_sifp_find_attr_as_int16_array(attrs, name, &out_num, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_uint16_array(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina uint16_t in_array[] = {10, 15, 8885, 3224, 5559};
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina unsigned int i;
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina reply_variant_array(reply, DBUS_TYPE_UINT16_AS_STRING, num_values,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->num_values, num_values);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_UINT16);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_uint16_array(attrs, name, &out_num, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina for (i = 0; i < num_values; i++) {
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březinavoid test_sss_sifp_parse_attr_uint16_array_empty(void **state)
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina /* prepare message */
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina reply_variant_array(reply, DBUS_TYPE_UINT16_AS_STRING, num_values,
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina assert_int_equal(attrs[0]->num_values, num_values);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_UINT16);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina ret = sss_sifp_find_attr_as_uint16_array(attrs, name, &out_num, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_int32_array(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina int32_t in_array[] = {10, 15, -10, -15, 5559};
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina unsigned int i;
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina reply_variant_array(reply, DBUS_TYPE_INT32_AS_STRING, num_values,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->num_values, num_values);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_INT32);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_int32_array(attrs, name, &out_num, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina for (i = 0; i < num_values; i++) {
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březinavoid test_sss_sifp_parse_attr_int32_array_empty(void **state)
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina /* prepare message */
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina reply_variant_array(reply, DBUS_TYPE_INT32_AS_STRING, num_values,
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina assert_int_equal(attrs[0]->num_values, num_values);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_INT32);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina ret = sss_sifp_find_attr_as_int32_array(attrs, name, &out_num, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_uint32_array(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina uint32_t in_array[] = {10, 15, 8885, 3224, 5559};
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina unsigned int i;
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina reply_variant_array(reply, DBUS_TYPE_UINT32_AS_STRING, num_values,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->num_values, num_values);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_UINT32);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_uint32_array(attrs, name, &out_num, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina for (i = 0; i < num_values; i++) {
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březinavoid test_sss_sifp_parse_attr_uint32_array_empty(void **state)
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina /* prepare message */
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina reply_variant_array(reply, DBUS_TYPE_UINT32_AS_STRING, num_values,
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina assert_int_equal(attrs[0]->num_values, num_values);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_UINT32);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina ret = sss_sifp_find_attr_as_uint32_array(attrs, name, &out_num, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_int64_array(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina int64_t in_array[] = {10, 15, -10, -15, 5559};
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina unsigned int i;
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina reply_variant_array(reply, DBUS_TYPE_INT64_AS_STRING, num_values,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->num_values, num_values);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_INT64);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_int64_array(attrs, name, &out_num, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina for (i = 0; i < num_values; i++) {
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březinavoid test_sss_sifp_parse_attr_int64_array_empty(void **state)
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina /* prepare message */
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina reply_variant_array(reply, DBUS_TYPE_INT64_AS_STRING, num_values,
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina assert_int_equal(attrs[0]->num_values, num_values);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_INT64);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina ret = sss_sifp_find_attr_as_int64_array(attrs, name, &out_num, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_uint64_array(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina uint64_t in_array[] = {10, 15, 8885, 3224, 5559};
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina unsigned int i;
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina reply_variant_array(reply, DBUS_TYPE_UINT64_AS_STRING, num_values,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->num_values, num_values);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_UINT64);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_uint64_array(attrs, name, &out_num, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina for (i = 0; i < num_values; i++) {
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březinavoid test_sss_sifp_parse_attr_uint64_array_empty(void **state)
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina /* prepare message */
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina reply_variant_array(reply, DBUS_TYPE_UINT64_AS_STRING, num_values,
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina assert_int_equal(attrs[0]->num_values, num_values);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_UINT64);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina ret = sss_sifp_find_attr_as_uint64_array(attrs, name, &out_num, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_string_array(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina const char *in_array[] = {"I", "don't", "like", "writing", "unit", "tests"};
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina unsigned int i;
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina reply_variant_array(reply, DBUS_TYPE_STRING_AS_STRING, num_values,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->num_values, num_values);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_STRING);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_string_array(attrs, name, &out_num, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina for (i = 0; i < num_values; i++) {
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březinavoid test_sss_sifp_parse_attr_string_array_empty(void **state)
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina /* prepare message */
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina reply_variant_array(reply, DBUS_TYPE_STRING_AS_STRING, num_values,
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina NULL, sizeof(const char*));
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina assert_int_equal(attrs[0]->num_values, num_values);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_STRING);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina ret = sss_sifp_find_attr_as_string_array(attrs, name, &out_num, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_object_path_array(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina const char *in_array[] = {"/object/path1", "/object/path2"};
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina unsigned int i;
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
b7080f1a2c6c97224c41f6347ca3743e1054faecPavel Březina reply_variant_array(reply, DBUS_TYPE_OBJECT_PATH_AS_STRING, num_values,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->num_values, num_values);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_STRING);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_string_array(attrs, name, &out_num, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina for (i = 0; i < num_values; i++) {
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březinavoid test_sss_sifp_parse_attr_object_path_array_empty(void **state)
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina /* prepare message */
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina reply_variant_array(reply, DBUS_TYPE_OBJECT_PATH_AS_STRING, num_values,
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina NULL, sizeof(const char*));
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina assert_int_equal(attrs[0]->num_values, num_values);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_STRING);
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina ret = sss_sifp_find_attr_as_string_array(attrs, name, &out_num, &out);
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březinavoid test_sss_sifp_parse_attr_string_dict_array(void **state)
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina static struct {
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina } data = {"key", {"value1", "value2", "value3"}};
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina unsigned int i;
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina /* prepare message */
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina bret = dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina bret = dbus_message_iter_open_container(&var_iter, DBUS_TYPE_ARRAY,
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina bret = dbus_message_iter_open_container(&array_iter,
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina bret = dbus_message_iter_append_basic(&dict_iter, DBUS_TYPE_STRING,
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina bret = dbus_message_iter_open_container(&dict_iter, DBUS_TYPE_ARRAY,
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina for (i = 0; i < num_values; i++) {
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina bret = dbus_message_iter_append_basic(&val_iter, DBUS_TYPE_STRING,
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina bret = dbus_message_iter_close_container(&dict_iter, &val_iter);
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina bret = dbus_message_iter_close_container(&array_iter, &dict_iter);
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina bret = dbus_message_iter_close_container(&var_iter, &array_iter);
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina bret = dbus_message_iter_close_container(&iter, &var_iter);
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina ret = sss_sifp_parse_attr(ctx, name, reply, &attrs);
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_STRING_DICT);
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina ret = sss_sifp_find_attr_as_string_dict(attrs, name, &out);
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina for (i = 0; i < num_values; i++) {
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina assert_string_equal(values[i], data.values[i]);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_list(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina } data[] = {{"attr1", 1}, {"attr2", 2}, {"attr3", 3}, {NULL, 0}};
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_open_container(&array_iter,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_append_basic(&dict_iter, DBUS_TYPE_STRING,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_open_container(&dict_iter, DBUS_TYPE_VARIANT,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_append_basic(&var_iter, DBUS_TYPE_UINT32,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_close_container(&dict_iter, &var_iter);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_close_container(&array_iter, &dict_iter);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_close_container(&iter, &array_iter);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr_list(ctx, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[i]->type, SSS_SIFP_ATTR_TYPE_UINT32);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_string_equal(attrs[i]->name, data[i].name);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_uint32(attrs, data[i].name, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_parse_attr_list_empty(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_close_container(&iter, &array_iter);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_parse_attr_list(ctx, reply, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina reply_variant_basic(reply, DBUS_TYPE_UINT32_AS_STRING, &in);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina will_return(__wrap_dbus_connection_send_with_reply_and_block, reply);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_fetch_attr(ctx, "/test/object", "test.com", name, &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[0]->type, SSS_SIFP_ATTR_TYPE_UINT32);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_uint32(attrs, name, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_fetch_all_attrs(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina } data[] = {{"attr1", 1}, {"attr2", 2}, {"attr3", 3}, {NULL, 0}};
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_open_container(&array_iter,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_append_basic(&dict_iter, DBUS_TYPE_STRING,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_open_container(&dict_iter, DBUS_TYPE_VARIANT,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_append_basic(&var_iter, DBUS_TYPE_UINT32,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_close_container(&dict_iter, &var_iter);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_close_container(&array_iter, &dict_iter);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_close_container(&iter, &array_iter);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina will_return(__wrap_dbus_connection_send_with_reply_and_block, reply);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_fetch_all_attrs(ctx, "/test/object", "test.com", &attrs);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(attrs[i]->type, SSS_SIFP_ATTR_TYPE_UINT32);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_string_equal(attrs[i]->name, data[i].name);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_uint32(attrs, data[i].name, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina } data[] = {{"name", "test-object"}, {"a1", "a"}, {"a2", "b"}, {NULL, 0}};
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_open_container(&array_iter,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_append_basic(&dict_iter, DBUS_TYPE_STRING,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_open_container(&dict_iter, DBUS_TYPE_VARIANT,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_append_basic(&var_iter, DBUS_TYPE_STRING,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_close_container(&dict_iter, &var_iter);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_close_container(&array_iter, &dict_iter);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_iter_close_container(&iter, &array_iter);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina will_return(__wrap_dbus_connection_send_with_reply_and_block, reply);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_fetch_object(ctx, path, iface, &object);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_string_equal(object->name, "test-object");
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_string_equal(object->object_path, path);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_string_equal(object->interface, iface);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(object->attrs[i]->num_values, 1);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_int_equal(object->attrs[i]->type, SSS_SIFP_ATTR_TYPE_STRING);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina assert_string_equal(object->attrs[i]->name, data[i].name);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina ret = sss_sifp_find_attr_as_string(object->attrs, data[i].name, &out);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_invoke_list_zeroargs(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina const char *path_in[] = {"/object/path1", "/object/path2"};
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_append_args(reply, DBUS_TYPE_ARRAY,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina will_return(__wrap_dbus_connection_send_with_reply_and_block, reply);
2a45f13e3139063d3a5842119e7377c8c98aea1dPavel Březina ret = sss_sifp_invoke_list_ex(ctx, SSS_SIFP_PATH, SSS_SIFP_IFACE,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_invoke_list_withargs(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina const char *path_in[] = {"/object/path1", "/object/path2"};
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_append_args(reply, DBUS_TYPE_ARRAY,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina will_return(__wrap_dbus_connection_send_with_reply_and_block, reply);
2a45f13e3139063d3a5842119e7377c8c98aea1dPavel Březina ret = sss_sifp_invoke_list_ex(ctx, SSS_SIFP_PATH, SSS_SIFP_IFACE,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_invoke_find_zeroargs(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path_in,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina will_return(__wrap_dbus_connection_send_with_reply_and_block, reply);
2a45f13e3139063d3a5842119e7377c8c98aea1dPavel Březina ret = sss_sifp_invoke_find_ex(ctx, SSS_SIFP_PATH, SSS_SIFP_IFACE,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březinavoid test_sss_sifp_invoke_find_withargs(void **state)
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* prepare message */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina bret = dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path_in,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina will_return(__wrap_dbus_connection_send_with_reply_and_block, reply);
2a45f13e3139063d3a5842119e7377c8c98aea1dPavel Březina ret = sss_sifp_invoke_find_ex(ctx, SSS_SIFP_PATH, SSS_SIFP_IFACE,
2a45f13e3139063d3a5842119e7377c8c98aea1dPavel Březina const char *in[] = {SSS_SIFP_PATH "/Domains/LDAP",
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina msg_paths = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina msg_ldap = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina msg_ipa = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina /* prepare message */
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina bret = dbus_message_append_args(msg_paths, DBUS_TYPE_ARRAY,
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina reply_variant_basic(msg_ldap, DBUS_TYPE_STRING_AS_STRING, &names[0]);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina reply_variant_basic(msg_ipa, DBUS_TYPE_STRING_AS_STRING, &names[1]);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina will_return(__wrap_dbus_connection_send_with_reply_and_block, msg_paths);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina will_return(__wrap_dbus_connection_send_with_reply_and_block, msg_ldap);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina will_return(__wrap_dbus_connection_send_with_reply_and_block, msg_ipa);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina for (i = 0; i < in_len; i++) {
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina /* messages are unrefed in the library */
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březinavoid test_sss_sifp_fetch_domain_by_name(void **state)
2a45f13e3139063d3a5842119e7377c8c98aea1dPavel Březina const char *in =SSS_SIFP_PATH "/Domains/LDAP";
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina } props[] = {{"name", name}, {"a1", "a"}, {"a2", "b"}, {NULL, 0}};
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina msg_path = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina msg_props = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina /* prepare message */
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina bret = dbus_message_append_args(msg_path, DBUS_TYPE_OBJECT_PATH, &in,
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina dbus_message_iter_init_append(msg_props, &iter);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina bret = dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina bret = dbus_message_iter_open_container(&array_iter,
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina bret = dbus_message_iter_append_basic(&dict_iter, DBUS_TYPE_STRING,
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina bret = dbus_message_iter_open_container(&dict_iter, DBUS_TYPE_VARIANT,
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina bret = dbus_message_iter_append_basic(&var_iter, DBUS_TYPE_STRING,
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina bret = dbus_message_iter_close_container(&dict_iter, &var_iter);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina bret = dbus_message_iter_close_container(&array_iter, &dict_iter);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina bret = dbus_message_iter_close_container(&iter, &array_iter);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina will_return(__wrap_dbus_connection_send_with_reply_and_block, msg_path);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina will_return(__wrap_dbus_connection_send_with_reply_and_block, msg_props);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina ret = sss_sifp_fetch_domain_by_name(ctx, name, &out);
2a45f13e3139063d3a5842119e7377c8c98aea1dPavel Březina assert_string_equal(out->interface, IFACE_IFP_DOMAINS);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina assert_int_equal(out->attrs[i]->num_values, 1);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina assert_int_equal(out->attrs[i]->type, SSS_SIFP_ATTR_TYPE_STRING);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina assert_string_equal(out->attrs[i]->name, props[i].name);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina ret = sss_sifp_find_attr_as_string(out->attrs, props[i].name, &prop);
0bb98b7700b1b61f5b0a20b93279d5c2c391007fPavel Březina /* messages are unrefed in the library */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina {"no-cleanup", 'n', POPT_ARG_NONE, &no_cleanup, 0,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina _("Do not delete the test database after a test run"), NULL },
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_strdup_valid,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_strdup_null,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_strcat_valid,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_strcat_left_null,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_strcat_right_null,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_strcat_both_null,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_object_path_valid,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_object_path_invalid,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_object_path_list_valid,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_object_path_list_invalid,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_bool,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_int16,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_uint16,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_int32,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_uint32,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_int64,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_uint64,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_string,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_object_path,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_string_dict,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_bool_array,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_bool_array_empty,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_int32_array,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_int32_array_empty,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_uint32_array,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_uint32_array_empty,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_int64_array,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_int64_array_empty,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_uint64_array,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_uint64_array_empty,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_string_array,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_string_array_empty,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_object_path_array,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_object_path_array_empty,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_string_dict_array,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_list,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_parse_attr_list_empty,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_fetch_attr,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_fetch_all_attrs,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_fetch_object,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_invoke_list_zeroargs,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_invoke_list_withargs,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_invoke_find_zeroargs,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_invoke_find_withargs,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_list_domains,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(test_sss_sifp_fetch_domain_by_name,
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina /* Set debug level to invalid value so we can deside if -d 0 was used. */
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina pc = poptGetContext(argv[0], argc, argv, long_options, 0);
f43c6a9ae2aea13b7a83fd932139f9352efbfcadPavel Březina fprintf(stderr, "\nInvalid option %s: %s\n\n",