|
@@ 150-167 (lines=18) @@
|
| 147 |
|
ssg.build_yaml.Platform.from_text("something_bogus", product_cpes) |
| 148 |
|
|
| 149 |
|
|
| 150 |
|
def test_platform_from_text_simple(product_cpes): |
| 151 |
|
platform = ssg.build_yaml.Platform.from_text("machine", product_cpes) |
| 152 |
|
assert platform.to_ansible_conditional() == \ |
| 153 |
|
"ansible_virtualization_type not in [\"docker\", \"lxc\", \"openvz\", \"podman\", \"container\"]" |
| 154 |
|
assert platform.to_bash_conditional() == \ |
| 155 |
|
"[ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]" |
| 156 |
|
platform_el = ET.fromstring(platform.to_xml_element()) |
| 157 |
|
assert platform_el.tag == "{%s}platform" % cpe_language_namespace |
| 158 |
|
assert platform_el.get("id") == "machine" |
| 159 |
|
logical_tests = platform_el.findall( |
| 160 |
|
"{%s}logical-test" % cpe_language_namespace) |
| 161 |
|
assert len(logical_tests) == 1 |
| 162 |
|
assert logical_tests[0].get("operator") == "AND" |
| 163 |
|
assert logical_tests[0].get("negate") == "false" |
| 164 |
|
fact_refs = logical_tests[0].findall( |
| 165 |
|
"{%s}fact-ref" % cpe_language_namespace) |
| 166 |
|
assert len(fact_refs) == 1 |
| 167 |
|
assert fact_refs[0].get("name") == "cpe:/a:machine" |
| 168 |
|
|
| 169 |
|
|
| 170 |
|
def test_platform_from_text_simple_product_cpe(product_cpes): |
|
@@ 189-205 (lines=17) @@
|
| 186 |
|
"cpe:/o:redhat:enterprise_linux:7::workstation" |
| 187 |
|
|
| 188 |
|
|
| 189 |
|
def test_platform_from_text_or(product_cpes): |
| 190 |
|
platform = ssg.build_yaml.Platform.from_text("ntp or chrony", product_cpes) |
| 191 |
|
assert platform.to_bash_conditional() == "( rpm --quiet -q chrony || rpm --quiet -q ntp )" |
| 192 |
|
assert platform.to_ansible_conditional() == \ |
| 193 |
|
"( \"chrony\" in ansible_facts.packages or \"ntp\" in ansible_facts.packages )" |
| 194 |
|
platform_el = ET.fromstring(platform.to_xml_element()) |
| 195 |
|
assert platform_el.tag == "{%s}platform" % cpe_language_namespace |
| 196 |
|
assert platform_el.get("id") == "chrony_or_ntp" |
| 197 |
|
logical_tests = platform_el.findall( |
| 198 |
|
"{%s}logical-test" % cpe_language_namespace) |
| 199 |
|
assert len(logical_tests) == 1 |
| 200 |
|
assert logical_tests[0].get("operator") == "OR" |
| 201 |
|
assert logical_tests[0].get("negate") == "false" |
| 202 |
|
fact_refs = logical_tests[0].findall( |
| 203 |
|
"{%s}fact-ref" % cpe_language_namespace) |
| 204 |
|
assert len(fact_refs) == 2 |
| 205 |
|
assert fact_refs[0].get("name") == "cpe:/a:chrony" |
| 206 |
|
assert fact_refs[1].get("name") == "cpe:/a:ntp" |
| 207 |
|
|
| 208 |
|
|
|
@@ 170-186 (lines=17) @@
|
| 167 |
|
assert fact_refs[0].get("name") == "cpe:/a:machine" |
| 168 |
|
|
| 169 |
|
|
| 170 |
|
def test_platform_from_text_simple_product_cpe(product_cpes): |
| 171 |
|
platform = ssg.build_yaml.Platform.from_text("rhel7-workstation", product_cpes) |
| 172 |
|
assert platform.to_bash_conditional() == "" |
| 173 |
|
assert platform.to_ansible_conditional() == "" |
| 174 |
|
platform_el = ET.fromstring(platform.to_xml_element()) |
| 175 |
|
assert platform_el.tag == "{%s}platform" % cpe_language_namespace |
| 176 |
|
assert platform_el.get("id") == "rhel7-workstation" |
| 177 |
|
logical_tests = platform_el.findall( |
| 178 |
|
"{%s}logical-test" % cpe_language_namespace) |
| 179 |
|
assert len(logical_tests) == 1 |
| 180 |
|
assert logical_tests[0].get("operator") == "AND" |
| 181 |
|
assert logical_tests[0].get("negate") == "false" |
| 182 |
|
fact_refs = logical_tests[0].findall( |
| 183 |
|
"{%s}fact-ref" % cpe_language_namespace) |
| 184 |
|
assert len(fact_refs) == 1 |
| 185 |
|
assert fact_refs[0].get("name") == \ |
| 186 |
|
"cpe:/o:redhat:enterprise_linux:7::workstation" |
| 187 |
|
|
| 188 |
|
|
| 189 |
|
def test_platform_from_text_or(product_cpes): |