How to use the rfc3986.uri_reference function in rfc3986

To help you get started, we’ve selected a few rfc3986 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-hyper / rfc3986 / tests / test_validators.py View on Github external
        rfc3986.uri_reference("https://gitlab.com/sigmavirus24"),
        rfc3986.uri_reference("ssh://gitlab.com/sigmavirus24"),
        rfc3986.uri_reference("ssh://ssh@gitlab.com:22/sigmavirus24"),
        rfc3986.uri_reference("https://gitlab.com:443/sigmavirus24"),
        rfc3986.uri_reference("https://bitbucket.org/sigmavirus24"),
        rfc3986.uri_reference("ssh://bitbucket.org/sigmavirus24"),
        rfc3986.uri_reference("ssh://ssh@bitbucket.org:22/sigmavirus24"),
        rfc3986.uri_reference("https://bitbucket.org:443/sigmavirus24"),
        rfc3986.uri_reference("https://git.openstack.org/sigmavirus24"),
        rfc3986.uri_reference("ssh://git.openstack.org/sigmavirus24"),
        rfc3986.uri_reference("ssh://ssh@git.openstack.org:22/sigmavirus24"),
        rfc3986.uri_reference("https://git.openstack.org:443/sigmavirus24"),
        rfc3986.uri_reference(
            "ssh://ssh@git.openstack.org:22/sigmavirus24?foo=bar#fragment"
        ),
        rfc3986.uri_reference(
            "ssh://git.openstack.org:22/sigmavirus24?foo=bar#fragment"
github python-hyper / rfc3986 / tests / test_builder.py View on Github external
def test_extend_query_with(uri, extend_with, expected_query):
    """Verify the behaviour of extend_query_with."""
    uribuilder = (
        builder.URIBuilder()
        .from_uri(uri_reference(uri))
        .extend_query_with(extend_with)
    )
    assert parse_qs(uribuilder.query) == expected_query
github python-hyper / rfc3986 / tests / test_validators.py View on Github external
        rfc3986.uri_reference("//google.com"),
        rfc3986.uri_reference("//google.com?query=value"),
        rfc3986.uri_reference("//google.com#fragment"),
    ],
)
def test_multiple_missing_components(uri):
    """Verify that multiple missing components are caught."""
    validator = validators.Validator().require_presence_of("scheme", "path")
    with pytest.raises(exceptions.MissingComponentError) as captured_exc:
        validator.validate(uri)
    exception = captured_exc.value
    assert 2 == len(exception.args[-1])
github python-hyper / rfc3986 / tests / test_unicode_support.py View on Github external
def test_unicode_authority():
    url_bytestring = SNOWMAN_HOST
    unicode_url = url_bytestring.decode("utf-8")
    uri = uri_reference(unicode_url)
    assert uri.is_valid() is False
    assert uri == unicode_url
github python-hyper / rfc3986 / tests / test_validators.py View on Github external
        rfc3986.uri_reference("//user@github.com"),
        rfc3986.uri_reference("//github.com"),
        rfc3986.uri_reference("https://github.com"),
    ],
)
def test_passwordless_uris_pass_validation(uri):
    """Verify password-less URLs validate properly."""
    validator = validators.Validator().forbid_use_of_password()
    validator.validate(uri)
github python-hyper / rfc3986 / tests / test_validators.py View on Github external
        rfc3986.uri_reference("ssh://git.openstack.org:22/#fragment"),
        rfc3986.uri_reference("ssh://git.openstack.org:22/"),
        rfc3986.uri_reference(
            "ssh://ssh@git.openstack.org:22/?foo=bar#fragment"
        ),
        rfc3986.uri_reference(
            "ssh://ssh@git.openstack.org:22/sigmavirus24#fragment"
        ),
        rfc3986.uri_reference("ssh://ssh@git.openstack.org:22/#fragment"),
        rfc3986.uri_reference("ssh://ssh@git.openstack.org:22/"),
    ],
)
def test_successful_complex_validation(uri):
    """Verify we do not raise ValidationErrors for good URIs."""
    validators.Validator().allow_schemes("https", "ssh",).allow_hosts(
        "github.com", "bitbucket.org", "gitlab.com", "git.openstack.org",
    ).allow_ports("22", "443",).require_presence_of(
github python-hyper / rfc3986 / tests / test_validators.py View on Github external
def test_validating_rfc_4007_ipv6_zone_ids():
    """Verify that RFC 4007 IPv6 Zone IDs are invalid
    host/authority but after normalization are valid
    """
    uri = rfc3986.uri_reference("http://[::1%eth0]")
    with pytest.raises(exceptions.InvalidComponentsError):
        validators.Validator().check_validity_of("host").validate(uri)

    uri = uri.normalize()
    assert uri.host == "[::1%25eth0]"

    validators.Validator().check_validity_of("host").validate(uri)
github python-hyper / rfc3986 / tests / test_validators.py View on Github external
        rfc3986.uri_reference("ssh://git.openstack.org:22/"),
        rfc3986.uri_reference(
            "ssh://ssh@git.openstack.org:22/?foo=bar#fragment"
        ),
        rfc3986.uri_reference(
            "ssh://ssh@git.openstack.org:22/sigmavirus24#fragment"
        ),
        rfc3986.uri_reference("ssh://ssh@git.openstack.org:22/#fragment"),
        rfc3986.uri_reference("ssh://ssh@git.openstack.org:22/"),
    ],
)
def test_successful_complex_validation(uri):
    """Verify we do not raise ValidationErrors for good URIs."""
    validators.Validator().allow_schemes("https", "ssh",).allow_hosts(
        "github.com", "bitbucket.org", "gitlab.com", "git.openstack.org",
    ).allow_ports("22", "443",).require_presence_of(
        "scheme", "host", "path",
github OCA / pylint-odoo / pylint_odoo / checkers / no_modules.py View on Github external
self.add_message('manifest-version-format', node=node,
                             args=(version_format,
                                   self.config.manifest_version_format_parsed))

        # Check if resource exist
        dirname = os.path.dirname(self.linter.current_file)
        for key in DFTL_MANIFEST_DATA_KEYS:
            for resource in (manifest_dict.get(key) or []):
                if os.path.isfile(os.path.join(dirname, resource)):
                    continue
                self.add_message('resource-not-exist', node=node,
                                 args=(key, resource))

        # Check if the website is valid URI
        website = manifest_dict.get('website', '')
        uri = rfc3986.uri_reference(website)
        if ((website and ',' not in website) and
                (not uri.is_valid(require_scheme=True,
                                  require_authority=True) or
                 uri.scheme not in {"http", "https"})):
            self.add_message('website-manifest-key-not-valid-uri',
                             node=node, args=(website))

        # Check valid development_status values
        dev_status = manifest_dict.get('development_status')
        if (dev_status and
                dev_status not in self.config.development_status_allowed):
            self.add_message('development-status-allowed',
                             node=node, args=(dev_status,))
github openstack / oslo.config / oslo_config / types.py View on Github external
def __call__(self, value):
        uri = rfc3986.uri_reference(value)
        validator = rfc3986.validators.Validator().require_presence_of(
            'scheme', 'host',
        ).check_validity_of(
            'scheme', 'host', 'path',
        )
        if self.schemes:
            validator = validator.allow_schemes(*self.schemes)
        try:
            validator.validate(uri)
        except rfc3986.exceptions.RFC3986Exception as exc:
            raise ValueError(exc)

        if self.max_length is not None and len(value) > self.max_length:
            raise ValueError("Value '%s' exceeds maximum length %d" %
                             (value, self.max_length))