mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
form: fix forbidden readonly type
This commit is contained in:
parent
582b1ed311
commit
a574855a03
2 changed files with 6 additions and 7 deletions
|
@ -741,7 +741,7 @@ class TestPassword(BaseTest):
|
||||||
("secret", FAIL),
|
("secret", FAIL),
|
||||||
*[("supersecret" + char, FAIL) for char in FORBIDDEN_PASSWORD_CHARS], # FIXME maybe add ` \n` to the list?
|
*[("supersecret" + char, FAIL) for char in FORBIDDEN_PASSWORD_CHARS], # FIXME maybe add ` \n` to the list?
|
||||||
# readonly
|
# readonly
|
||||||
("s3cr3t!!", FAIL, {"readonly": True, "current_value": "isforbidden"}), # readonly is forbidden
|
("s3cr3t!!", FAIL, {"readonly": True}), # readonly is forbidden
|
||||||
]
|
]
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
|
@ -1519,7 +1519,7 @@ class TestDomain(BaseTest):
|
||||||
("doesnt_exist.pouet", FAIL, {}),
|
("doesnt_exist.pouet", FAIL, {}),
|
||||||
("fake.com", FAIL, {"choices": ["fake.com"]}),
|
("fake.com", FAIL, {"choices": ["fake.com"]}),
|
||||||
# readonly
|
# readonly
|
||||||
(domains1[0], YunohostError, {"readonly": True}), # readonly is forbidden
|
(domains1[0], FAIL, {"readonly": True}), # readonly is forbidden
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1619,7 +1619,7 @@ class TestApp(BaseTest):
|
||||||
(installed_non_webapp["id"], installed_non_webapp["id"]),
|
(installed_non_webapp["id"], installed_non_webapp["id"]),
|
||||||
(installed_non_webapp["id"], FAIL, {"filter": "is_webapp"}),
|
(installed_non_webapp["id"], FAIL, {"filter": "is_webapp"}),
|
||||||
# readonly
|
# readonly
|
||||||
(installed_non_webapp["id"], YunohostError, {"readonly": True}), # readonly is forbidden
|
(installed_non_webapp["id"], FAIL, {"readonly": True}), # readonly is forbidden
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -1736,7 +1736,7 @@ class TestUser(BaseTest):
|
||||||
("", regular_username, {"default": regular_username})
|
("", regular_username, {"default": regular_username})
|
||||||
], reason="Should throw 'no default allowed'"),
|
], reason="Should throw 'no default allowed'"),
|
||||||
# readonly
|
# readonly
|
||||||
(admin_username, YunohostError, {"readonly": True}), # readonly is forbidden
|
(admin_username, FAIL, {"readonly": True}), # readonly is forbidden
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -1820,7 +1820,7 @@ class TestGroup(BaseTest):
|
||||||
("", "custom_group", {"default": "custom_group"}),
|
("", "custom_group", {"default": "custom_group"}),
|
||||||
], reason="Should throw 'default must be in (None, 'all_users', 'visitors', 'admins')"),
|
], reason="Should throw 'default must be in (None, 'all_users', 'visitors', 'admins')"),
|
||||||
# readonly
|
# readonly
|
||||||
("admins", "all_users", {"readonly": True}), # readonly is forbidden (default is "all_users")
|
("admins", FAIL, {"readonly": True}), # readonly is forbidden
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
|
@ -300,8 +300,7 @@ class BaseOption(BaseModel):
|
||||||
|
|
||||||
@validator("readonly", pre=True)
|
@validator("readonly", pre=True)
|
||||||
def can_be_readonly(cls, value: bool, values: Values) -> bool:
|
def can_be_readonly(cls, value: bool, values: Values) -> bool:
|
||||||
forbidden_types = ("password", "app", "domain", "user", "file")
|
if value is True and values["type"] in FORBIDDEN_READONLY_TYPES:
|
||||||
if value is True and values["type"] in forbidden_types:
|
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
m18n.n(
|
m18n.n(
|
||||||
"config_forbidden_readonly_type",
|
"config_forbidden_readonly_type",
|
||||||
|
|
Loading…
Add table
Reference in a new issue