HIRS/.ci/setup/addFaultyComponents.py
busaboy1340 440bb06b70
Create initial system test for Base/Delta Platform Certificates ()
* Add creation of bad base platform certificate.

* Adding Base Certificate system test.

* Adding Base Certificate system test.

* Adding Base Certificate system test.

* Adding Base Certificate system test.

* Updated script to add faulty components to bad base certificate.

* Updated addFaultyComponents script.

* Add Base/Delta system tests to .travis.yml

* Disable unit tests to decrease CI time.

* Cleaned up code.

* Cleaned up code.

* Delete system_test_Driver.py
2019-07-19 05:50:26 -04:00

29 lines
863 B
Python

# Add faulty components to the PACCOR generated JSON componentsFile.
# This will be used to create a bad platform certificate.
# Will not need this once PACCOR supports generation of faulty components.
import json
print("Adding Faulty components...")
try:
nicComponent = '00090002'
pc_dir = '/var/hirs/pc_generation/'
with open(pc_dir + "componentsFile", "r") as f:
data = json.load(f)
print(data)
components = data['COMPONENTS']
for component in components:
if component['COMPONENTCLASS']['COMPONENTCLASSVALUE'] == nicComponent:
print("Creating FAULTY component for: " + component['MODEL'])
component['MODEL'] += "-FAULTY"
print("New JSON value: " + component['MODEL'])
with open(pc_dir + "badComponentsFile", 'w') as outfile:
json.dump(data, outfile)
except Exception:
print("=== ERROR generating badComponentsFile ===")