コード例 #1
0
def test_simple_uri_comparision(uri):
    u1 = URI(b'http://abc.com:80/~smith/home.html')
    u2 = URI(b'http://ABC.com/%7Esmith/home.html')
    u3 = URI(b'http://ABC.com:/%7esmith/home.html')
    u4 = URI(b'http://ABC.com:/%7esmith/./home.html')
    u5 = URI(b'http://ABC.com:/%7esmith/foo/../home.html')
    assert u1 == u2
    assert u2 == u3
    assert u1 == u3
    assert u1 == u4
    assert u1 == u5
コード例 #2
0
ファイル: test_uri_query.py プロジェクト: spaceone/httoop
def test_urlencode_object():
	class Trivial(object):
		def __str__(self):
			return 'trivial'

		def __unicode__(self):
			return u'trivial'

		def __bytes__(self):
			return b'trivial'

	u = URI()
	u.query = {u'a': Trivial()}
	assert u.query_string == b'a=trivial'
コード例 #3
0
ファイル: test_uri_query.py プロジェクト: vermuz/httoop
def test_urlencode_object():
    class Trivial(object):
        def __str__(self):
            return 'trivial'

        def __unicode__(self):
            return u'trivial'

        def __bytes__(self):
            return b'trivial'

    u = URI()
    u.query = {u'a': Trivial()}
    assert u.query_string == b'a=trivial'
コード例 #4
0
ファイル: test_uri_query.py プロジェクト: spaceone/httoop
def test_urlencode_object():
    class Trivial(object):
        def __str__(self):
            return "trivial"

        def __unicode__(self):
            return u"trivial"

        def __bytes__(self):
            return b"trivial"

    u = URI()
    u.query = {u"a": Trivial()}
    assert u.query_string == b"a=trivial"
コード例 #5
0
ファイル: test_uri_abspath.py プロジェクト: vermuz/httoop
def test_abspath(url, expected):
	uri = URI()
	uri.parse(url)
	uri.abspath()
	assert uri.tuple == expected
	uri.normalize()
	assert uri.tuple == expected
コード例 #6
0
 def add_sockets(self):
     if not self.arguments.bind:
         if self.arguments.wsgi:
             return
         import warnings
         warnings.warn('No socket to bind to. Use --bind.', RuntimeWarning)
     for bind in self.arguments.bind:
         self.add_socket(URI(bind))
コード例 #7
0
ファイル: domain.py プロジェクト: spaceone/circuits.http
 def url(self, client, *path):
     uri = URI(scheme=client.request.uri.scheme,
               host=self.fqdn,
               port=client.server.port)
     uri2 = URI()
     uri2.path_segments = path
     uri.join(uri2)
     return uri
コード例 #8
0
	def select_service_provider(self, client):
		"""Select the URI of the requested assertion consumer service and the reply binding which should be used.
			If tries to preserve the current request scheme (HTTP / HTTPS) and picks the same netloc (host or IP).
			If nothing is found for this it falls back to the regular full qualified host name of the service provider.

			Returns (binding, service-provider-URI)
		"""
		acs = self.sp.config.getattr("endpoints", "sp")["assertion_consumer_service"]
		service_url, reply_binding = acs[0]
		netloc = False
		p2 = client.request.uri
		for _url, _binding in acs:
			p1 = URI(_url)
			if p1.scheme == p2.scheme and p1.netloc == p2.netloc:
				netloc = True
				service_url, reply_binding = _url, _binding
				if p1.path == p2.path:
					break
			elif not netloc and p1.netloc == p2.netloc:
				service_url, reply_binding = _url, _binding
		return reply_binding, service_url
コード例 #9
0
ファイル: test_uri_query.py プロジェクト: vermuz/httoop
def test_parse_encodings(query_string, encoding, query):
    u = URI()
    u.encoding = encoding
    u.parse(b'http://example.com/?%s' % (query_string, ))
    assert u.query == tuple(query)
コード例 #10
0
ファイル: test_uri_schemes.py プロジェクト: vermuz/httoop
def test_parse_scheme(url, expected):
	uri = URI(url)
	assert uri.tuple == expected
	assert bytes(uri) == bytes(URI(expected))
コード例 #11
0
ファイル: test_uri_query.py プロジェクト: vermuz/httoop
def test_urlencode_sequences():
    u = URI()
    u.query = {'a': [1, 2], 'b': (3, 4, 5)}
    assert set(u.query_string.split(b'&')) == {
        b'a=1', b'a=2', b'b=3', b'b=4', b'b=5'
    }
