capabilities-tests.c File Reference


Detailed Description

Test policy loading capabilities that were introduced in SETools 3.2.

Author:
Jeremy A. Mowery jmowery@tresys.com

Jason Tang jtang@tresys.com

Copyright (C) 2007-2008 Tresys Technology, LLC

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Definition in file capabilities-tests.c.

#include <config.h>
#include <CUnit/CUnit.h>
#include <qpol/policy.h>
#include <stdbool.h>

Go to the source code of this file.


Classes

struct  capability_answer

Defines

#define POLICY_ROOT   TEST_POLICIES "/policy-versions"

Functions

void capability_test (const struct capability_answer *ca)
void capability_v12_source ()
void capability_v15_source ()
void capability_v15_binary ()
void capability_v16_source ()
void capability_v16_binary ()
void capability_v17_source ()
void capability_v17_binary ()
void capability_v18_source ()
void capability_v18_binary ()
void capability_v19_binary ()
void capability_v19_binary_mls ()
void capability_v20_binary ()
void capability_v20_binary_mls ()
void capability_v21_source ()
void capability_v21_binary ()
void capability_v22_source ()
void capability_v22_binary ()
void capability_modv6_base_binary ()
int capabilities_init ()
int capabilities_cleanup ()

Variables

CU_TestInfo capabilities_tests []

Define Documentation

#define POLICY_ROOT   TEST_POLICIES "/policy-versions"
 

Definition at line 34 of file capabilities-tests.c.


Function Documentation

void capability_test const struct capability_answer ca  )  [static]
 

Definition at line 51 of file capabilities-tests.c.

References capability_answer::has_attributes, capability_answer::has_conditionals, capability_answer::has_line_numbers, capability_answer::has_mls, capability_answer::has_modules, capability_answer::has_polcaps, capability_answer::has_source, capability_answer::has_syn_rules, capability_answer::policy_name, capability_answer::policy_type, capability_answer::policy_version, QPOL_CAP_ATTRIB_NAMES, QPOL_CAP_CONDITIONALS, QPOL_CAP_LINE_NUMBERS, QPOL_CAP_MLS, QPOL_CAP_MODULES, QPOL_CAP_POLCAPS, QPOL_CAP_SOURCE, QPOL_CAP_SYN_RULES, qpol_policy_destroy(), qpol_policy_get_policy_version(), qpol_policy_has_capability(), qpol_policy_open_from_file(), QPOL_POLICY_OPTION_NO_NEVERALLOWS, and qpol_policy_t.

Referenced by capability_modv6_base_binary(), capability_v12_source(), capability_v15_binary(), capability_v15_source(), capability_v16_binary(), capability_v16_source(), capability_v17_binary(), capability_v17_source(), capability_v18_binary(), capability_v18_source(), capability_v19_binary(), capability_v19_binary_mls(), capability_v20_binary(), capability_v20_binary_mls(), capability_v21_binary(), capability_v21_source(), capability_v22_binary(), and capability_v22_source().

