-
Notifications
You must be signed in to change notification settings - Fork 3
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
fix get_client #32
Merged
Merged
fix get_client #32
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
05db75a
get_client: use pop instead of get to remove used kwargs
dtrifiro e387cc6
tests: move tests/unit/remote/test_http.py from dvc-http repo
dtrifiro 4cf7f86
tests: test_config: remove unused fixtures
dtrifiro 5a7772f
tests: fix ssl_verify_{disable,custom_cert}
dtrifiro 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
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,96 @@ | ||
import ssl | ||
|
||
from dvc.fs import HTTPFileSystem | ||
from fsspec.asyn import get_loop as get_fsspec_loop | ||
from fsspec.asyn import sync | ||
|
||
|
||
def test_public_auth_method(): | ||
config = { | ||
"url": "http://example.com/", | ||
"path": "file.html", | ||
"user": "", | ||
"password": "", | ||
} | ||
|
||
fs = HTTPFileSystem(**config) | ||
|
||
assert "auth" not in fs.fs_args["client_kwargs"] | ||
assert "headers" not in fs.fs_args | ||
|
||
|
||
def test_basic_auth_method(): | ||
user = "username" | ||
password = "password" | ||
config = { | ||
"url": "http://example.com/", | ||
"path": "file.html", | ||
"auth": "basic", | ||
"user": user, | ||
"password": password, | ||
} | ||
|
||
fs = HTTPFileSystem(**config) | ||
|
||
assert fs.fs_args["client_kwargs"]["auth"].login == user | ||
assert fs.fs_args["client_kwargs"]["auth"].password == password | ||
|
||
|
||
def test_custom_auth_method(): | ||
header = "Custom-Header" | ||
password = "password" | ||
config = { | ||
"url": "http://example.com/", | ||
"path": "file.html", | ||
"auth": "custom", | ||
"custom_auth_header": header, | ||
"password": password, | ||
} | ||
|
||
fs = HTTPFileSystem(**config) | ||
|
||
headers = fs.fs_args["headers"] | ||
assert header in headers | ||
assert headers[header] == password | ||
|
||
|
||
def test_ssl_verify_disable(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modified |
||
config = { | ||
"url": "http://example.com/", | ||
"path": "file.html", | ||
"ssl_verify": False, | ||
} | ||
|
||
fs = HTTPFileSystem(**config) | ||
session = sync(get_fsspec_loop(), fs.fs.set_session) | ||
|
||
# pylint: disable-next=protected-access | ||
assert not session._client._connector._ssl | ||
|
||
|
||
def test_ssl_verify_custom_cert(mocker): | ||
mocker.patch("ssl.SSLContext.load_verify_locations") | ||
config = { | ||
"url": "http://example.com/", | ||
"path": "file.html", | ||
"ssl_verify": "/path/to/custom/cabundle.pem", | ||
} | ||
|
||
fs = HTTPFileSystem(**config) | ||
session = sync(get_fsspec_loop(), fs.fs.set_session) | ||
|
||
# pylint: disable-next=protected-access | ||
assert isinstance(session._client.connector._ssl, ssl.SSLContext) | ||
|
||
|
||
def test_http_method(): | ||
config = { | ||
"url": "http://example.com/", | ||
"path": "file.html", | ||
} | ||
|
||
fs = HTTPFileSystem(**config, method="PUT") | ||
assert fs.upload_method == "PUT" | ||
|
||
fs = HTTPFileSystem(**config, method="POST") | ||
assert fs.upload_method == "POST" |
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.
Use
pop
everywhere to avoid passingkwargs
to client