This file is indexed.

/usr/lib/python3/dist-packages/pydap/tests/test_net.py is in python3-pydap 3.2.2+ds1-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""
Test the follow redirects and handling of more complex routing situations
"""

import requests
from webob.request import Request
import requests_mock
from pydap.net import create_request


def test_redirect():
    """ Test that redirection is handled properly """
    mock_url = 'http://www.test.com/'
    # mock_url is redirected to https:
    redirect_url = 'http://www.test2.com/'
    with requests_mock.Mocker() as m:
        m.register_uri('HEAD', mock_url, text='resp2', status_code=200)
        req = create_request(mock_url)
        assert len(m.request_history) == 1
        assert isinstance(req, Request)
        assert req.headers['Host'] == 'www.test.com:80'

    # Without session:
    with requests_mock.Mocker() as m:
        m.register_uri('HEAD', mock_url, text='resp1', status_code=301,
                       headers={'Location': redirect_url})
        m.register_uri('HEAD', redirect_url, text='resp2', status_code=200)
        req = create_request(mock_url)
        # Ensure follow redirect:
        assert len(m.request_history) == 2
        assert isinstance(req, Request)
        assert req.headers['Host'] == 'www.test2.com:80'

    # With session:
    with requests_mock.Mocker() as m:
        m.register_uri('HEAD', mock_url, text='resp1', status_code=301,
                       headers={'Location': redirect_url})
        m.register_uri('HEAD', redirect_url, text='resp2', status_code=200)
        req = create_request(mock_url, session=requests.Session())
        # Ensure follow redirect:
        assert len(m.request_history) == 2
        assert isinstance(req, Request)
        assert req.headers['Host'] == 'www.test2.com:80'