00052 {
00053         qpol_policy_t *q = NULL;
00054         int policy_type = qpol_policy_open_from_file(ca->policy_name, &q, NULL, NULL, QPOL_POLICY_OPTION_NO_NEVERALLOWS);
00055         CU_ASSERT_FATAL(policy_type >= 0);
00056         CU_ASSERT_EQUAL(policy_type, ca->policy_type);
00057 
00058         unsigned policy_version;
00059         int retval;
00060         retval = qpol_policy_get_policy_version(q, &policy_version);
00061         CU_ASSERT_EQUAL_FATAL(retval, 0);
00062         CU_ASSERT_EQUAL(policy_version, ca->policy_version);
00063 
00064         bool cap;
00065 
00066         cap = (bool) qpol_policy_has_capability(q, QPOL_CAP_ATTRIB_NAMES);
00067         CU_ASSERT_EQUAL(cap, ca->has_attributes);
00068 
00069         cap = (bool) qpol_policy_has_capability(q, QPOL_CAP_SYN_RULES);
00070         CU_ASSERT_EQUAL(cap, ca->has_syn_rules);
00071 
00072         cap = (bool) qpol_policy_has_capability(q, QPOL_CAP_LINE_NUMBERS);
00073         CU_ASSERT_EQUAL(cap, ca->has_line_numbers);
00074 
00075         cap = (bool) qpol_policy_has_capability(q, QPOL_CAP_CONDITIONALS);
00076         CU_ASSERT_EQUAL(cap, ca->has_conditionals);
00077 
00078         cap = (bool) qpol_policy_has_capability(q, QPOL_CAP_MLS);
00079         CU_ASSERT_EQUAL(cap, ca->has_mls);
00080 
00081         cap = (bool) qpol_policy_has_capability(q, QPOL_CAP_POLCAPS);
00082         CU_ASSERT_EQUAL(cap, ca->has_polcaps);
00083 
00084         cap = (bool) qpol_policy_has_capability(q, QPOL_CAP_SOURCE);
00085         CU_ASSERT_EQUAL(cap, ca->has_source);
00086 
00087         cap = (bool) qpol_policy_has_capability(q, QPOL_CAP_MODULES);
00088         CU_ASSERT_EQUAL(cap, ca->has_modules);
00089 
00090         qpol_policy_destroy(&q);
00091 }

void capability_v12_source  )  [static]
 

Definition at line 93 of file capabilities-tests.c.

References capability_test(), and POLICY_ROOT.

00094 {
00095         struct capability_answer cap = {
00096                 POLICY_ROOT "/policy-12.conf",
00097                 QPOL_POLICY_KERNEL_SOURCE,      // policy type
00098                 12U,                   // policy version
00099                 true,                  // has attributes
00100                 true,                  // has syntactic rules
00101                 true,                  // has line numbers
00102                 false,                 // has conditionals
00103                 false,                 // has mls
00104                 false,                 // has policy capabilities
00105                 true,                  // has source
00106                 false                  // has modules
00107         };
00108         capability_test(&cap);
00109 }

void capability_v15_source  )  [static]
 

Definition at line 111 of file capabilities-tests.c.

References capability_test(), and POLICY_ROOT.

00112 {
00113         struct capability_answer cap = {
00114                 POLICY_ROOT "/policy-15.conf",
00115                 QPOL_POLICY_KERNEL_SOURCE,      // policy type
00116                 15U,                   // policy version
00117                 true,                  // has attributes
00118                 true,                  // has syntactic rules
00119                 true,                  // has line numbers
00120                 false,                 // has conditionals
00121                 false,                 // has mls
00122                 false,                 // has policy capabilities
00123                 true,                  // has source
00124                 false                  // has modules
00125         };
00126         capability_test(&cap);
00127 }

void capability_v15_binary  )  [static]
 

Definition at line 129 of file capabilities-tests.c.

References capability_test(), and POLICY_ROOT.

00130 {
00131         struct capability_answer cap = {
00132                 POLICY_ROOT "/policy.15",
00133                 QPOL_POLICY_KERNEL_BINARY,      // policy type
00134                 15U,                   // policy version
00135                 false,                 // has attributes
00136                 false,                 // has syntactic rules
00137                 false,                 // has line numbers
00138                 false,                 // has conditionals
00139                 false,                 // has mls
00140                 false,                 // has policy capabilities
00141                 false,                 // has source
00142                 false                  // has modules
00143         };
00144         capability_test(&cap);
00145 }

void capability_v16_source  )  [static]
 

Definition at line 147 of file capabilities-tests.c.

References capability_test(), and POLICY_ROOT.

