# Path: user_management/utils/validators.py
# def validate_password_strength(value):
#     """
#     Passwords should be tough.
# 
#     That means they should use:
#     - mixed case letters,
#     - numbers,
#     - (optionally) ascii symbols and spaces.
# 
#     The (contrversial?) decision to limit the passwords to ASCII only
#     is for the sake of:
#     - simplicity (no need to normalise UTF-8 input)
#     - security (some character sets are visible as typed into password fields)
# 
#     TODO: In future, it may be worth considering:
#     - rejecting common passwords. (Where can we get a list?)
#     - rejecting passwords with too many repeated characters.
# 
#     It should be noted that no restriction has been placed on the length of the
#     password here, as that can easily be achieved with use of the min_length
#     attribute of a form/serializer field.
#     """
#     used_chars = set(value)
#     good_chars = set(ascii_letters + digits + punctuation + ' ')
#     required_sets = (ascii_uppercase, ascii_lowercase, digits)
# 
#     if not used_chars.issubset(good_chars):
#         raise ValidationError(too_fancy)
# 
#     for required in required_sets:
#         if not used_chars.intersection(required):
#             raise ValidationError(too_simple)


import string
from django.core.exceptions import ValidationError
from django.test import TestCase
from ..validators import validate_password_strength
# -*- coding: utf-8 -*-




class PasswordsTest(TestCase):
    too_simple = (
        'Password must have at least ' +
        'one upper case letter, one lower case letter, and one number.'
    )

    too_fancy = (
        'Password only accepts the following symbols ' + string.punctuation
    )

    def test_no_upper(self):
        password = 'aaaa1111'
        with self.assertRaises(ValidationError) as error:

# Path: user_management/utils/validators.py
# def validate_password_strength(value):
#     """
#     Passwords should be tough.
# 
#     That means they should use:
#     - mixed case letters,
#     - numbers,
#     - (optionally) ascii symbols and spaces.
# 
#     The (contrversial?) decision to limit the passwords to ASCII only
#     is for the sake of:
#     - simplicity (no need to normalise UTF-8 input)
#     - security (some character sets are visible as typed into password fields)
# 
#     TODO: In future, it may be worth considering:
#     - rejecting common passwords. (Where can we get a list?)
#     - rejecting passwords with too many repeated characters.
# 
#     It should be noted that no restriction has been placed on the length of the
#     password here, as that can easily be achieved with use of the min_length
#     attribute of a form/serializer field.
#     """
#     used_chars = set(value)
#     good_chars = set(ascii_letters + digits + punctuation + ' ')
#     required_sets = (ascii_uppercase, ascii_lowercase, digits)
# 
#     if not used_chars.issubset(good_chars):
#         raise ValidationError(too_fancy)
# 
#     for required in required_sets:
#         if not used_chars.intersection(required):
#             raise ValidationError(too_simple)


# Path: user_management/utils/tests/test_validators.py
import string
from django.core.exceptions import ValidationError
from django.test import TestCase
from ..validators import validate_password_strength

# -*- coding: utf-8 -*-




class PasswordsTest(TestCase):
    too_simple = (
        'Password must have at least ' +
        'one upper case letter, one lower case letter, and one number.'
    )

    too_fancy = (
        'Password only accepts the following symbols ' + string.punctuation
    )

    def test_no_upper(self):
        password = 'aaaa1111'
        with self.assertRaises(ValidationError) as error:

            validate_password_strength(password)