Skip to content

Commit

Permalink
Add testcase for new command fwupdmgr
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoxue Wang <[email protected]>
  • Loading branch information
JoySnow committed Dec 20, 2024
1 parent d969940 commit b159247
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions insights/tests/parsers/test_fwupdagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,32 @@
}
"""

SECURITY_FWUPDMGR = """
WARNING: UEFI firmware can not be updated in legacy BIOS mode
See https://github.com/fwupd/fwupd/wiki/PluginFlag:legacy-bios for more information.
{
"HostSecurityAttributes" : [
{
"AppstreamId" : "org.fwupd.hsi.Kernel.Tainted",
"HsiResult" : "not-tainted",
"Name" : "Linux kernel",
"Uri" : "https://fwupd.github.io/hsi.html#org.fwupd.hsi.Kernel.Tainted",
"Flags" : [
"success",
"runtime-issue"
]
},
{
"AppstreamId" : "org.fwupd.hsi.EncryptedRam",
"HsiLevel" : 4,
"HsiResult" : "not-supported",
"Name" : "Encrypted RAM",
"Uri" : "https://fwupd.github.io/hsi.html#org.fwupd.hsi.EncryptedRam"
}
]
}
"""

SECURITY_ERROR_1 = """
Failed to parse arguments: Unknown option --force
"""
Expand Down Expand Up @@ -169,6 +195,13 @@ def test_security():
assert security["HostSecurityAttributes"][1]["Name"] == "Encrypted RAM"
assert security["HostSecurityAttributes"][1]["HsiLevel"] == 4

security = FwupdagentSecurity(context_wrap(SECURITY_FWUPDMGR))
assert len(security["HostSecurityAttributes"]) == 2
assert security["HostSecurityAttributes"][0]["Name"] == "Linux kernel"
assert security["HostSecurityAttributes"][0]["HsiResult"] == "not-tainted"
assert security["HostSecurityAttributes"][1]["Name"] == "Encrypted RAM"
assert security["HostSecurityAttributes"][1]["HsiLevel"] == 4

with pytest.raises(ParseException):
FwupdagentSecurity(context_wrap(SECURITY_ERROR_1))

Expand Down

0 comments on commit b159247

Please sign in to comment.