HIRS/.ci/setup/addFaultyComponents.py
busaboy1340 4b4f811735
[#176] Initial delta system test to resolve bad component in a base certificate (#177)
* Add Base/Delta to .travis.yml

* Implement Delta system test.

* Removed un-needed scripts.

* Update system_test_Driver.py
2019-08-02 12:39:56 -04:00

28 lines
820 B
Python

# Add faulty components to the PACCOR generated JSON componentsFile.
# This will be used to create a bad platform certificate.
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 + "PBaseCertB.json", 'w') as outfile:
json.dump(data, outfile)
except Exception as ex:
print "=== ERROR generating PBaseCertB.json ===: error({0})".format(ex.message)