Beispiel #1
0
def url_with_origin_validator(node, val):
    """Validate that entered URL can be parsed into a scope"""
    if not group_scope.parse_origin(val):
        raise colander.Invalid(
            node,
            _("Each scope (prefix) must be a complete URL (e.g. 'http://www.example.com' or `https://foo.com/bar`)"
              ),
        )
Beispiel #2
0
def url_with_origin_validator(node, val):
    """Validate that entered URL can be parsed into a scope"""
    if not group_scope.parse_origin(val):
        raise colander.Invalid(
            node,
            _(
                "Each scope (prefix) must be a complete URL (e.g. 'http://www.example.com' or `https://foo.com/bar`)"
            ),
        )
Beispiel #3
0
    def fetch_by_scope(self, url):
        """Return GroupScope records that match the given URL

        :arg url: URL to find matching scopes for
        :type url: str
        :rtype: list(:class:`~h.models.group_scope.GroupScope`)
        """
        origin = scope_util.parse_origin(url)
        if not origin:
            return []
        origin_scopes = (self._session.query(GroupScope).filter(
            GroupScope.origin == origin).all())
        return [
            scope for scope in origin_scopes
            if scope_util.url_in_scope(url, [scope.scope])
        ]
 def test_it_parses_origin_from_url(self, url, expected_origin):
     assert scope_util.parse_origin(url) == expected_origin
Beispiel #5
0
 def test_it_parses_origin_from_url(self, url, expected_origin):
     assert scope_util.parse_origin(url) == expected_origin