From 3aa9a7c778db6c828f6e9c0927c042845a111f9d Mon Sep 17 00:00:00 2001 From: kihuha Date: Fri, 17 May 2019 16:59:48 +0300 Subject: [PATCH] [Bug #166079643] Update password validation --- authors/apps/authentication/serializers.py | 3 ++- .../tests/test_authentication.py | 18 ++++++++++++++++++ authors/urls.py | 7 ------- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/authors/apps/authentication/serializers.py b/authors/apps/authentication/serializers.py index abfa927..cd62c04 100644 --- a/authors/apps/authentication/serializers.py +++ b/authors/apps/authentication/serializers.py @@ -22,7 +22,8 @@ class RegistrationSerializer(serializers.ModelSerializer): write_only=True, required=True, validators=[RegexValidator( - regex="^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$", + # ^[A-Za-z0-9!@#$%^&*()_+\-=\[\]{};':\"\\|,.<>\/?±§~`]+$ + regex="^(?=.*[A-Za-z])(?=.*\d)[A-Za-z0-9!@#$%^&*()_+\-=\[\]{};':\"\\|,.<>\/?±§~`\]+]{8,}$", message="Please ensure your password contains at least one letter and one numeral", code='invalid_password')], diff --git a/authors/apps/authentication/tests/test_authentication.py b/authors/apps/authentication/tests/test_authentication.py index bbc0d20..3e4ede7 100644 --- a/authors/apps/authentication/tests/test_authentication.py +++ b/authors/apps/authentication/tests/test_authentication.py @@ -279,3 +279,21 @@ def test_signup_nonalphanumeric_password(self): 'Please ensure your password contains at least one letter and one numeral', str(output) ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + + def test_signup_special_character_password(self): + """ + test for request with a non alphanumeric password + """ + response = self.client.post( + reverse('authentication:user-signup'), + data={ + "user": { + "email": "tester3@mail.com", + "username": "tester3", + "password": "Tester1234#&&*±§" + } + }, + format="json" + ) + output = json.loads(response.content) + self.assertEqual(response.status_code, status.HTTP_201_CREATED) diff --git a/authors/urls.py b/authors/urls.py index 58d6403..8e22922 100644 --- a/authors/urls.py +++ b/authors/urls.py @@ -84,11 +84,4 @@ namespace='bookmark' ) ), - path( - 'api/', - include( - ('authors.apps.stats.urls', 'authors.apps.stats'), - namespace="stats" - ) - ) ]