Пример #1
0
def test_digest_auth_method(dvc):
    from requests.auth import HTTPDigestAuth

    user = "******"
    password = "******"
    auth = HTTPDigestAuth(user, password)
    config = {
        "url": "http://example.com/",
        "path_info": "file.html",
        "auth": "digest",
        "user": user,
        "password": password,
    }

    fs = HTTPFileSystem(**config)

    assert fs._auth_method(config["url"]) == auth
    assert isinstance(fs._auth_method(config["url"]), HTTPDigestAuth)
Пример #2
0
def test_basic_auth_method(dvc):
    from requests.auth import HTTPBasicAuth

    user = "******"
    password = "******"
    auth = HTTPBasicAuth(user, password)
    config = {
        "url": "http://example.com/",
        "path_info": "file.html",
        "auth": "basic",
        "user": user,
        "password": password,
    }

    fs = HTTPFileSystem(dvc, config)

    assert fs._auth_method() == auth
    assert isinstance(fs._auth_method(), HTTPBasicAuth)
Пример #3
0
def test_public_auth_method(dvc):
    config = {
        "url": "http://example.com/",
        "path_info": "file.html",
        "user": "",
        "password": "",
    }

    fs = HTTPFileSystem(**config)

    assert fs._auth_method(config["url"]) is None
Пример #4
0
def test_custom_auth_method(dvc):
    header = "Custom-Header"
    password = "******"
    config = {
        "url": "http://example.com/",
        "path_info": "file.html",
        "auth": "custom",
        "custom_auth_header": header,
        "password": password,
    }

    fs = HTTPFileSystem(**config)

    assert fs._auth_method(config["url"]) is None
    assert header in fs.headers
    assert fs.headers[header] == password