00148 {
00149         struct capability_answer cap = {
00150                 POLICY_ROOT "/policy-16.conf",
00151                 QPOL_POLICY_KERNEL_SOURCE,      // policy type
00152                 16U,                   // policy version
00153                 true,                  // has attributes
00154                 true,                  // has syntactic rules
00155                 true,                  // has line numbers
00156                 true,                  // has conditionals
00157                 false,                 // has mls
00158                 false,                 // has policy capabilities
00159                 true,                  // has source
00160                 false                  // has modules
00161         };
00162         capability_test(&cap);
00163 }

void capability_v16_binary  )  [static]
 

Definition at line 165 of file capabilities-tests.c.

References capability_test(), and POLICY_ROOT.

00166 {
00167         struct capability_answer cap = {
00168                 POLICY_ROOT "/policy.16",
00169                 QPOL_POLICY_KERNEL_BINARY,      // policy type
00170                 16U,                   // policy version
00171                 false,                 // has attributes
00172                 false,                 // has syntactic rules
00173                 false,                 // has line numbers
00174                 true,                  // has conditionals
00175                 false,                 // has mls
00176                 false,                 // has policy capabilities
00177                 false,                 // has source
00178                 false                  // has modules
00179         };
00180         capability_test(&cap);
00181 }

void capability_v17_source  )  [static]
 

Definition at line 183 of file capabilities-tests.c.

References capability_test(), and POLICY_ROOT.

00184 {
00185         struct capability_answer cap = {
00186                 POLICY_ROOT "/policy-17.conf",
00187                 QPOL_POLICY_KERNEL_SOURCE,      // policy type
00188                 17U,                   // policy version
00189                 true,                  // has attributes
00190                 true,                  // has syntactic rules
00191                 true,                  // has line numbers
00192                 true,                  // has conditionals
00193                 false,                 // has mls
00194                 false,                 // has policy capabilities
00195                 true,                  // has source
00196                 false                  // has modules
00197         };
00198         capability_test(&cap);
00199 }

void capability_v17_binary  )  [static]
 

Definition at line 201 of file capabilities-tests.c.

References capability_test(), and POLICY_ROOT.

00202 {
00203         struct capability_answer cap = {
00204                 POLICY_ROOT "/policy.17",
00205                 QPOL_POLICY_KERNEL_BINARY,      // policy type
00206                 17U,                   // policy version
00207                 false,                 // has attributes
00208                 false,                 // has syntactic rules
00209                 false,                 // has line numbers
00210                 true,                  // has conditionals
00211                 false,                 // has mls
00212                 false,                 // has policy capabilities
00213                 false,                 // has source
00214                 false                  // has modules
00215         };
00216         capability_test(&cap);
00217 }

void capability_v18_source  )  [static]
 

Definition at line 219 of file capabilities-tests.c.

References capability_test(), and POLICY_ROOT.

00220 {
00221         struct capability_answer cap = {
00222                 POLICY_ROOT "/policy-18.conf",
00223                 QPOL_POLICY_KERNEL_SOURCE,      // policy type
00224                 18U,                   // policy version
00225                 true,                  // has attributes
00226                 true,                  // has syntactic rules
00227                 true,                  // has line numbers
00228                 true,                  // has conditionals
00229                 false,                 // has mls
00230                 false,                 // has policy capabilities
00231                 true,                  // has source
00232                 false                  // has modules
00233         };
00234         capability_test(&cap);
00235 }

void capability_v18_binary  )  [static]
 

Definition at line 237 of file capabilities-tests.c.

References capability_test(), and POLICY_ROOT.

00238 {
00239         struct capability_answer cap = {
00240                 POLICY_ROOT "/policy.18",
00241                 QPOL_POLICY_KERNEL_BINARY,      // policy type
00242                 18U,                   // policy version
00243                 false,                 // has attributes
00244                 false,                 // has syntactic rules
00245                 false,                 // has line numbers
00246                 true,                  // has conditionals
00247                 false,                 // has mls
00248                 false,                 // has policy capabilities
00249                 false,                 // has source
00250                 false                  // has modules
00251         };
00252         capability_test(&cap);
00253 }

