-
-
Notifications
You must be signed in to change notification settings - Fork 649
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
Plumb the custom certs file through to Pip (via Pex) #10837
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/python/pants/backend/python/util_rules/pex_cli_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from pants.backend.python.util_rules import pex_cli | ||
from pants.backend.python.util_rules.pex_cli import PexCliProcess | ||
from pants.core.util_rules.pants_environment import PantsEnvironment | ||
from pants.engine.fs import DigestContents | ||
from pants.engine.process import Process | ||
from pants.engine.rules import QueryRule | ||
from pants.testutil.option_util import create_options_bootstrapper | ||
from pants.testutil.rule_runner import RuleRunner | ||
from pants.util.contextutil import temporary_dir | ||
|
||
|
||
@pytest.fixture | ||
def rule_runner() -> RuleRunner: | ||
return RuleRunner( | ||
rules=[ | ||
*pex_cli.rules(), | ||
QueryRule(Process, (PexCliProcess, PantsEnvironment)), | ||
] | ||
) | ||
|
||
|
||
def test_custom_ca_certs(rule_runner: RuleRunner) -> None: | ||
with temporary_dir() as tmpdir: | ||
certs_file = Path(tmpdir) / "certsfile" | ||
certs_file.write_text("Some fake cert") | ||
proc = rule_runner.request( | ||
Process, | ||
[ | ||
PexCliProcess(argv=["some", "--args"], description=""), | ||
PantsEnvironment(), | ||
create_options_bootstrapper(args=[f"--ca-certs-path={certs_file}"]), | ||
], | ||
) | ||
assert proc.argv[2:6] == ("some", "--args", "--cert", "certsfile") | ||
files = rule_runner.request(DigestContents, [proc.input_digest]) | ||
chrooted_certs_file = [f for f in files if f.path == "certsfile"] | ||
assert len(chrooted_certs_file) == 1 | ||
assert b"Some fake cert" == chrooted_certs_file[0].content |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stuhood bump on our convo about porting
PathGlobsAndRoot
to the Async API. This is really not great to havePath.read_bytes()
in a rule. Fine as a temporary workaround, but I think this shows the need.We can caution plugin authors about the risks of using it. They're adults.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should add absolute file reads. #10360, #10769, and this usecase all require them. Opened #10842.