Skip to content

Commit

Permalink
Merge pull request trevi-software#10 from trevi-software/fix-9-doubly…
Browse files Browse the repository at this point in the history
…-encrypted-random-password

[FIX] itm: random password doesn't work as expected
  • Loading branch information
mtelahun committed Aug 20, 2021
2 parents 8b6729b + 389c079 commit e7510a1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion itm/__manifest__.py
Expand Up @@ -4,7 +4,7 @@

{
"name": "IT Infrastructure Management",
"version": "14.0.1.0.1",
"version": "14.0.1.0.2",
"license": "AGPL-3",
"category": "IT Infrastructure Management",
"summary": """IT Assets, Credentials, Backups, Applications.""",
Expand Down
3 changes: 1 addition & 2 deletions itm/models/access.py
Expand Up @@ -41,8 +41,7 @@ def get_random_string(self):

def get_random_password(self):
for access in self:
token = self.encrypt_string(self.get_random_string())
access.password = token
access.password = self.get_random_string()

def get_urlsafe_key(self):

Expand Down
12 changes: 12 additions & 0 deletions itm/tests/test_access.py
Expand Up @@ -39,3 +39,15 @@ def test_change_password(self):
self.assertEqual("123", self._decrypt(cred.password))
cred.write({"password": "456"})
self.assertEqual("456", self._decrypt(cred.password))

def test_random_password(self):
"""Random password isn't mangled"""

# Not sure there's a way to test randomness. Just test that
# it's the expected length.
#
cred = self.ItAccess.create({"name": "a", "site_id": self.defaultSite.id})
self.assertFalse(cred.password)
cred.get_random_password()
strRandom = self.ItAccess.decrypt_password_as_string(cred.id)
self.assertEqual(16, len(strRandom))

0 comments on commit e7510a1

Please sign in to comment.