Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSquires committed Jan 8, 2025
1 parent 42eccab commit 65f09ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions synapse/lib/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,7 @@ async def setPasswd(self, passwd, nexs=True, enforce_policy=True):
# Prevent empty string or non-string values
if passwd is None:
shadow = None
enforce_policy = False
elif passwd and isinstance(passwd, str):
shadow = await s_passwd.getShadowV2(passwd=passwd)
else:
Expand Down
13 changes: 6 additions & 7 deletions synapse/tests/test_lib_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ async def test_auth_password_policy(self):
])

# Check sequences
seqmsg = f'Password must not contain forward/reverse sequences longer than 3 characters.'
seqmsg = 'Password must not contain forward/reverse sequences longer than 3 characters.'
passwords = [
# letters
'abcA', 'dcbA', 'Abcd', 'Acba',
Expand Down Expand Up @@ -531,12 +531,8 @@ async def test_auth_password_policy(self):
'Password must contain at least 2 digit characters, 0 found.'
])

with self.raises(s_exc.BadArg) as exc:
await core.setUserPasswd(user.iden, None)
self.isin(
'Password must be at least 12 characters.',
exc.exception.get('failures')
)
# Setting password to None should work also
await core.setUserPasswd(user.iden, None)

# Attempting to add a user with a bad passwd will add the user and fail to set the password
with self.raises(s_exc.BadArg):
Expand Down Expand Up @@ -582,6 +578,9 @@ async def test_auth_password_policy(self):
await core.setUserPasswd(user.iden, pass2)
await core.setUserPasswd(user.iden, pass3)

# Setting password to None should work also
await core.setUserPasswd(user.iden, None)

with self.raises(s_exc.BadArg) as exc:
await core.setUserPasswd(user.iden, pass1)
self.eq(exc.exception.get('failures'), [
Expand Down

0 comments on commit 65f09ac

Please sign in to comment.