aboutsummaryrefslogtreecommitdiff
path: root/server/szurubooru/tests
diff options
context:
space:
mode:
authorHunternif2025-02-15 23:55:21 +0000
committerHunternif2025-02-16 01:21:59 +0000
commit778db7d510ccb7d772d4ed6677325f784ed96f0b (patch)
tree3f2f8a73285913d2885b1e8266e211f44adc29c9 /server/szurubooru/tests
parent376f687c386f65522b2f65e98b998b21af26ee29 (diff)
server: add privilege posts:view:unsafe
Diffstat (limited to 'server/szurubooru/tests')
-rw-r--r--server/szurubooru/tests/api/test_post_retrieving.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/server/szurubooru/tests/api/test_post_retrieving.py b/server/szurubooru/tests/api/test_post_retrieving.py
index ac984c2..a40ab0e 100644
--- a/server/szurubooru/tests/api/test_post_retrieving.py
+++ b/server/szurubooru/tests/api/test_post_retrieving.py
@@ -14,6 +14,7 @@ def inject_config(config_injector):
"privileges": {
"posts:list": model.User.RANK_REGULAR,
"posts:view": model.User.RANK_REGULAR,
+ "posts:view:unsafe": model.User.RANK_REGULAR,
},
}
)
@@ -73,7 +74,10 @@ def test_trying_to_use_special_tokens_without_logging_in(
):
config_injector(
{
- "privileges": {"posts:list": "anonymous"},
+ "privileges": {
+ "posts:list": "anonymous",
+ "posts:list:unsafe": "regular",
+ },
}
)
with pytest.raises(errors.SearchError):
@@ -125,3 +129,23 @@ def test_trying_to_retrieve_single_without_privileges(
context_factory(user=user_factory(rank=model.User.RANK_ANONYMOUS)),
{"post_id": 999},
)
+
+
+def test_trying_to_retrieve_unsafe_without_privileges(
+ user_factory, context_factory, post_factory, config_injector
+):
+ config_injector(
+ {
+ "privileges": {
+ "posts:view": "anonymous",
+ "posts:view:unsafe": "regular",
+ },
+ }
+ )
+ db.session.add(post_factory(id=1, safety=model.Post.SAFETY_UNSAFE))
+ db.session.flush()
+ with pytest.raises(errors.AuthError):
+ api.post_api.get_post(
+ context_factory(user=user_factory(rank=model.User.RANK_ANONYMOUS)),
+ {"post_id": 1},
+ )

© 2015 - 2026 Jakob L. Kreuze