Fix username length check
continuous-integration/drone/push Build is passing Details

pull/15/head
Inex Code 2022-05-02 14:48:28 +03:00
parent c0c9c1e89e
commit 36bf1a80bf
4 changed files with 4 additions and 4 deletions

View File

@ -68,7 +68,7 @@ def create_app(test_config=None):
def spec():
if app.config["ENABLE_SWAGGER"] == "1":
swag = swagger(app)
swag["info"]["version"] = "1.2.3"
swag["info"]["version"] = "1.2.4"
swag["info"]["title"] = "SelfPrivacy API"
swag["info"]["description"] = "SelfPrivacy API"
swag["securityDefinitions"] = {

View File

@ -23,4 +23,4 @@ class ApiVersion(Resource):
401:
description: Unauthorized
"""
return {"version": "1.2.3"}
return {"version": "1.2.4"}

View File

@ -89,7 +89,7 @@ class Users(Resource):
if not re.match(r"^[a-z_][a-z0-9_]+$", args["username"]):
return {"error": "username must be alphanumeric"}, 400
# Check if username less than 32 characters
if len(args["username"]) > 32:
if len(args["username"]) >= 32:
return {"error": "username must be less than 32 characters"}, 400
with WriteUserData() as data:

View File

@ -213,7 +213,7 @@ def test_post_user_to_undefined_users(
def test_post_very_long_username(authorized_client, one_user, mock_subprocess_popen):
response = authorized_client.post(
"/users", json={"username": "a" * 100, "password": "password"}
"/users", json={"username": "a" * 32, "password": "password"}
)
assert response.status_code == 400