Ejemplo n.º 1
0
 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,
         )
Ejemplo n.º 2
0
 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,
         )
Ejemplo n.º 3
0
 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,
         )
Ejemplo n.º 4
0
 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,
         )
Ejemplo n.º 5
0
 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,
         )
Ejemplo n.º 6
0
 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,
         )
Ejemplo n.º 7
0
 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,
         )
Ejemplo n.º 8
0
 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,
         )
Ejemplo n.º 9
0
 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,
         )
Ejemplo n.º 10
0
 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,
         )
Ejemplo n.º 11
0
    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
            )