void capability_v19_binary  )  [static]
 

Definition at line 255 of file capabilities-tests.c.

References capability_test(), and POLICY_ROOT.

00256 {
00257         struct capability_answer cap = {
00258                 POLICY_ROOT "/policy.19",
00259                 QPOL_POLICY_KERNEL_BINARY,      // policy type
00260                 19U,                   // policy version
00261                 false,                 // has attributes
00262                 false,                 // has syntactic rules
00263                 false,                 // has line numbers
00264                 true,                  // has conditionals
00265                 false,                 // has mls
00266                 false,                 // has policy capabilities
00267                 false,                 // has source
00268                 false                  // has modules
00269         };
00270         capability_test(&cap);
00271 }

void capability_v19_binary_mls  )  [static]
 

Definition at line 273 of file capabilities-tests.c.

References capability_test(), and POLICY_ROOT.

00274 {
00275         struct capability_answer cap = {
00276                 POLICY_ROOT "/policy-mls.19",
00277                 QPOL_POLICY_KERNEL_BINARY,      // policy type
00278                 19U,                   // policy version
00279                 false,                 // has attributes
00280                 false,                 // has syntactic rules
00281                 false,                 // has line numbers
00282                 true,                  // has conditionals
00283                 true,                  // has mls
00284                 false,                 // has policy capabilities
00285                 false,                 // has source
00286                 false                  // has modules
00287         };
00288         capability_test(&cap);
00289 }

void capability_v20_binary  )  [static]
 

Definition at line 291 of file capabilities-tests.c.

References capability_test(), and POLICY_ROOT.

00292 {
00293         struct capability_answer cap = {
00294                 POLICY_ROOT "/policy.20",
00295                 QPOL_POLICY_KERNEL_BINARY,      // policy type
00296                 20U,                   // policy version
00297                 false,                 // has attributes
00298                 false,                 // has syntactic rules
00299                 false,                 // has line numbers
00300                 true,                  // has conditionals
00301                 false,                 // has mls
00302                 false,                 // has policy capabilities
00303                 false,                 // has source
00304                 false                  // has modules
00305         };
00306         capability_test(&cap);
00307 }

void capability_v20_binary_mls  )  [static]
 

Definition at line 309 of file capabilities-tests.c.

References capability_test(), and POLICY_ROOT.

00310 {
00311         struct capability_answer cap = {
00312                 POLICY_ROOT "/policy-mls.20",
00313                 QPOL_POLICY_KERNEL_BINARY,      // policy type
00314                 20U,                   // policy version
00315                 false,                 // has attributes
00316                 false,                 // has syntactic rules
00317                 false,                 // has line numbers
00318                 true,                  // has conditionals
00319                 true,                  // has mls
00320                 false,                 // has policy capabilities
00321                 false,                 // has source
00322                 false                  // has modules
00323         };
00324         capability_test(&cap);
00325 }

void capability_v21_source  )  [static]
 

Definition at line 327 of file capabilities-tests.c.

References capability_test(), and POLICY_ROOT.

00328 {
00329         struct capability_answer cap = {
00330                 POLICY_ROOT "/policy-mls-21.conf",
00331                 QPOL_POLICY_KERNEL_SOURCE,      // policy type
00332                 21U,                   // policy version
00333                 true,                  // has attributes
00334                 true,                  // has syntactic rules
00335                 true,                  // has line numbers
00336                 true,                  // has conditionals
00337                 true,                  // has mls
00338                 false,                 // has policy capabilities
00339                 true,                  // has source
00340                 false                  // has modules
00341         };
00342         capability_test(&cap);
00343 }

void capability_v21_binary  )  [static]
 

Definition at line 345 of file capabilities-tests.c.

References capability_test(), and POLICY_ROOT.

