Fix username length check
This commit is contained in:
parent
c0c9c1e89e
commit
36bf1a80bf
|
@ -68,7 +68,7 @@ def create_app(test_config=None):
|
||||||
def spec():
|
def spec():
|
||||||
if app.config["ENABLE_SWAGGER"] == "1":
|
if app.config["ENABLE_SWAGGER"] == "1":
|
||||||
swag = swagger(app)
|
swag = swagger(app)
|
||||||
swag["info"]["version"] = "1.2.3"
|
swag["info"]["version"] = "1.2.4"
|
||||||
swag["info"]["title"] = "SelfPrivacy API"
|
swag["info"]["title"] = "SelfPrivacy API"
|
||||||
swag["info"]["description"] = "SelfPrivacy API"
|
swag["info"]["description"] = "SelfPrivacy API"
|
||||||
swag["securityDefinitions"] = {
|
swag["securityDefinitions"] = {
|
||||||
|
|
|
@ -23,4 +23,4 @@ class ApiVersion(Resource):
|
||||||
401:
|
401:
|
||||||
description: Unauthorized
|
description: Unauthorized
|
||||||
"""
|
"""
|
||||||
return {"version": "1.2.3"}
|
return {"version": "1.2.4"}
|
||||||
|
|
|
@ -89,7 +89,7 @@ class Users(Resource):
|
||||||
if not re.match(r"^[a-z_][a-z0-9_]+$", args["username"]):
|
if not re.match(r"^[a-z_][a-z0-9_]+$", args["username"]):
|
||||||
return {"error": "username must be alphanumeric"}, 400
|
return {"error": "username must be alphanumeric"}, 400
|
||||||
# Check if username less than 32 characters
|
# 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
|
return {"error": "username must be less than 32 characters"}, 400
|
||||||
|
|
||||||
with WriteUserData() as data:
|
with WriteUserData() as data:
|
||||||
|
|
|
@ -213,7 +213,7 @@ def test_post_user_to_undefined_users(
|
||||||
|
|
||||||
def test_post_very_long_username(authorized_client, one_user, mock_subprocess_popen):
|
def test_post_very_long_username(authorized_client, one_user, mock_subprocess_popen):
|
||||||
response = authorized_client.post(
|
response = authorized_client.post(
|
||||||
"/users", json={"username": "a" * 100, "password": "password"}
|
"/users", json={"username": "a" * 32, "password": "password"}
|
||||||
)
|
)
|
||||||
assert response.status_code == 400
|
assert response.status_code == 400
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue