예제 #1
0
def test_password_without_user_is_invalid():
    with pytest.raises(Exception) as exception_info:
        requests_auth.NTLM(password="******")
    assert (
        str(exception_info.value) ==
        'NTLM authentication requires "username" to be provided in security_details.'
    )
예제 #2
0
def test_requests_negotiate_sspi_is_used_when_nothing_is_provided(
        monkeypatch, responses):
    # load requests_negociate_sspi from the file in tests/success_ntlm folder
    monkeypatch.syspath_prepend(
        os.path.join(os.path.abspath(os.path.dirname(__file__)),
                     "success_ntlm"))
    assert (get_header(
        responses,
        requests_auth.NTLM()).get("Authorization") == "HttpNegotiateAuth fake")
예제 #3
0
def test_requests_negotiate_sspi_is_used_when_nothing_is_provided_but_without_installed(
    monkeypatch, ):
    # load requests_negociate_sspi from the file in tests/failing_ntlm folder
    monkeypatch.syspath_prepend(
        os.path.join(os.path.abspath(os.path.dirname(__file__)),
                     "failing_ntlm"))
    with pytest.raises(Exception) as exception_info:
        requests_auth.NTLM()
    assert (str(exception_info.value) ==
            "NTLM authentication requires requests_negotiate_sspi module.")
예제 #4
0
def test_requests_ntlm_is_used_when_user_and_pass_provided(
        monkeypatch, responses):
    # load requests_ntlm from the file in tests/success_ntlm folder
    monkeypatch.syspath_prepend(
        os.path.join(os.path.abspath(os.path.dirname(__file__)),
                     "success_ntlm"))
    assert (get_header(responses,
                       requests_auth.NTLM("fake_user",
                                          "fake_pwd")).get("Authorization") ==
            "HttpNtlmAuth fake fake_user / fake_pwd")