LCOV - code coverage report
Current view: top level - tests - ad_ldap_opt-tests.c (source / functions) Hit Total Coverage
Test: .coverage.total Lines: 33 33 100.0 %
Date: 2015-10-19 Functions: 4 4 100.0 %

          Line data    Source code
       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           1 : START_TEST(test_compare_opts)
      39             : {
      40             :     errno_t ret;
      41             : 
      42           1 :     ret = compare_dp_options(default_basic_opts, SDAP_OPTS_BASIC,
      43             :                              ad_def_ldap_opts);
      44           1 :     fail_unless(ret == EOK, "[%s]", strerror(ret));
      45             : 
      46           1 :     ret = compare_dp_options(default_krb5_opts, KRB5_OPTS,
      47             :                              ad_def_krb5_opts);
      48           1 :     fail_unless(ret == EOK, "[%s]", strerror(ret));
      49             : }
      50           1 : END_TEST
      51             : 
      52           1 : START_TEST(test_compare_sdap_attrs)
      53             : {
      54             :     errno_t ret;
      55             : 
      56             :     /* General Attributes */
      57           1 :     ret = compare_sdap_attr_maps(generic_attr_map, SDAP_AT_GENERAL,
      58             :                                  ad_2008r2_attr_map);
      59           1 :     fail_unless(ret == EOK, "[%s]", strerror(ret));
      60             : 
      61             :     /* User Attributes */
      62           1 :     ret = compare_sdap_attr_maps(rfc2307_user_map, SDAP_OPTS_USER,
      63             :                                  ad_2008r2_user_map);
      64           1 :     fail_unless(ret == EOK, "[%s]", strerror(ret));
      65             : 
      66             :     /* Group Attributes */
      67           1 :     ret = compare_sdap_attr_maps(rfc2307_group_map, SDAP_OPTS_GROUP,
      68             :                                  ad_2008r2_group_map);
      69           1 :     fail_unless(ret == EOK, "[%s]", strerror(ret));
      70             : 
      71             :     /* Netgroup Attributes */
      72           1 :     ret = compare_sdap_attr_maps(netgroup_map, SDAP_OPTS_NETGROUP,
      73             :                                  ad_netgroup_map);
      74           1 :     fail_unless(ret == EOK, "[%s]", strerror(ret));
      75             : 
      76             :     /* Service Attributes */
      77           1 :     ret = compare_sdap_attr_maps(service_map, SDAP_OPTS_SERVICES,
      78             :                                  ad_service_map);
      79           1 :     fail_unless(ret == EOK, "[%s]", strerror(ret));
      80             : }
      81           1 : END_TEST
      82             : 
      83           1 : Suite *ad_ldap_opt_suite (void)
      84             : {
      85           1 :     Suite *s = suite_create ("ad_ldap_opt");
      86             : 
      87           1 :     TCase *tc_ad_ldap_opt = tcase_create ("ad_ldap_opt");
      88             : 
      89           1 :     tcase_add_test (tc_ad_ldap_opt, test_compare_opts);
      90           1 :     tcase_add_test (tc_ad_ldap_opt, test_compare_sdap_attrs);
      91           1 :     suite_add_tcase (s, tc_ad_ldap_opt);
      92             : 
      93           1 :     return s;
      94             : }
      95             : 
      96           1 : int main(void)
      97             : {
      98             :     int number_failed;
      99             : 
     100           1 :     tests_set_cwd();
     101             : 
     102           1 :     Suite *s = ad_ldap_opt_suite ();
     103           1 :     SRunner *sr = srunner_create (s);
     104             :     /* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */
     105           1 :     srunner_run_all(sr, CK_ENV);
     106           1 :     number_failed = srunner_ntests_failed (sr);
     107           1 :     srunner_free (sr);
     108           1 :     return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
     109             : }

Generated by: LCOV version 1.10