Fix enforcement of restricted plugins (#4286)

This commit is contained in:
Raphael Michel
2024-07-03 17:14:03 +02:00
committed by GitHub
parent 4513e31f0d
commit 73038b0d97
9 changed files with 180 additions and 2 deletions

View File

@@ -763,6 +763,50 @@ def test_event_update(token_client, organizer, event, item, meta_prop):
assert cnt == event.all_logentries().count()
@pytest.mark.django_db
def test_event_update_plugins_validation(token_client, organizer, event, item, meta_prop):
resp = token_client.patch(
'/api/v1/organizers/{}/events/{}/'.format(organizer.slug, event.slug),
{
"plugins": ["pretix.plugins.paypal2", "unknown"]
},
format='json'
)
assert resp.status_code == 400
assert resp.data == {"plugins": ["Unknown plugin: 'unknown'."]}
resp = token_client.patch(
'/api/v1/organizers/{}/events/{}/'.format(organizer.slug, event.slug),
{
"plugins": ["pretix.plugins.paypal2", "tests.testdummyhidden"]
},
format='json'
)
assert resp.status_code == 400
assert resp.data == {"plugins": ["Unknown plugin: 'tests.testdummyhidden'."]}
resp = token_client.patch(
'/api/v1/organizers/{}/events/{}/'.format(organizer.slug, event.slug),
{
"plugins": ["pretix.plugins.paypal2", "tests.testdummyrestricted"]
},
format='json'
)
assert resp.status_code == 400
assert resp.data == {"plugins": ["Restricted plugin: 'tests.testdummyrestricted'."]}
organizer.settings.allowed_restricted_plugins = ["tests.testdummyrestricted"]
resp = token_client.patch(
'/api/v1/organizers/{}/events/{}/'.format(organizer.slug, event.slug),
{
"plugins": ["pretix.plugins.paypal2", "tests.testdummyrestricted"]
},
format='json'
)
assert resp.status_code == 200
@pytest.mark.django_db
def test_event_test_mode(token_client, organizer, event):
resp = token_client.patch(