"Fossies" - the Fresh Open Source Software Archive

Member "sssd-2.2.3/src/tests/ad_ldap_opt-tests.c" (30 Nov 2019, 3313 Bytes) of package /linux/misc/sssd-2.2.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2    SSSD
    3 
    4    Tests if AD and LDAP backend options are in sync
    5 
    6    Authors:
    7        Jakub Hrozek <jhrozek@redhat.com>
    8        Stephen Gallagher <sgallagh@redhat.com>
    9 
   10    Copyright (C) 2012 Red Hat
   11 
   12    This program is free software; you can redistribute it and/or modify
   13    it under the terms of the GNU General Public License as published by
   14    the Free Software Foundation; either version 3 of the License, or
   15    (at your option) any later version.
   16 
   17    This program is distributed in the hope that it will be useful,
   18    but WITHOUT ANY WARRANTY; without even the implied warranty of
   19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   20    GNU General Public License for more details.
   21 
   22    You should have received a copy of the GNU General Public License
   23    along with this program.  If not, see <http://www.gnu.org/licenses/>.
   24 */
   25 
   26 #include <check.h>
   27 #include <stdlib.h>
   28 #include <talloc.h>
   29 
   30 #include "providers/ad/ad_common.h"
   31 #include "providers/ad/ad_opts.h"
   32 #include "providers/ldap/sdap.h"
   33 #include "providers/ldap/ldap_opts.h"
   34 #include "providers/krb5/krb5_opts.h"
   35 #include "providers/krb5/krb5_common.h"
   36 #include "tests/common.h"
   37 
   38 START_TEST(test_compare_opts)
   39 {
   40     errno_t ret;
   41 
   42     ret = compare_dp_options(default_basic_opts, SDAP_OPTS_BASIC,
   43                              ad_def_ldap_opts);
   44     fail_unless(ret == EOK, "[%s]", strerror(ret));
   45 
   46     ret = compare_dp_options(default_krb5_opts, KRB5_OPTS,
   47                              ad_def_krb5_opts);
   48     fail_unless(ret == EOK, "[%s]", strerror(ret));
   49 }
   50 END_TEST
   51 
   52 START_TEST(test_compare_sdap_attrs)
   53 {
   54     errno_t ret;
   55 
   56     /* General Attributes */
   57     ret = compare_sdap_attr_maps(generic_attr_map, SDAP_AT_GENERAL,
   58                                  ad_2008r2_attr_map);
   59     fail_unless(ret == EOK, "[%s]", strerror(ret));
   60 
   61     /* User Attributes */
   62     ret = compare_sdap_attr_maps(rfc2307_user_map, SDAP_OPTS_USER,
   63                                  ad_2008r2_user_map);
   64     fail_unless(ret == EOK, "[%s]", strerror(ret));
   65 
   66     /* Group Attributes */
   67     ret = compare_sdap_attr_maps(rfc2307_group_map, SDAP_OPTS_GROUP,
   68                                  ad_2008r2_group_map);
   69     fail_unless(ret == EOK, "[%s]", strerror(ret));
   70 
   71     /* Netgroup Attributes */
   72     ret = compare_sdap_attr_maps(netgroup_map, SDAP_OPTS_NETGROUP,
   73                                  ad_netgroup_map);
   74     fail_unless(ret == EOK, "[%s]", strerror(ret));
   75 
   76     /* Service Attributes */
   77     ret = compare_sdap_attr_maps(service_map, SDAP_OPTS_SERVICES,
   78                                  ad_service_map);
   79     fail_unless(ret == EOK, "[%s]", strerror(ret));
   80 }
   81 END_TEST
   82 
   83 Suite *ad_ldap_opt_suite (void)
   84 {
   85     Suite *s = suite_create ("ad_ldap_opt");
   86 
   87     TCase *tc_ad_ldap_opt = tcase_create ("ad_ldap_opt");
   88 
   89     tcase_add_test (tc_ad_ldap_opt, test_compare_opts);
   90     tcase_add_test (tc_ad_ldap_opt, test_compare_sdap_attrs);
   91     suite_add_tcase (s, tc_ad_ldap_opt);
   92 
   93     return s;
   94 }
   95 
   96 int main(void)
   97 {
   98     int number_failed;
   99 
  100     tests_set_cwd();
  101 
  102     Suite *s = ad_ldap_opt_suite ();
  103     SRunner *sr = srunner_create (s);
  104     /* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */
  105     srunner_run_all(sr, CK_ENV);
  106     number_failed = srunner_ntests_failed (sr);
  107     srunner_free (sr);
  108     return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
  109 }