Skip to content

Commit

Permalink
Merge pull request #3007 from xavfernandez/trusted_host_in_req_file
Browse files Browse the repository at this point in the history
Allow --trusted-host option in requirement files
  • Loading branch information
xavfernandez committed Sep 5, 2015
2 parents b0ccf46 + e168b84 commit a7634cb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
changes made to the repository protocol made in PEP 470, these options are no
longer functional.

* Allow ``--trusted-host`` within a requirements file. :issue:`2822`.


**7.1.2 (2015-08-22)**

Expand Down
4 changes: 4 additions & 0 deletions pip/req/req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
cmdoptions.always_unzip,
cmdoptions.no_binary,
cmdoptions.only_binary,
cmdoptions.trusted_host,
]

# options to be passed to requirements
Expand Down Expand Up @@ -218,6 +219,9 @@ def process_line(line, filename, line_number, finder=None, comes_from=None,
if os.path.exists(relative_to_reqs_file):
value = relative_to_reqs_file
finder.find_links.append(value)
if opts.trusted_hosts:
finder.secure_origins.extend(
("*", host, "*") for host in opts.trusted_hosts)


def break_args_options(line):
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/test_req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ def test_set_finder_no_use_wheel(self, finder):
no_use_wheel_fmt = pip.index.FormatControl(set([':all:']), set())
assert finder.format_control == no_use_wheel_fmt

def test_set_finder_trusted_host(self, finder):
list(process_line("--trusted-host=url", "file", 1, finder=finder))
assert finder.secure_origins == [('*', 'url', '*')]

def test_noop_always_unzip(self, finder):
# noop, but confirm it can be set
list(process_line("--always-unzip", "file", 1, finder=finder))
Expand Down

0 comments on commit a7634cb

Please sign in to comment.