Projet

Général

Profil

0002-hobo_notify-set-is_active-attribute-42428.patch

Benjamin Dauvergne, 07 juillet 2020 16:36

Télécharger (3,05 ko)

Voir les différences:

Subject: [PATCH 2/5] hobo_notify: set is_active attribute (#42428)

 tests/test_hobo_notify.py | 4 ++++
 wcs/ctl/hobo_notify.py    | 7 +++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
tests/test_hobo_notify.py
514 514
                    u'email': u'john.doe@example.net',
515 515
                    u'zipcode': u'13400',
516 516
                    u'is_superuser': False,
517
                    'is_active': True,
517 518
                    u'roles': [
518 519
                        {
519 520
                            u'uuid': u'12345',
......
542 543
    assert user.form_data['_birthdate'] is None
543 544
    assert user.name_identifiers == ['a'*32]
544 545
    assert user.is_admin is False
546
    assert user.is_active is True
545 547
    assert set(user.roles) == set([new_role.id, old_role.id])
546 548

  
547 549
    notification = {
......
559 561
                    u'zipcode': u'13600',
560 562
                    u'birthdate': u'2000-01-01',
561 563
                    u'is_superuser': True,
564
                    'is_active': False,
562 565
                    u'roles': [
563 566
                        {
564 567
                            u'uuid': u'xyz',
......
587 590
    assert user.form_data['_birthdate'].tm_year == 2000
588 591
    assert user.name_identifiers == ['a'*32]
589 592
    assert user.is_admin is True
593
    assert user.is_active is False
590 594
    assert set(user.roles) == set([old_role.id])
591 595

  
592 596
    for birthdate in ('baddate', '', None):
wcs/ctl/hobo_notify.py
191 191
                        user.form_data[field.id] = field_value
192 192
                    user.name_identifiers = [uuid]
193 193
                    # reset roles
194
                    user.is_active = o.get('is_active', True)
194 195
                    user.is_admin = o.get('is_superuser', False)
195 196
                    user.roles = []
196 197
                    for role_ref in o.get('roles', []):
......
208 209
                elif action == 'deprovision':
209 210
                    if 'uuid' not in o:
210 211
                        raise KeyError('user without uuid')
211
                    # do not remove for real
212
                    pass
212
                    # make user inactive, he will be deleted later
213
                    for user in User.get_users_with_name_identifier(uuid):
214
                        user.is_active = False
215
                        user.store()
213 216
            except Exception as e:
214 217
                publisher.notify_of_exception(sys.exc_info(), context='[PROVISIONNING]')
215 218

  
216
-