Skip to content

Commit

Permalink
Merge pull request #32 from DMTF/key-fix
Browse files Browse the repository at this point in the history
Fixed mandatory Protocol key, checks for invalid propnames
  • Loading branch information
mraineri authored Mar 15, 2018
2 parents f9a7fbb + d2e726b commit d971439
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions RedfishInteropValidator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
import argparse
from enum import Enum

class sEnum(Enum):
FAIL = 'FAIL'
PASS = 'PASS'
WARN = 'WARN'


rsvLogger = rst.getLogger()

Expand All @@ -46,6 +41,10 @@ def checkProfileAgainstSchema(profile, schema):
# consider @odata.type, with regex
return True

class sEnum(Enum):
FAIL = 'FAIL'
PASS = 'PASS'
WARN = 'WARN'

class msgInterop:
def __init__(self, name, entry, expected, actual, success):
Expand Down Expand Up @@ -87,6 +86,17 @@ def validateRequirement(entry, decodeditem, conditional=False):
paramPass


def isPropertyValid(profilePropName, rObj):
node = rObj.typeobj
while node is not None:
for prop in node.propList:
if profilePropName == prop.propChild:
return None, True
node = node.parent
rsvLogger.error('{} - Does not exist in ResourceType'.format(profilePropName))
return msgInterop('PropertyValidity', profilePropName, 'Should Exist', 'in ResourceType', False), False


def validateMinCount(alist, length, annotation=0):
"""
Validates Mincount annotation
Expand Down Expand Up @@ -448,6 +458,9 @@ def validateInteropResource(propResourceObj, interopDict, decoded):
# problem, unlisted in 0.9.9a
innerDict = interopDict["PropertyRequirements"]
for item in innerDict:
vmsg, isvalid = isPropertyValid(item, propResourceObj)
if not isvalid:
msgs.append(vmsg)
rsvLogger.info('### Validating PropertyRequirements for {}'.format(item))
pmsgs, pcounts = validatePropertyRequirement(
propResourceObj, innerDict[item], (decoded.get(item, 'DNE'), decodedtuple), item)
Expand Down Expand Up @@ -629,7 +642,6 @@ def validateURITree(URI, uriName, profile, expectedType=None, expectedSchema=Non
rmessages = []
rsuccess = True
rerror = io.StringIO()
serviceVersion = profile["Protocol"].get('MinVersion', '1.0.0')

objRes = dict(profile.get('Resources'))

Expand All @@ -638,13 +650,16 @@ def validateURITree(URI, uriName, profile, expectedType=None, expectedSchema=Non
validateSingleURI(URI, profile, uriName, expectedType,
expectedSchema, expectedJson)

msg, mpss = validateMinVersion(thisobj.jsondata.get("RedfishVersion", "0"), serviceVersion)
rmessages.append(msg)

# parent first, then child execution
# do top level root first, then do each child root, then their children...
# hold refs for last (less recursion)
if validateSuccess:
serviceVersion = profile.get("Protocol")
if serviceVersion is not None:
serviceVersion = serviceVersion.get('MinVersion', '1.0.0')
msg, mpss = validateMinVersion(thisobj.jsondata.get("RedfishVersion", "0"), serviceVersion)
rmessages.append(msg)

currentLinks = [(l, links[l], thisobj) for l in links]
while len(currentLinks) > 0:
newLinks = list()
Expand Down

0 comments on commit d971439

Please sign in to comment.