-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved timeout to only the initial negotiate instead of a global setti…
…ng, set NTLM check to verify username and password is set
- Loading branch information
Showing
4 changed files
with
54 additions
and
19 deletions.
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
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 |
---|---|---|
|
@@ -5,8 +5,8 @@ | |
|
||
from smbprotocol.connection import Connection, Dialects, SecurityMode | ||
from smbprotocol.exceptions import SMBAuthenticationError, SMBException | ||
from smbprotocol.session import Session, SMB2Logoff, SMB2SessionSetupRequest, \ | ||
SMB2SessionSetupResponse | ||
from smbprotocol.session import NtlmContext, Session, SMB2Logoff, \ | ||
SMB2SessionSetupRequest, SMB2SessionSetupResponse | ||
|
||
from .utils import smb_real | ||
|
||
|
@@ -104,6 +104,39 @@ def test_parse_message(self): | |
assert actual['reserved'].get_value() == 0 | ||
|
||
|
||
class TestNtlmContext(object): | ||
|
||
def test_no_username_fail(self): | ||
with pytest.raises(SMBException) as exc: | ||
NtlmContext(None, None) | ||
assert str(exc.value) == "The username must be set when using NTLM " \ | ||
"authentication" | ||
|
||
def test_no_password_fail(self): | ||
with pytest.raises(SMBException) as exc: | ||
NtlmContext("username", None) | ||
assert str(exc.value) == "The password must be set when using NTLM " \ | ||
"authentication" | ||
|
||
def test_username_without_domain(self): | ||
actual = NtlmContext("username", "password") | ||
assert actual.domain == "" | ||
assert actual.username == "username" | ||
assert actual.password == "password" | ||
|
||
def test_username_in_netlogon_form(self): | ||
actual = NtlmContext("DOMAIN\\username", "password") | ||
assert actual.domain == "DOMAIN" | ||
assert actual.username == "username" | ||
assert actual.password == "password" | ||
|
||
def test_username_in_upn_form(self): | ||
actual = NtlmContext("[email protected]", "password") | ||
assert actual.domain == "" | ||
assert actual.username == "[email protected]" | ||
assert actual.password == "password" | ||
|
||
|
||
class TestSession(object): | ||
|
||
def test_dialect_2_0_2(self, smb_real): | ||
|