00346 {
00347         struct capability_answer cap = {
00348                 POLICY_ROOT "/policy-mls.21",
00349                 QPOL_POLICY_KERNEL_BINARY,      // policy type
00350                 21U,                   // policy version
00351                 false,                 // has attributes
00352                 false,                 // has syntactic rules
00353                 false,                 // has line numbers
00354                 true,                  // has conditionals
00355                 true,                  // has mls
00356                 false,                 // has policy capabilities
00357                 false,                 // has source
00358                 false                  // has modules
00359         };
00360         capability_test(&cap);
00361 }

void capability_v22_source  )  [static]
 

Definition at line 363 of file capabilities-tests.c.

References capability_test(), and POLICY_ROOT.

00364 {
00365         struct capability_answer cap = {
00366                 POLICY_ROOT "/policy-mls-22.conf",
00367                 QPOL_POLICY_KERNEL_SOURCE,      // policy type
00368                 22U,                   // policy version
00369                 true,                  // has attributes
00370                 true,                  // has syntactic rules
00371                 true,                  // has line numbers
00372                 true,                  // has conditionals
00373                 true,                  // has mls
00374                 true,                  // has policy capabilities
00375                 true,                  // has source
00376                 false                  // has modules
00377         };
00378         capability_test(&cap);
00379 }

void capability_v22_binary  )  [static]
 

Definition at line 381 of file capabilities-tests.c.

References capability_test(), and POLICY_ROOT.

00382 {
00383         struct capability_answer cap = {
00384                 POLICY_ROOT "/policy-mls.22",
00385                 QPOL_POLICY_KERNEL_BINARY,      // policy type
00386                 22U,                   // policy version
00387                 false,                 // has attributes
00388                 false,                 // has syntactic rules
00389                 false,                 // has line numbers
00390                 true,                  // has conditionals
00391                 true,                  // has mls
00392                 true,                  // has policy capabilities
00393                 false,                 // has source
00394                 false                  // has modules
00395         };
00396         capability_test(&cap);
00397 }

void capability_modv6_base_binary  )  [static]
 

Definition at line 399 of file capabilities-tests.c.

References capability_test(), and POLICY_ROOT.

00400 {
00401         struct capability_answer cap = {
00402                 POLICY_ROOT "/base-6.pp",
00403                 QPOL_POLICY_MODULE_BINARY,      // policy type
00404                 6U,                    // policy version
00405                 true,                  // has attributes
00406                 true,                  // has syntactic rules
00407                 false,                 // has line numbers
00408                 true,                  // has conditionals
00409                 true,                  // has mls
00410                 false,                 // has policy capabilities
00411                 false,                 // has source
00412                 true                   // has modules
00413         };
00414         capability_test(&cap);
00415 }

int capabilities_init  ) 
 

Definition at line 439 of file capabilities-tests.c.

00440 {
00441         return 0;
00442 }

int capabilities_cleanup  ) 
 

Definition at line 444 of file capabilities-tests.c.

00445 {
00446         return 0;
00447 }


Variable Documentation

CU_TestInfo capabilities_tests[]
 

Initial value:

 {
        {"v12, source", capability_v12_source},
        {"v15, source", capability_v15_source},
        {"v15, binary", capability_v15_binary},
        {"v16, source", capability_v16_source},
        {"v16, binary", capability_v16_binary},
        {"v17, source", capability_v17_source},
        {"v17, binary", capability_v17_binary},
        {"v18, source", capability_v18_source},
        {"v18, binary", capability_v18_binary},
        {"v19, binary", capability_v19_binary},
        {"v19, binary mls", capability_v19_binary_mls},
        {"v20, binary", capability_v20_binary},
        {"v20, binary mls", capability_v20_binary_mls},
        {"v21, source", capability_v21_source},
        {"v21, binary", capability_v21_binary},
        {"v22, source", capability_v22_source},
        {"v22, binary", capability_v22_binary},
        {"mod v6, base binary", capability_modv6_base_binary},
        CU_TEST_INFO_NULL
}

Definition at line 417 of file capabilities-tests.c.

Referenced by main().