Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow --trusted-host option in requirement files #3007

Merged
merged 1 commit into from
Sep 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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