def _validate_schema_primary(self): if not isinstance(self.primary, bool): raise scim_exceptions.ModelAttributeCharacteristicNotAllowedException( locator_path=self._locator_path, attribute_name="primary", expected="a boolean", actual=self.primary, )
def _validate_schema_ref(self): if not isinstance(self.ref, (str, text_type)): raise scim_exceptions.ModelAttributeCharacteristicNotAllowedException( locator_path=self.display, attribute_name="ref", expected="a human-readable name (string)", actual=self.ref, )
def _validate_schema_case_exact(self): if self.caseExact not in self._accepted_case_exact_value: raise scim_exceptions.ModelAttributeCharacteristicNotAllowedException( locator_path=self._locator_path, attribute_name="caseExact", expected=self._accepted_case_exact_value, actual=self.caseExact, )
def _validate_schema_type(self): if not isinstance(self.type, (str, text_type)): raise scim_exceptions.ModelAttributeCharacteristicNotAllowedException( locator_path=self._locator_path, attribute_name="type", expected="a string", actual=self.value, )
def _validate_schema_uniqueness(self): if self.uniqueness not in self._accepted_uniqueness_value: raise scim_exceptions.ModelAttributeCharacteristicNotAllowedException( locator_path=self._locator_path, attribute_name="uniqueness_value", expected=self._accepted_uniqueness_value, actual=self.uniqueness, )
def _validate_schema_required(self): if not isinstance(self.required, bool): raise scim_exceptions.ModelAttributeCharacteristicNotAllowedException( locator_path=self._locator_path, attribute_name="required", expected="boolean", actual=self.required, )
def _validate_schema_returned(self): expected_values = {"default", "always", "never", "request"} if self.returned not in expected_values: raise scim_exceptions.ModelAttributeCharacteristicNotAllowedException( locator_path=self._locator_path, attribute_name="returned", expected=expected_values, actual=self.returned, )
def _validate_schema_mutability(self): # https://tools.ietf.org/html/rfc7643#section-7 expected_values = {"readWrite", "readOnly", "immutable", "writeOnly"} if self.mutability not in expected_values: raise scim_exceptions.ModelAttributeCharacteristicNotAllowedException( locator_path=self._locator_path, attribute_name="mutability", expected=expected_values, actual=self.mutability, )
def _validate_schema_canonical_values(self): if self.canonicalValues is not None and not isinstance( self.canonicalValues, list ): raise scim_exceptions.ModelAttributeCharacteristicNotAllowedException( locator_path=self._locator_path, attribute_name="canonicalValues", expected="none or valid list", actual=self.canonicalValues, )
def _validate_schema_name(self): msg = ( "valid name e.g. must be ALPHA * {{nameChar}} where nameChar " '= "$" / "-" / "_" / DIGIT / ALPHA' ) # ^[a-zA-Z] - starts with ALPHA 0...many # (\$|\-|_|\w)$ - ends with $ - _ alphanumeric if self.name is None or not bool( re.match(r"^[a-zA-Z](\$|-|_|\w)*$", self.name) ): raise scim_exceptions.ModelAttributeCharacteristicNotAllowedException( locator_path=self._locator_path, attribute_name="name", expected=msg, actual=self.name, )
def validate_schema(self): if self._is_parent_complex: # sub attribute of complex cannot be complex raise scim_exceptions.ModelAttributeCharacteristicNotAllowedException( locator_path=self._locator_path, attribute_name=self.name, expected="simple type sub-attribute", actual="complex type sub-attribute on a complex parent", ) super(ComplexAttribute, self).validate_schema() exceptions = [] for sa in self.subAttributes: try: sa.validate_schema() except AssertionError as ae: exceptions.append(ae) if exceptions: scim_exceptions.AggregatedScimSchemaExceptions( self._locator_path, exceptions=exceptions )