Skip to content

Commit

Permalink
Rename the insecure_hosts argument to trusted_hosts.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjerdonek committed Aug 22, 2019
1 parent 970dfde commit ce218c3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/pip/_internal/cli/req_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _build_session(self, options, retries=None, timeout=None):
if options.cache_dir else None
),
retries=retries if retries is not None else options.retries,
insecure_hosts=options.trusted_hosts,
trusted_hosts=options.trusted_hosts,
index_urls=self._get_index_urls(options),
)

Expand Down
6 changes: 3 additions & 3 deletions src/pip/_internal/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,12 +573,12 @@ class PipSession(requests.Session):

def __init__(self, *args, **kwargs):
"""
:param insecure_hosts: Domains not to emit warnings for when not using
:param trusted_hosts: Domains not to emit warnings for when not using
HTTPS.
"""
retries = kwargs.pop("retries", 0)
cache = kwargs.pop("cache", None)
insecure_hosts = kwargs.pop("insecure_hosts", []) # type: List[str]
trusted_hosts = kwargs.pop("trusted_hosts", []) # type: List[str]
index_urls = kwargs.pop("index_urls", None)

super(PipSession, self).__init__(*args, **kwargs)
Expand Down Expand Up @@ -652,7 +652,7 @@ def __init__(self, *args, **kwargs):
# Enable file:// urls
self.mount("file://", LocalFSAdapter())

for host in insecure_hosts:
for host in trusted_hosts:
self.add_trusted_host(host, suppress_logging=True)

def add_trusted_host(self, host, source=None, suppress_logging=False):
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ def test_http_cache_is_not_enabled(self, tmpdir):
def test_insecure_host_adapter(self, tmpdir):
session = PipSession(
cache=tmpdir.joinpath("test-cache"),
insecure_hosts=["example.com"],
trusted_hosts=["example.com"],
)

assert "https://example.com/" in session.adapters
Expand All @@ -630,7 +630,7 @@ def test_insecure_host_adapter(self, tmpdir):
def test_add_trusted_host(self):
# Leave a gap to test how the ordering is affected.
trusted_hosts = ['host1', 'host3']
session = PipSession(insecure_hosts=trusted_hosts)
session = PipSession(trusted_hosts=trusted_hosts)
insecure_adapter = session._insecure_adapter
prefix2 = 'https://host2/'
prefix3 = 'https://host3/'
Expand Down Expand Up @@ -658,7 +658,7 @@ def test_add_trusted_host__logging(self, caplog):
Test logging when add_trusted_host() is called.
"""
trusted_hosts = ['host0', 'host1']
session = PipSession(insecure_hosts=trusted_hosts)
session = PipSession(trusted_hosts=trusted_hosts)
with caplog.at_level(logging.INFO):
# Test adding an existing host.
session.add_trusted_host('host1', source='somewhere')
Expand All @@ -677,7 +677,7 @@ def test_add_trusted_host__logging(self, caplog):

def test_iter_secure_origins(self):
trusted_hosts = ['host1', 'host2']
session = PipSession(insecure_hosts=trusted_hosts)
session = PipSession(trusted_hosts=trusted_hosts)

actual = list(session.iter_secure_origins())
assert len(actual) == 8
Expand All @@ -688,11 +688,11 @@ def test_iter_secure_origins(self):
('*', 'host2', '*'),
]

def test_iter_secure_origins__insecure_hosts_empty(self):
def test_iter_secure_origins__trusted_hosts_empty(self):
"""
Test iter_secure_origins() after passing insecure_hosts=[].
Test iter_secure_origins() after passing trusted_hosts=[].
"""
session = PipSession(insecure_hosts=[])
session = PipSession(trusted_hosts=[])

actual = list(session.iter_secure_origins())
assert len(actual) == 6
Expand Down Expand Up @@ -723,7 +723,7 @@ def __init__(self):
def warning(self, *args, **kwargs):
self.called = True

session = PipSession(insecure_hosts=trusted)
session = PipSession(trusted_hosts=trusted)
actual = session.is_secure_origin(location)
assert actual == expected

Expand Down

0 comments on commit ce218c3

Please sign in to comment.