Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: Add more negative test cases in CI #150

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions sh_script/build_final.sh
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,22 @@ function final_test_migtd() {
enroll "migtd_src_sb14.bin" "policy_006.json" "migtd_src_014.bin"
enroll "migtd_dst_sb14.bin" "policy_006.json" "migtd_dst_014.bin"

echo "-- Build final binary for test case 015 of migration TD"
# Test operation "array-equal", sgxtcbcomponents is no equal with reference
enroll "migtd_sb1.bin" "policy_007.json" "migtd_015.bin"

echo "-- Build final binary for test case 016 of migration TD"
# Test operation "array-greater-or-equal", sgxtcbcomponents is smaller than reference
enroll "migtd_sb1.bin" "policy_008.json" "migtd_016.bin"

echo "-- Build final binary for test case 017 of migration TD"
# Test polciy content is not correct, "fmspcx" shall be "fmspc"
enroll "migtd_sb1.bin" "policy_009.json" "migtd_017.bin"

echo "-- Build final binary for test case 018 of migration TD"
# Test polciy file does not contain actual platforms' fmspc
enroll "migtd_sb1.bin" "policy_010.json" "migtd_018.bin"

cleanup
build_migtd
build_tdshim
Expand Down
82 changes: 81 additions & 1 deletion sh_script/test/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,86 @@ def test_negative_014(device_type):

ctx.terminate_all_tds()
ctx.terminate_socat()

"""
Migration Policy Check:
Test operation "array-equal", sgxtcbcomponents is no equal with reference
"""
def test_negative_015(device_type):
migtd_src = "../../Bin/migtd_015.bin"
migtd_dst = "../../Bin/migtd_015.bin"

with migtd_context() as ctx:
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
ctx.start_user_td(type="src")
ctx.start_user_td(type="dst")
ctx.connect()
ctx.pre_migration()
ctx.check_migration_result(negative=True)

ctx.terminate_all_tds()
ctx.terminate_socat()

"""
Migration Policy Check:
Test operation "array-greater-or-equal", sgxtcbcomponents is smaller than reference
"""
def test_negative_016(device_type):
migtd_src = "../../Bin/migtd_016.bin"
migtd_dst = "../../Bin/migtd_016.bin"

with migtd_context() as ctx:
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
ctx.start_user_td(type="src")
ctx.start_user_td(type="dst")
ctx.connect()
ctx.pre_migration()
ctx.check_migration_result(negative=True)

ctx.terminate_all_tds()
ctx.terminate_socat()

"""
Migration Policy Check:
# Test polciy content is not correct, "fmspcx" shall be "fmspc"
"""
def test_negative_017(device_type):
migtd_src = "../../Bin/migtd_017.bin"
migtd_dst = "../../Bin/migtd_017.bin"

with migtd_context() as ctx:
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
ctx.start_user_td(type="src")
ctx.start_user_td(type="dst")
ctx.connect()
ctx.pre_migration()
ctx.check_migration_result(negative=True)

ctx.terminate_all_tds()
ctx.terminate_socat()

"""
Migration Policy Check:
# Test polciy file does not contain actual platforms' fmspc
"""
def test_negative_018(device_type):
migtd_src = "../../Bin/migtd_018.bin"
migtd_dst = "../../Bin/migtd_018.bin"

with migtd_context() as ctx:
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
ctx.start_user_td(type="src")
ctx.start_user_td(type="dst")
ctx.connect()
ctx.pre_migration()
ctx.check_migration_result(negative=True)

ctx.terminate_all_tds()
ctx.terminate_socat()

"""
Test TD payload:
Expand All @@ -306,7 +386,7 @@ def test_negative_014(device_type):
- Quote Sevice Query
- Quote Attestation
"""
def test_function_015(device_type):
def test_function_000(device_type):
test_bin = "../../Bin/final-test.bin"

with migtd_context() as ctx:
Expand Down
6 changes: 5 additions & 1 deletion src/policy/test/policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
| [policy_003.json](./policy_003.json) | Test "Digest.MigTdPolicy" with different policy files |
| [policy_004.json](./policy_004.json) | Test secure boot, check svn whether in 13... |
| [policy_005.json](./policy_005.json) | Invalid json |
| [policy_006.json](./policy_006.json) | Test operator 'greater or equal' with Digest.MigTdCoreSvn |
| [policy_006.json](./policy_006.json) | Test operator 'greater or equal' with Digest.MigTdCoreSvn |
| [policy_007.json](./policy_007.json) | Test operator 'array-equal' with sgxtcbcomponents, not equal |
| [policy_008.json](./policy_008.json) | Test operator 'array-greater-or-equal' with sgxtcbcomponents, smaller than refernce |
| [policy_009.json](./policy_009.json) | Invalid section name "fmspcx", correct name is "fmspc" |
| [policy_010.json](./policy_010.json) | Actual "fmspc" is no in policy fmspc list |
102 changes: 102 additions & 0 deletions src/policy/test/policy_007.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"id": "1CECB0F4-6411-492D-8834-F097F960DE07",
"policy": [
{
"fmspc": "30806F000000",
"Platform": {
"TcbInfo": {
"sgxtcbcomponents": {
"operation": "array-equal",
"reference": [0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
},
"pcesvn": {
"operation": "equal",
"reference": 11
},
"tdxtcbcomponents": {
"operation": "array-greater-or-equal",
"reference": [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0]
}
}
}
},
{
"QE": {
"QeIdentity": {
"MISCSELECT": {
"operation": "equal",
"reference": "00000000"
}
}
}
},
{
"TDXModule": {
"TDXModule_Identity": {
"TDXModuleMajorVersion": {
"operation": "equal",
"reference": 1
},
"TDXModuleSVN": {
"operation": "equal",
"reference": 0
},
"MRSIGNERSEAM": {
"operation": "equal",
"reference": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
},
"ATTRIBUTES": {
"operation": "equal",
"reference": "0000000000000000"
}
}
}
},
{
"MigTD": {
"TDINFO": {
"ATTRIBUTES": {
"operation": "equal",
"reference": "self"
},
"XFAM": {
"operation": "equal",
"reference": "self"
},
"MRTD": {
"operation": "equal",
"reference": "self"
},
"MRCONFIGID": {
"operation": "equal",
"reference": "self"
},
"MROWNER": {
"operation": "equal",
"reference": "self"
},
"MROWNERCONFIG": {
"operation": "equal",
"reference": "self"
},
"RTMR0": {
"operation": "equal",
"reference": "self"
},
"RTMR1": {
"operation": "equal",
"reference": "self"
},
"RTMR2": {
"operation": "equal",
"reference": "self"
},
"RTMR3": {
"operation": "equal",
"reference": "self"
}
}
}
}
]
}
102 changes: 102 additions & 0 deletions src/policy/test/policy_008.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"id": "1CECB0F4-6411-492D-8834-F097F960DE07",
"policy": [
{
"fmspc": "30806F000000",
"Platform": {
"TcbInfo": {
"sgxtcbcomponents": {
"operation": "array-greater-or-equal",
"reference": [1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0]
},
"pcesvn": {
"operation": "equal",
"reference": 11
},
"tdxtcbcomponents": {
"operation": "array-greater-or-equal",
"reference": [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0]
}
}
}
},
{
"QE": {
"QeIdentity": {
"MISCSELECT": {
"operation": "equal",
"reference": "00000000"
}
}
}
},
{
"TDXModule": {
"TDXModule_Identity": {
"TDXModuleMajorVersion": {
"operation": "equal",
"reference": 1
},
"TDXModuleSVN": {
"operation": "equal",
"reference": 0
},
"MRSIGNERSEAM": {
"operation": "equal",
"reference": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
},
"ATTRIBUTES": {
"operation": "equal",
"reference": "0000000000000000"
}
}
}
},
{
"MigTD": {
"TDINFO": {
"ATTRIBUTES": {
"operation": "equal",
"reference": "self"
},
"XFAM": {
"operation": "equal",
"reference": "self"
},
"MRTD": {
"operation": "equal",
"reference": "self"
},
"MRCONFIGID": {
"operation": "equal",
"reference": "self"
},
"MROWNER": {
"operation": "equal",
"reference": "self"
},
"MROWNERCONFIG": {
"operation": "equal",
"reference": "self"
},
"RTMR0": {
"operation": "equal",
"reference": "self"
},
"RTMR1": {
"operation": "equal",
"reference": "self"
},
"RTMR2": {
"operation": "equal",
"reference": "self"
},
"RTMR3": {
"operation": "equal",
"reference": "self"
}
}
}
}
]
}
Loading
Loading