|
8 | 8 | # - Test the presence or the absence of expected builtins functions
|
9 | 9 | # - Indentify a constant name by its value and prefix (prefix XCCDF_RESULT
|
10 | 10 | # with value 1 (usually) should identify XCCDF_RESULT_PASS
|
11 |
| -# - Check presence of constants filtered by a prefix (XCCDF_RESULT with |
| 11 | +# - Check presence of constants filtered by a prefix (XCCDF_RESULT with |
12 | 12 | # value = None should returns all XCCDF_RESULT_* constants).
|
13 | 13 | #
|
14 | 14 |
|
15 | 15 |
|
16 | 16 | from import_handler import oscap
|
17 | 17 | from pprint import pprint
|
18 | 18 |
|
19 |
| -oval_funcs=oscap.oval.introspect() |
| 19 | +oval_funcs = oscap.oval.introspect() |
20 | 20 |
|
21 | 21 | if oval_funcs.get('oval_variable_get_values') is None:
|
22 | 22 | raise Exception("method 'oval_variable_get_values' not found in builtins"
|
23 | 23 | "functions of oval object (should be in oscap.oval.introspect())")
|
24 | 24 |
|
25 |
| -if oval_funcs.get('xccdf_check_get_id') is not None: |
| 25 | +if oval_funcs.get('xccdf_check_get_id') is not None: |
26 | 26 | raise Exception("method 'xccdf_check_get_id' should not be found in "
|
27 | 27 | "oscap.oval.introspect(), because the prefix isn't 'oval')")
|
28 | 28 |
|
29 |
| -if oscap.oval.introspect_all().get('xccdf_check_get_id') is None: |
30 |
| - raise Exception("method 'xccdf_check_get_id' should be present in " |
31 |
| - "oscap.oval.introspect_all(), which returns all available builtins functions") |
32 |
| - |
| 29 | +if oscap.oval.introspect_all().get('xccdf_check_get_id') is None: |
| 30 | + raise Exception("method 'xccdf_check_get_id' should be present in " |
| 31 | + "oscap.oval.introspect_all(), which returns all available builtins functions") |
| 32 | + |
33 | 33 | print("Introspection of builtins functions seems working.")
|
34 | 34 |
|
35 | 35 |
|
36 | 36 | # should returns {'XCCDF_RESULT_PASS': 1}
|
37 | 37 | # but it's not impossible that the numeric value change (in fact we don't care of it)
|
38 |
| -pass_val=oscap.oval.XCCDF_RESULT_PASS # is usually 1 |
| 38 | +pass_val = oscap.oval.XCCDF_RESULT_PASS # is usually 1 |
39 | 39 |
|
40 |
| -var1=oscap.oval.introspect_constants(pass_val, "XCCDF_RESULT") |
41 |
| -if len(var1) == 1 and list(var1.keys())[0]=="XCCDF_RESULT_PASS": |
42 |
| - print("Introspection of oscap.oval.XCCDF_RESULT_PASS ok"); |
| 40 | +var1 = oscap.oval.introspect_constants(pass_val, "XCCDF_RESULT") |
| 41 | +if len(var1) == 1 and list(var1.keys())[0] == "XCCDF_RESULT_PASS": |
| 42 | + print("Introspection of oscap.oval.XCCDF_RESULT_PASS ok") |
43 | 43 |
|
44 | 44 |
|
45 |
| -xccdf_results=oscap.oval.introspect_constants(None, "XCCDF_RESULT") |
| 45 | +xccdf_results = oscap.oval.introspect_constants(None, "XCCDF_RESULT") |
46 | 46 | # should returns something like {
|
47 | 47 | # 'XCCDF_RESULT_ERROR': 3,
|
48 | 48 | # 'XCCDF_RESULT_FAIL': 2,
|
|
55 | 55 | # 'XCCDF_RESULT_UNKNOWN': 4}
|
56 | 56 |
|
57 | 57 | expected_constants = ('XCCDF_RESULT_ERROR', 'XCCDF_RESULT_FAIL', 'XCCDF_RESULT_FIXED',
|
58 |
| - 'XCCDF_RESULT_INFORMATIONAL', 'XCCDF_RESULT_NOT_APPLICABLE', |
| 58 | + 'XCCDF_RESULT_INFORMATIONAL', 'XCCDF_RESULT_NOT_APPLICABLE', |
59 | 59 | 'XCCDF_RESULT_NOT_CHECKED', 'XCCDF_RESULT_PASS',
|
60 | 60 | 'XCCDF_RESULT_NOT_SELECTED', 'XCCDF_RESULT_UNKNOWN')
|
61 | 61 |
|
|
64 | 64 | raise Exception("oscap.oval.introspect_constants(None, 'XCCDF_RESULT) should"
|
65 | 65 | "contains the constant {0}.".format(c))
|
66 | 66 |
|
67 |
| -print("Introspection of constants ok with prefix XCCDF_RESULT_*"); |
| 67 | +print("Introspection of constants ok with prefix XCCDF_RESULT_*") |
0 commit comments