Пример #1
0
def test_path_info_extraction():
    x = wsgi.extract_path_info('http://example.com/app', '/app/hello')
    assert x == u'/hello'
    x = wsgi.extract_path_info('http://example.com/app',
                               'https://example.com/app/hello')
    assert x == u'/hello'
    x = wsgi.extract_path_info('http://example.com/app/',
                               'https://example.com/app/hello')
    assert x == u'/hello'
    x = wsgi.extract_path_info('http://example.com/app/',
                               'https://example.com/app')
    assert x == u'/'
    x = wsgi.extract_path_info(u'http://☃.net/', u'/fööbär')
    assert x == u'/fööbär'
    x = wsgi.extract_path_info(u'http://☃.net/x', u'http://☃.net/x/fööbär')
    assert x == u'/fööbär'

    env = create_environ(u'/fööbär', u'http://☃.net/x/')
    x = wsgi.extract_path_info(env, u'http://☃.net/x/fööbär')
    assert x == u'/fööbär'

    x = wsgi.extract_path_info('http://example.com/app/',
                               'https://example.com/a/hello')
    assert x is None
    x = wsgi.extract_path_info('http://example.com/app/',
                               'https://example.com/app/hello',
                               collapse_http_schemes=False)
    assert x is None
Пример #2
0
    def test_path_info_extraction(self):
        x = wsgi.extract_path_info('http://example.com/app', '/app/hello')
        self.assert_equal(x, u'/hello')
        x = wsgi.extract_path_info('http://example.com/app',
                                   'https://example.com/app/hello')
        self.assert_equal(x, u'/hello')
        x = wsgi.extract_path_info('http://example.com/app/',
                                   'https://example.com/app/hello')
        self.assert_equal(x, u'/hello')
        x = wsgi.extract_path_info('http://example.com/app/',
                                   'https://example.com/app')
        self.assert_equal(x, u'/')
        x = wsgi.extract_path_info(u'http://☃.net/', u'/fööbär')
        self.assert_equal(x, u'/fööbär')
        x = wsgi.extract_path_info(u'http://☃.net/x', u'http://☃.net/x/fööbär')
        self.assert_equal(x, u'/fööbär')

        env = create_environ(u'/fööbär', u'http://☃.net/x/')
        x = wsgi.extract_path_info(env, u'http://☃.net/x/fööbär')
        self.assert_equal(x, u'/fööbär')

        x = wsgi.extract_path_info('http://example.com/app/',
                                   'https://example.com/a/hello')
        self.assert_is_none(x)
        x = wsgi.extract_path_info('http://example.com/app/',
                                   'https://example.com/app/hello',
                                   collapse_http_schemes=False)
        self.assert_is_none(x)
Пример #3
0
    def test_path_info_extraction(self):
        x = wsgi.extract_path_info('http://example.com/app', '/app/hello')
        self.assert_equal(x, u'/hello')
        x = wsgi.extract_path_info('http://example.com/app',
                                   'https://example.com/app/hello')
        self.assert_equal(x, u'/hello')
        x = wsgi.extract_path_info('http://example.com/app/',
                                   'https://example.com/app/hello')
        self.assert_equal(x, u'/hello')
        x = wsgi.extract_path_info('http://example.com/app/',
                                   'https://example.com/app')
        self.assert_equal(x, u'/')
        x = wsgi.extract_path_info(u'http://☃.net/', u'/fööbär')
        self.assert_equal(x, u'/fööbär')
        x = wsgi.extract_path_info(u'http://☃.net/x', u'http://☃.net/x/fööbär')
        self.assert_equal(x, u'/fööbär')

        env = create_environ(u'/fööbär', u'http://☃.net/x/')
        x = wsgi.extract_path_info(env, u'http://☃.net/x/fööbär')
        self.assert_equal(x, u'/fööbär')

        x = wsgi.extract_path_info('http://example.com/app/',
                                   'https://example.com/a/hello')
        self.assert_is_none(x)
        x = wsgi.extract_path_info('http://example.com/app/',
                                   'https://example.com/app/hello',
                                   collapse_http_schemes=False)
        self.assert_is_none(x)
Пример #4
0
def test_path_info_extraction():
    x = wsgi.extract_path_info('http://example.com/app', '/app/hello')
    assert x == u'/hello'
    x = wsgi.extract_path_info('http://example.com/app',
                               'https://example.com/app/hello')
    assert x == u'/hello'
    x = wsgi.extract_path_info('http://example.com/app/',
                               'https://example.com/app/hello')
    assert x == u'/hello'
    x = wsgi.extract_path_info('http://example.com/app/',
                               'https://example.com/app')
    assert x == u'/'
    x = wsgi.extract_path_info(u'http://☃.net/', u'/fööbär')
    assert x == u'/fööbär'
    x = wsgi.extract_path_info(u'http://☃.net/x', u'http://☃.net/x/fööbär')
    assert x == u'/fööbär'

    env = create_environ(u'/fööbär', u'http://☃.net/x/')
    x = wsgi.extract_path_info(env, u'http://☃.net/x/fööbär')
    assert x == u'/fööbär'

    x = wsgi.extract_path_info('http://example.com/app/',
                               'https://example.com/a/hello')
    assert x is None
    x = wsgi.extract_path_info('http://example.com/app/',
                               'https://example.com/app/hello',
                               collapse_http_schemes=False)
    assert x is None
