Fix #3360 -- Allow to revoke devices before initialized

This commit is contained in:
Raphael Michel
2023-06-04 18:06:00 +02:00
parent 0d93f7f52f
commit 35350a13d6
5 changed files with 39 additions and 7 deletions

View File

@@ -72,6 +72,21 @@ def test_initialize_used_token(client, device: Device):
assert resp.data == {'token': ['This initialization token has already been used.']}
@pytest.mark.django_db
def test_initialize_revoked_token(client, new_device: Device):
new_device.revoked = True
new_device.save()
resp = client.post('/api/v1/device/initialize', {
'token': new_device.initialization_token,
'hardware_brand': 'Samsung',
'hardware_model': 'Galaxy S',
'software_brand': 'pretixdroid',
'software_version': '4.0.0'
})
assert resp.status_code == 400
assert resp.data == {'token': ['This initialization token has been revoked.']}
@pytest.mark.django_db
def test_initialize_valid_token(client, new_device: Device):
resp = client.post('/api/v1/device/initialize', {

View File

@@ -110,6 +110,17 @@ def test_revoke_device(event, admin_user, admin_team, device, client):
assert device.revoked
@pytest.mark.django_db
def test_revoke_device_before_initialization(event, admin_user, admin_team, device, client):
client.login(email='dummy@dummy.dummy', password='dummy')
device.save()
client.get('/control/organizer/dummy/device/{}/revoke'.format(device.pk))
client.post('/control/organizer/dummy/device/{}/revoke'.format(device.pk), {}, follow=True)
device.refresh_from_db()
assert device.revoked
@pytest.mark.django_db
def test_bulk_update_device(event, admin_user, admin_team, device, client):
client.login(email='dummy@dummy.dummy', password='dummy')