diff --git a/Backend/settings.py b/Backend/settings.py index 28a882b396e3b03f2aad04c534e9fad579998a78..5aa50a9d30163550322e3f929f7160c6b8b52adc 100644 --- a/Backend/settings.py +++ b/Backend/settings.py @@ -185,6 +185,11 @@ DOMAIN = { 'readonly': True, 'default': 'waiting', }, + 'checked_in': { + 'type': 'boolean', + 'default': None, + 'not_patchable': True, + }, }, }, diff --git a/Backend/tests/test_security.py b/Backend/tests/test_security.py index 48aeb856d228720102b3f65a019d496d65e1ffbb..baeca75e8a5eda7fbebe48fc66eb47bd9e68712e 100644 --- a/Backend/tests/test_security.py +++ b/Backend/tests/test_security.py @@ -174,3 +174,37 @@ def test_admin_signup_visibility(app, resource): # Delete (etag missing again) app.client.delete(url, headers=headers, assert_status=412) + + +def test_checkin_authorization(app): + """Test that only an admin can check-in a user at an event.""" + with app.user(): + # Create mock signup + str(app.data.driver.db['signups'].insert({'nethz': 'igor', + 'course': 'hunting'})) + + # GET on the event to get the _etag + url = '/signups?where={"nethz":"igor", "course":"hunting"}' + r = app.client.get(url, assert_status=200) + etag = r['_etag'] + + # Prepare and send PATCH request + headers = {'If-Match': etag} + payload = {"checked_in": "True"} + app.client.patch(url, headers=headers, data=payload, assert_status=422) + + with app.admin(): + # Create mock signup + str(app.data.driver.db['signups'].insert({ + 'nethz': 'igor', + 'course': 'hunting'})) + + # GET on the event to get the _etag + url = '/signups?where={"nethz":"igor", "course":"hunting"}' + r = app.client.get(url, assert_status=200) + etag = r['_etag'] + + # Prepare and send PATCH request + headers = {'If-Match': etag} + payload = {"checked_in": "True"} + app.client.patch(url, headers=headers, data=payload, assert_status=200) diff --git a/Backend/tests/test_signups.py b/Backend/tests/test_signups.py index 6ea2df7f9703fc13df472083fbaed4b85d43e6e0..cc9320cfcd7891c72a834dd7fadfa7e27b1e3852 100644 --- a/Backend/tests/test_signups.py +++ b/Backend/tests/test_signups.py @@ -46,7 +46,7 @@ def test_success(app): def test_zero_spots(app): - """Settings spots to zero will just put everyone on the waiting list.""" + """Setting spots to zero will just put everyone on the waiting list.""" with app.admin(): # Create fake courses to sign up to course_id = str(app.data.driver.db['courses'].insert({'spots': 0})) @@ -99,7 +99,7 @@ def test_not_enough_spots(app): def test_update_spots(app): """Test the main update function. - As a key for sorting the _updated timestamp will be used, with + As a key for sorting, the _updated timestamp will be used, with nethz as a tie breaker """ with app.admin():