Пример #5
0
def test_path_info_extraction():
    x = wsgi.extract_path_info("http://example.com/app", "/app/hello")
    assert x == "/hello"
    x = wsgi.extract_path_info("http://example.com/app",
                               "https://example.com/app/hello")
    assert x == "/hello"
    x = wsgi.extract_path_info("http://example.com/app/",
                               "https://example.com/app/hello")
    assert x == "/hello"
    x = wsgi.extract_path_info("http://example.com/app/",
                               "https://example.com/app")
    assert x == "/"
    x = wsgi.extract_path_info("http://☃.net/", "/fööbär")
    assert x == "/fööbär"
    x = wsgi.extract_path_info("http://☃.net/x", "http://☃.net/x/fööbär")
    assert x == "/fööbär"

    env = create_environ("/fööbär", "http://☃.net/x/")
    x = wsgi.extract_path_info(env, "http://☃.net/x/fööbär")
    assert x == "/fööbär"

    x = wsgi.extract_path_info("http://example.com/app/",
                               "https://example.com/a/hello")
    assert x is None
    x = wsgi.extract_path_info(
        "http://example.com/app/",
        "https://example.com/app/hello",
        collapse_http_schemes=False,
    )
    assert x is None
Пример #6
0
def test_path_info_extraction():
    x = wsgi.extract_path_info("http://example.com/app", "/app/hello")
    assert x == u"/hello"
    x = wsgi.extract_path_info(
        "http://example.com/app", "https://example.com/app/hello"
    )
    assert x == u"/hello"
    x = wsgi.extract_path_info(
        "http://example.com/app/", "https://example.com/app/hello"
    )
    assert x == u"/hello"
    x = wsgi.extract_path_info("http://example.com/app/", "https://example.com/app")
    assert x == u"/"
    x = wsgi.extract_path_info(u"http://☃.net/", u"/fööbär")
    assert x == u"/fööbär"
    x = wsgi.extract_path_info(u"http://☃.net/x", u"http://☃.net/x/fööbär")
    assert x == u"/fööbär"

    env = create_environ(u"/fööbär", u"http://☃.net/x/")
    x = wsgi.extract_path_info(env, u"http://☃.net/x/fööbär")
    assert x == u"/fööbär"

    x = wsgi.extract_path_info("http://example.com/app/", "https://example.com/a/hello")
    assert x is None
    x = wsgi.extract_path_info(
        "http://example.com/app/",
        "https://example.com/app/hello",
        collapse_http_schemes=False,
    )
    assert x is None
Пример #7
0
def edit_redirect():
    record = None

    # Find out where we wanted to go to.  We need to chop off the leading
    # /admin on this URL as this is where the admin thinks it's placed.
    path = extract_path_info(request.url_root.rstrip('/').rsplit('/', 1)[0],
                             request.args.get('path', '/'))

    if path is not None:
        record = g.admin_context.pad.resolve_url_path(path, alt_fallback=False)
    if record is None:
        abort(404)
    path = fs_path_to_url_path(record.path)
    if record.alt != PRIMARY_ALT:
        path += '+' + record.alt
    return redirect(url_for('dash.edit', path=path))
Пример #8
0
def edit_redirect():
    record = None

    # Find out where we wanted to go to.  We need to chop off the leading
    # /admin on this URL as this is where the admin thinks it's placed.
    path = extract_path_info(
        request.url_root.rstrip('/').rsplit('/', 1)[0],
        request.args.get('path', '/'))

    if path is not None:
        record = g.admin_context.pad.resolve_url_path(path, alt_fallback=False)
    if record is None:
        abort(404)
    path = fs_path_to_url_path(record.path)
    if record.alt != PRIMARY_ALT:
        path += '+' + record.alt
    return redirect(url_for('dash.edit', path=path))
Пример #9
0
    def test_path_info_extraction(self):
        x = wsgi.extract_path_info("http://example.com/app", "/app/hello")
        self.assert_equal(x, u"/hello")
        x = wsgi.extract_path_info("http://example.com/app", "https://example.com/app/hello")
        self.assert_equal(x, u"/hello")
        x = wsgi.extract_path_info("http://example.com/app/", "https://example.com/app/hello")
        self.assert_equal(x, u"/hello")
        x = wsgi.extract_path_info("http://example.com/app/", "https://example.com/app")
        self.assert_equal(x, u"/")
        x = wsgi.extract_path_info(u"http://☃.net/", u"/fööbär")
        self.assert_equal(x, u"/fööbär")
        x = wsgi.extract_path_info(u"http://☃.net/x", u"http://☃.net/x/fööbär")
        self.assert_equal(x, u"/fööbär")

        env = create_environ(u"/fööbär", u"http://☃.net/x/")
        x = wsgi.extract_path_info(env, u"http://☃.net/x/fööbär")
        self.assert_equal(x, u"/fööbär")

        x = wsgi.extract_path_info("http://example.com/app/", "https://example.com/a/hello")
        self.assert_is_none(x)
        x = wsgi.extract_path_info(
            "http://example.com/app/", "https://example.com/app/hello", collapse_http_schemes=False
        )
        self.assert_is_none(x)