Commit 30208605 authored by Jorge Moratinos's avatar Jorge Moratinos
Browse files

Added new regex type under types

parent c8c610a5
Loading
Loading
Loading
Loading
Loading
+22 −4
Original line number Diff line number Diff line
@@ -70,11 +70,27 @@ def check_variable(input, data_type):
def check_attributes_dict(body, data_type):
    mandatory_attributes = capif_types[data_type]["mandatory_attributes"]
    optional_parameters = capif_types[data_type]["optional_attributes"]
    regex_attributes = capif_types[data_type]["regex_attributes"]

    all_attributes = mandatory_attributes | optional_parameters
    # Check if body has not allowed attributes

    for body_key in body.keys():
        print(body_key)
        if body_key not in all_attributes.keys():
            print(body_key + " NOT IN ALL ATTRIBUTES")
            present = False
            if regex_attributes is not None:
                print("REGEX ATTRIBUTES PRESENT")
                print(regex_attributes)
                for regex_key, regex_data_type in regex_attributes.items():
                    print(regex_key + ":" + regex_data_type)
                    if check_regex(body_key, regex_key):
                        print("MATCH with " + body_key)
                        present = True
                        all_attributes[body_key] = regex_data_type
                        break
            if not present:
                raise Exception('Attribute "' + body_key +
                                '" is not present as a mandatory or optional key (' + ','.join(all_attributes.keys()) + ')')

@@ -116,10 +132,12 @@ def check_uri(input,rule):
    else:
        raise Exception(rule + " is not accomplish rfc3986 rule ("+input+")")


def check_regex(input, regex):
    matched = re.match(regex, input)
    is_match = bool(matched)
    if is_match:
        print("Regex match")
        return True
    else:
        raise Exception("Input(" + input + ") not match regex (" + regex + ")")
+6 −0
Original line number Diff line number Diff line
@@ -83,8 +83,14 @@
      "apiSuppFeats": "SupportedFeatures",
      "pubApiPath": "PublishedApiPath",
      "ccfId": "string"
    },
    "regex_attributes": {
      "^vendorSpecific-(.*)": "VendorSpecificObject"
    }
  },
  "VendorSpecificObject": {
    "Check": false
  },
  "AefProfile": {
    "mandatory_attributes": {
      "aefId": "string",