Resolve obfuscated password warnings, merge use of the field

This commit is contained in:
shamoon
2024-11-30 10:48:07 -08:00
parent 627d0ac9cf
commit 880dc7b34c
3 changed files with 7 additions and 18 deletions

View File

@@ -8,13 +8,13 @@ from paperless_mail.models import MailAccount
from paperless_mail.models import MailRule
class ObfuscatedPasswordField(serializers.Field):
class ObfuscatedPasswordField(serializers.CharField):
"""
Sends *** string instead of password in the clear
"""
def to_representation(self, value):
return "*" * len(value)
def to_representation(self, value) -> str:
return "*" * max(10, len(value))
def to_internal_value(self, data):
return data

View File

@@ -64,7 +64,7 @@ class TestAPIMailAccounts(DirectoriesMixin, APITestCase):
self.assertEqual(returned_account1["username"], account1.username)
self.assertEqual(
returned_account1["password"],
"*" * len(account1.password),
"**********",
)
self.assertEqual(returned_account1["imap_server"], account1.imap_server)
self.assertEqual(returned_account1["imap_port"], account1.imap_port)