|
25 | 25 |
|
26 | 26 | rf = RequestFactory() |
27 | 27 | decorator = login_required() |
| 28 | +decorator_allow_public_post = login_required(allowPublicPost=True) |
28 | 29 |
|
29 | 30 |
|
30 | 31 | def test_is_valid_public_url_default(monkeypatch): |
@@ -157,3 +158,16 @@ def test_is_valid_public_url_any_method(monkeypatch): |
157 | 158 | assert decorator.is_valid_public_url(1, rf.post("/api/v0/login")) is True |
158 | 159 | assert decorator.is_valid_public_url(1, rf.get("/webgateway/")) is False |
159 | 160 | assert decorator.is_valid_public_url(1, rf.get("/webclient/")) is False |
| 161 | + |
| 162 | + |
| 163 | +def test_is_valid_table_slice_call(monkeypatch): |
| 164 | + monkeypatch.setattr(settings, "PUBLIC_ENABLED", True) |
| 165 | + monkeypatch.setattr(settings, "PUBLIC_USER", "public.user", raising=False) |
| 166 | + monkeypatch.setattr(settings, "PUBLIC_PASSWORD", "password", raising=False) |
| 167 | + monkeypatch.setattr(settings, "PUBLIC_GET_ONLY", True) |
| 168 | + monkeypatch.setattr(settings, "PUBLIC_URL_FILTER", re.compile("^/api")) |
| 169 | + assert decorator_allow_public_post.is_valid_public_url(1, rf.get("/webgateway/table/123/slice")) is False |
| 170 | + assert decorator_allow_public_post.is_valid_public_url(1, rf.post("/webgateway/table/123/slice")) is False |
| 171 | + monkeypatch.setattr(settings, "PUBLIC_URL_FILTER", re.compile("^/api|webgateway")) |
| 172 | + assert decorator_allow_public_post.is_valid_public_url(1, rf.get("/webgateway/table/123/slice")) is True |
| 173 | + assert decorator_allow_public_post.is_valid_public_url(1, rf.post("/webgateway/table/123/slice")) is True |
0 commit comments