0002-data_transfer-fail-importing-on-empty-role-uuid-3108.patch
src/authentic2/data_transfer.py | ||
---|---|---|
171 | 171 |
status = 'updated' |
172 | 172 |
update_model(self._obj, kwargs) |
173 | 173 |
else: # Create role |
174 |
if 'uuid' in kwargs and not kwargs['uuid']: |
|
175 |
raise DataImportError("Cannot import role '%s' with empty uuid" |
|
176 |
% kwargs.get('name')) |
|
174 | 177 |
self._obj = get_role_model().objects.create(**kwargs) |
175 | 178 |
status = 'created' |
176 | 179 |
tests/test_import_export_site_cmd.py | ||
---|---|---|
200 | 200 |
r1.refresh_from_db() |
201 | 201 |
assert r1.slug == 'slug-updated' |
202 | 202 |
assert r1.name == 'Role second update' |
203 | ||
204 | ||
205 |
def test_import_site_empty_uuids(db, monkeypatch, json_fixture): |
|
206 |
from authentic2.data_transfer import DataImportError |
|
207 |
with pytest.raises(DataImportError): |
|
208 |
management.call_command('import_site', json_fixture({ |
|
209 |
'roles': [ |
|
210 |
{ |
|
211 |
'uuid': '', |
|
212 |
'slug': 'role-slug', |
|
213 |
'name': 'role-name', |
|
214 |
'ou': None, |
|
215 |
'service': None |
|
216 |
} |
|
217 |
] |
|
218 |
})) |
|
203 |
- |