Beispiel #1
0
 def _setup(self, filter_=True):
     inst = PathStore("path_policy")
     inst.path_policy = create_mock(["check_filters"])
     if not filter_:
         inst.path_policy.check_filters.side_effect = SCIONPathPolicyViolated()
     pcb = create_mock(["get_hops_hash", "get_timestamp"],
                       class_=PathSegment)
     return inst, pcb
Beispiel #2
0
    def check_filters(self, pcb):
        """
        Runs some checks, including: unwanted ASes and min/max property values.

        :param pcb: beacon to analyze.
        :type pcb: :class:`PathSegment`
        :raises:
            SCIONPathPolicyViolated if any unwanted AS is present or a range is not respected.
        """
        assert isinstance(pcb, PathSegment), type(pcb)
        isd_as = self._check_unwanted_ases(pcb)
        if isd_as:
            raise SCIONPathPolicyViolated("Unwanted AS(%s): %s", isd_as,
                                          pcb.short_desc())
        reasons = self._check_property_ranges(pcb)
        if reasons:
            raise SCIONPathPolicyViolated(", ".join(reasons), pcb.short_desc())
        ia = self._check_remote_ifid(pcb)
        if ia:
            raise SCIONPathPolicyViolated("Remote IFID of %s unknown", ia)