コード例 #12
0
ファイル: test_uri_query.py プロジェクト: spaceone/httoop
def test_urlencode_sequences():
	u = URI()
	u.query = {'a': [1, 2], 'b': (3, 4, 5)}
	assert set(u.query_string.split(b'&')) == {b'a=1', b'a=2', b'b=3', b'b=4', b'b=5'}
コード例 #13
0
ファイル: test_uri_parsing.py プロジェクト: vermuz/httoop
def test_parse_invalid_netloc(url):
    with pytest.raises(InvalidURI):
        URI(url)
コード例 #14
0
ファイル: test_uri_query.py プロジェクト: vermuz/httoop
def test_query_string_compose(query_string, query):
    uri = URI(b'http://example.com/')
    uri.query = query
    assert uri.query_string == query_string
コード例 #15
0
ファイル: test_uri_query.py プロジェクト: spaceone/httoop
def test_parse_encodings(query_string, encoding, query):
    u = URI()
    u.encoding = encoding
    u.parse(b"http://example.com/?%s" % (query_string,))
    assert u.query == tuple(query)
コード例 #16
0
 def redirect_alias(self, domain, client):
     path = URI(client.request.uri)
     path.host = domain.fqdn
     raise MOVED_PERMANENTLY(path)
コード例 #17
0
ファイル: test_uri_parsing.py プロジェクト: vermuz/httoop
def test_ipvfuture(url, hostname, port):
    url = URI(url)
    assert url.hostname == hostname
コード例 #18
0
ファイル: test_uri_parsing.py プロジェクト: vermuz/httoop
def test_rfc2732(url, hostname, port):
    url = URI(url)
    assert url.hostname == hostname
    assert url.port == port
コード例 #19
0
ファイル: test_uri_parsing.py プロジェクト: vermuz/httoop
def test_unparse_parse(u):
    assert bytes(URI(u)) == u
コード例 #20
0
ファイル: domain.py プロジェクト: spaceone/circuits.http
	def url(self, client, *path):
		uri = URI(scheme=client.request.uri.scheme, host=self.fqdn, port=client.server.port)
		uri2 = URI()
		uri2.path_segments = path
		uri.join(uri2)
		return uri
コード例 #21
0
ファイル: test_uri_query.py プロジェクト: vermuz/httoop
def test_query_string_parse(query_string, query):
    uri = URI(b'http://example.com/?%s' % (query_string, ))
    assert uri.query == query
コード例 #22
0
ファイル: test_uri_query.py プロジェクト: spaceone/httoop
def test_query_string_compose(query_string, query):
    uri = URI(b"http://example.com/")
    uri.query = query
    assert uri.query_string == query_string
コード例 #23
0
def test_uri_join_very_strict(base, relative, expected):
	uri = URI(base).join(relative)
	assert bytes(uri) == bytes(expected)
コード例 #24
0
ファイル: test_uri_query.py プロジェクト: spaceone/httoop
def test_urlencode_sequences():
    u = URI()
    u.query = {"a": [1, 2], "b": (3, 4, 5)}
    assert set(u.query_string.split(b"&")) == {b"a=1", b"a=2", b"b=3", b"b=4", b"b=5"}
コード例 #25
0
ファイル: domain.py プロジェクト: spaceone/circuits.http
	def redirect_alias(self, domain, client):
		path = URI(client.request.uri)
		path.host = domain.fqdn
		raise MOVED_PERMANENTLY(path)
コード例 #26
0
ファイル: test_uri_comparision.py プロジェクト: vermuz/httoop
def test_scheme_difference():
    assert URI(b'http://foo.example:1/') != URI(b'ftp://foo.example:1/')
    assert URI(b'http://foo.example:1/') != b'ftp://foo.example:1'
    assert URI(b'ftp://foo.example:1/') != b'http://foo.example:1'
コード例 #27
0
ファイル: test_uri_parsing.py プロジェクト: vermuz/httoop
def test_parse_absolute_uri(url, expected):
    uri = URI()
    uri.parse(url)
    assert uri.tuple == expected
コード例 #28
0
ファイル: test_uri_parsing.py プロジェクト: spaceone/httoop
def test_parse_absolute_uri(url, expected):
	uri = URI()
	uri.parse(url)
	assert uri.tuple == expected
コード例 #29
0
def test_uri_join(base, relative, expected):
	uri = URI(base).join(relative)
	assert uri == expected