Skip to content
Snippets Groups Projects
Select Git revision
  • develop default protected
  • 1356-update-packages
  • 1303-failing-to-refetch-federated-tracks
  • 1108-remove-jwt-and-switch-to-oauth-for-ui-auth
  • set-sast-config-2
  • set-sast-config-1
  • master
  • tracemallocmiddleware
  • 1299-encoding-problem-in-rss-feeds
  • 1346-selectoreventloop-required-instead-got-uvloop-loop
  • 1278-embed-isn-t-available-in-the-front-end-for-channel-tracks
  • 1311-feedparser-requires-update-to-accomodate-python-3-9
  • 1.0.1
  • 1121-download
  • plugins-v3
  • plugins-v2
  • plugins
  • 1.1.1
  • 1.1
  • 1.1-rc2
  • 1.1-rc1
  • 1.0.1
  • 1.0
  • 1.0-rc1
  • 0.21.2
  • 0.21.1
  • 0.21
  • 0.21-rc2
  • 0.21-rc1
  • 0.20.1
  • 0.20.0
  • 0.20.0-rc1
  • 0.19.1
  • 0.19.0
  • 0.19.0-rc2
  • 0.19.0-rc1
  • 0.18.3
37 results

test_serializers.py

Blame
  • Forked from funkwhale / funkwhale
    5093 commits behind the upstream repository.
    test_serializers.py 1.26 KiB
    import pytest
    
    from funkwhale_api.users import serializers
    
    
    @pytest.mark.parametrize(
        "data, expected_error",
        [
            (
                {
                    "username": "myusername",
                    "email": "test@hello.com",
                    "password1": "myusername",
                },
                r".*password is too similar.*",
            ),
            (
                {"username": "myusername", "email": "test@hello.com", "password1": "test"},
                r".*must contain at least 8 characters.*",
            ),
            (
                {
                    "username": "myusername",
                    "email": "test@hello.com",
                    "password1": "superman",
                },
                r".*password is too common.*",
            ),
            (
                {
                    "username": "myusername",
                    "email": "test@hello.com",
                    "password1": "123457809878",
                },
                r".*password is entirely numeric.*",
            ),
        ],
    )
    def test_registration_serializer_validates_password_properly(data, expected_error, db):
        data["password2"] = data["password1"]
        serializer = serializers.RegisterSerializer(data=data)
    
        with pytest.raises(serializers.serializers.ValidationError, match=expected_error):
            serializer.is_valid(raise_exception=True)