diff --git a/RedfishInteropValidator.py b/RedfishInteropValidator.py index ed0caaf..2762fa5 100644 --- a/RedfishInteropValidator.py +++ b/RedfishInteropValidator.py @@ -346,7 +346,7 @@ def validateURITree(URI, uriName, profile, expectedType=None, expectedSchema=Non ############################################################# -validatorconfig = {'payloadmode': 'Default', 'payloadfilepath': None, 'logpath': './logs'} +validatorconfig = {'payloadmode': 'Default', 'payloadfilepath': None, 'logpath': './logs', 'writecheck': False} def main(arglist=None, direct_parser=None): """ @@ -399,6 +399,8 @@ def main(arglist=None, direct_parser=None): argget.add_argument('profile', type=str, default='sample.json', help='interop profile with which to validate service against') argget.add_argument('--schema', type=str, default=None, help='schema with which to validate interop profile against') argget.add_argument('--warnrecommended', action='store_true', help='warn on recommended instead of pass') + # todo: write patches + argget.add_argument('--writecheck', action='store_true', help='(unimplemented) specify to allow WriteRequirement checks') args = argget.parse_args(arglist) @@ -427,6 +429,8 @@ def main(arglist=None, direct_parser=None): # Set interop config items config['WarnRecommended'] = rst.config.get('warnrecommended', args.warnrecommended) commonInterop.config['WarnRecommended'] = config['WarnRecommended'] + config['WriteCheck'] = rst.config.get('writecheck', args.writecheck) + commonInterop.config['WriteCheck'] = config['WriteCheck'] config['profile'] = args.profile config['schema'] = args.schema diff --git a/commonInterop.py b/commonInterop.py index b7ec31c..32d8af0 100644 --- a/commonInterop.py +++ b/commonInterop.py @@ -9,7 +9,7 @@ rsvLogger = rst.getLogger() -config = {'WarnRecommended': False} +config = {'WarnRecommended': False, 'WriteCheck': False} class sEnum(Enum): @@ -113,6 +113,10 @@ def validateWriteRequirement(propObj, entry, itemname): rsvLogger.info('writeable \n\t' + str(entry)) permission = 'Read' expected = "OData.Permission/ReadWrite" if entry else "Any" + if not config['WriteCheck']: + paramPass = True + return msgInterop('WriteRequirement', entry, expected, permission, paramPass),\ + paramPass if entry: targetProp = findPropItemforString(propObj, itemname.replace('#', '')) propAttr = None @@ -175,22 +179,30 @@ def checkComparison(val, compareType, target): else: paramPass = False - if compareType == "Equal": - paramPass = val == target - if compareType == "NotEqual": - paramPass = val != target - if compareType == "GreaterThan": - paramPass = val > target - if compareType == "GreaterThanOrEqual": - paramPass = val >= target - if compareType == "LessThan": - paramPass = val < target - if compareType == "LessThanOrEqual": - paramPass = val <= target if compareType == "Absent": paramPass = val == 'DNE' if compareType == "Present": paramPass = val != 'DNE' + + if isinstance(target, list): + if len(target) >= 1: + target = target[0] + else: + target = 'DNE' + + if target != 'DNE': + if compareType == "Equal": + paramPass = val == target + if compareType == "NotEqual": + paramPass = val != target + if compareType == "GreaterThan": + paramPass = val > target + if compareType == "GreaterThanOrEqual": + paramPass = val >= target + if compareType == "LessThan": + paramPass = val < target + if compareType == "LessThanOrEqual": + paramPass = val <= target rsvLogger.info('\tpass ' + str(paramPass)) if not paramPass: rsvLogger.error('\tNoPass')