Projet

Général

Profil

0001-data_transfer-check-that-import-is-a-dictionnary.patch

Benjamin Dauvergne, 06 décembre 2018 10:24

Télécharger (1,4 ko)

Voir les différences:

Subject: [PATCH] data_transfer: check that import is a dictionnary

 src/authentic2/data_transfer.py | 3 +++
 tests/test_manager.py           | 5 +++++
 2 files changed, 8 insertions(+)
src/authentic2/data_transfer.py
246 246
def import_site(json_d, import_context):
247 247
    result = ImportResult()
248 248

  
249
    if not isinstance(json_d, dict):
250
        raise DataImportError('Export file is invalid: not a dictionnary')
251

  
249 252
    for ou_d in json_d.get('ous', []):
250 253
        result.update_ous(*import_ou(ou_d))
251 254

  
tests/test_manager.py
667 667
    with pytest.raises(Role.DoesNotExist):
668 668
        Role.objects.get(slug='basic')
669 669

  
670
    form['site_json'] = Upload(
671
        'site_export.json', json.dumps([]), 'application/octet-stream')
672
    res = form.submit()
673
    assert res.status_code == 200
674

  
670 675

  
671 676
def test_manager_site_import_forbidden(app, simple_user):
672 677
    login(app, simple_user)
673
-