예제 #1
0
def test_ntlm_iov_not_available():
    expected = "The system is missing the GSSAPI IOV extension headers or NTLM is being requested, cannot utilitze " \
               "wrap_iov and unwrap_iov"
    with pytest.raises(FeatureMissingError, match=re.escape(expected)):
        ntlm.NTLMProxy('user',
                       'pass',
                       options=spnego.NegotiateOptions.wrapping_iov)
예제 #2
0
def test_ntlm_no_encoding_flags():
    negotiate = memoryview(bytearray(get_data('ntlm_negotiate')))
    negotiate[12:16] = b"\x00\x00\x00\x00"

    n = ntlm.NTLMProxy('user', 'pass')
    with pytest.raises(
            SpnegoError,
            match=
            "Neither NEGOTIATE_OEM or NEGOTIATE_UNICODE flags were set, cannot derive "
            "encoding for text fields"):
        n._step_accept_negotiate(negotiate.tobytes())
예제 #3
0
def test_ntlm_sign_qop_invalid():
    n = ntlm.NTLMProxy('user', 'pass')
    with pytest.raises(UnsupportedQop,
                       match="Unsupported QoP value 1 specified for NTLM"):
        n.sign(b"data", qop=1)
예제 #4
0
def test_ntlm_unwrap_iov_fail():
    n = ntlm.NTLMProxy('user', 'pass')
    with pytest.raises(OperationNotAvailableError,
                       match="NTLM does not offer IOV wrapping"):
        n.unwrap_iov([])
예제 #5
0
def test_ntlm_wrap_no_sign_or_seal():
    n = ntlm.NTLMProxy('user', 'pass')
    with pytest.raises(OperationNotAvailableError,
                       match="NTLM wrap without integrity or confidentiality"):
        n.wrap(b"data")
예제 #6
0
def test_ntlm_invalid_protocol():
    with pytest.raises(
            ValueError,
            match=
            "Invalid protocol 'fake', must be ntlm, kerberos, or negotiate"):
        ntlm.NTLMProxy('user', 'pass', protocol='fake')
예제 #7
0
def test_ntlm_invalid_usage():
    with pytest.raises(
            ValueError,
            match="Invalid usage 'test', must be initiate or accept"):
        ntlm.NTLMProxy('user', 'pass', usage='test')
예제 #8
0
def test_context_no_store(usage):
    with pytest.raises(
            OperationNotAvailableError,
            match="Retrieving NTLM store without NTLM_USER_FILE set to a "
            "filepath"):
        ntlm.NTLMProxy(None, None, usage=usage)
예제 #9
0
def test_invalid_lm_compat_level(level, monkeypatch):
    monkeypatch.setenv('LM_COMPAT_LEVEL', to_native(level))

    expected = "Invalid LM_COMPAT_LEVEL %s, must be between 0 and 5" % level
    with pytest.raises(SpnegoError, match=re.escape(expected)):
        ntlm.NTLMProxy("user", "pass")