Skip to content

Commit 37ff630

Browse files
committed
Fix pre-commit, fix tests
1 parent b541618 commit 37ff630

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

salt/modules/win_useradd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ def info(name):
814814
dc_info = win32security.DsGetDcName(None, domain_name)
815815
server = dc_info["DomainControllerName"]
816816
log.debug("Found DC: %s", server)
817-
except win32net.error:
817+
except pywintypes.error:
818818
# Restore username to original
819819
log.debug("DC not found. Using username: %s", str(name))
820820
user_name = str(name)

tests/pytests/functional/modules/test_win_useradd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def test_info_int(user, account_int):
215215

216216

217217
def test_info_domain_local(user, account_str):
218-
domain = "." # localhost or hostname doesn't work, only .
218+
domain = "." # localhost or hostname doesn't work, only .
219219
ret = user.info(f"{domain}\\{account_str.username}")
220220
assert ret["name"] == account_str.username
221221
assert ret["uid"].startswith("S-1-5")

tests/pytests/unit/modules/test_win_useradd.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from tests.support.mock import MagicMock, patch
99

1010
try:
11-
import win32net
11+
import pywintypes
1212

1313
WINAPI = True
1414
except ImportError:
@@ -64,8 +64,9 @@ def test_info(account, caplog):
6464
def test_info_domain(account, caplog):
6565
domain = "mydomain"
6666
dc = "myDC"
67+
dc_info = {"DomainControllerName": dc}
6768
with caplog.at_level(logging.DEBUG), patch(
68-
"win32net.NetGetAnyDCName", MagicMock(return_value=dc)
69+
"win32security.DsGetDcName", MagicMock(return_value=dc_info)
6970
):
7071
account.username = f"{domain}\\{account.username}"
7172
win_useradd.info(account.username)
@@ -77,7 +78,7 @@ def test_info_error(account, caplog):
7778
domain = "mydomain"
7879
dc = "myDC"
7980
with caplog.at_level(logging.DEBUG), patch(
80-
"win32net.NetGetAnyDCName", MagicMock(side_effect=win32net.error)
81+
"win32security.DsGetDcName", MagicMock(side_effect=pywintypes.error)
8182
):
8283
account.username = f"{domain}\\{account.username}"
8384
win_useradd.info(account.username)

0 commit comments

Comments
 (0)