mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
feat(webdav): add bearer_token_command for dynamic token acquisition (#10917)
Co-authored-by: GreenHatHG <[email protected]> Co-authored-by: skshetry <[email protected]>
This commit is contained in:
co-authored by
GreenHatHG
skshetry
parent
0eb279ea35
commit
f342cc7db5
@@ -151,6 +151,7 @@ WEBDAV_COMMON = {
|
||||
"password": str,
|
||||
"ask_password": Bool,
|
||||
"token": str,
|
||||
"bearer_token_command": str,
|
||||
"custom_auth_header": str,
|
||||
"cert_path": str,
|
||||
"key_path": str,
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ tests = [
|
||||
"sqlalchemy>=1,<3", # optional dependency for `import-db`
|
||||
"pandas>=1", # optional dependency for `import-db`
|
||||
]
|
||||
webdav = ["dvc-webdav>=3,<4"]
|
||||
webdav = ["dvc-webdav>=3.0.1,<4"]
|
||||
webhdfs = ["dvc-webhdfs>=3.1,<4"]
|
||||
webhdfs_kerberos = ["dvc-webhdfs[kerberos]>=3.1,<4"]
|
||||
|
||||
|
||||
@@ -153,3 +153,31 @@ def test_remote_with_jobs(dvc, base_url, fs_cls):
|
||||
assert config["user"] == "admin"
|
||||
assert f"{scheme}://{user}@example.com" in config["host"]
|
||||
assert cls is fs_cls
|
||||
|
||||
|
||||
def test_bearer_token_command(mocker):
|
||||
mock_auth_obj = mocker.Mock()
|
||||
mock_get_auth = mocker.patch(
|
||||
"dvc_webdav.get_bearer_auth", return_value=mock_auth_obj
|
||||
)
|
||||
|
||||
command = "my-token-cmd.sh"
|
||||
timeout = 10
|
||||
|
||||
# Configuration with potential conflicts
|
||||
config = {
|
||||
"url": url,
|
||||
"token": "static-token-value",
|
||||
"user": "conflict-user",
|
||||
"password": "conflict-password",
|
||||
"bearer_token_command": command,
|
||||
"timeout": timeout,
|
||||
}
|
||||
|
||||
fs = WebDAVFileSystem(**config)
|
||||
|
||||
# the factory function was invoked with the correct arguments from the config.
|
||||
mock_get_auth.assert_called_once_with(command, timeout)
|
||||
|
||||
# the generated auth object is correctly injected into `fs_args`.
|
||||
assert fs.fs_args["auth"] == mock_auth_obj
|
||||
|
||||
Reference in New Issue
Block a user