0002-check_hobos-add-default-phone-field-users-config-698.patch
tests/test_hobo_notify.py | ||
---|---|---|
449 | 449 |
from wcs.ctl.check_hobos import CmdCheckHobos |
450 | 450 | |
451 | 451 |
# setup an hobo profile |
452 |
assert 'users' not in pub.cfg |
|
452 | 453 |
CmdCheckHobos().update_profile(PROFILE, pub) |
454 |
assert pub.cfg['users']['field_phone'] == '_phone' |
|
453 | 455 | |
454 | 456 |
uuid1 = str(uuid.uuid4()) |
455 | 457 |
uuid2 = str(uuid.uuid4()) |
... | ... | |
515 | 517 |
'first_name': 'John', |
516 | 518 |
'last_name': 'Doé', |
517 | 519 |
'email': 'john.doe@example.net', |
520 |
'phone': '+33123456789', |
|
518 | 521 |
'zipcode': '13400', |
519 | 522 |
'is_superuser': False, |
520 | 523 |
'is_active': True, |
... | ... | |
540 | 543 |
assert user.form_data is not None |
541 | 544 |
assert user.form_data['_email'] == 'john.doe@example.net' |
542 | 545 |
assert user.email == 'john.doe@example.net' |
546 |
assert user.form_data['_phone'] == '+33123456789' |
|
543 | 547 |
assert user.form_data['_first_name'] == 'John' |
544 | 548 |
assert user.form_data['_last_name'] == force_str('Doé') |
545 | 549 |
assert user.form_data['_zipcode'] == '13400' |
... | ... | |
668 | 672 |
assert User.select()[0].first_name == 'John' |
669 | 673 |
assert not User.select()[0].email |
670 | 674 | |
675 |
# check provisionning an account with no phone works |
|
676 |
for no_phone in (None, ''): |
|
677 |
User.wipe() |
|
678 |
notification = { |
|
679 |
'@type': 'provision', |
|
680 |
'issuer': 'http://idp.example.net/idp/saml/metadata', |
|
681 |
'audience': ['test'], |
|
682 |
'objects': { |
|
683 |
'@type': 'user', |
|
684 |
'data': [ |
|
685 |
{ |
|
686 |
'uuid': 'a' * 32, |
|
687 |
'first_name': 'John', |
|
688 |
'last_name': 'Doé', |
|
689 |
'email': 'john.doe@example.net', |
|
690 |
'phone': no_phone, |
|
691 |
'zipcode': '13400', |
|
692 |
'is_superuser': False, |
|
693 |
'roles': [ |
|
694 |
{ |
|
695 |
'uuid': uuid1, |
|
696 |
'name': 'Service petite enfance', |
|
697 |
'description': 'etc.', |
|
698 |
}, |
|
699 |
{ |
|
700 |
'uuid': uuid2, |
|
701 |
'name': 'Service état civil', |
|
702 |
'description': 'etc.', |
|
703 |
}, |
|
704 |
], |
|
705 |
} |
|
706 |
], |
|
707 |
}, |
|
708 |
} |
|
709 |
CmdHoboNotify.process_notification(notification) |
|
710 |
assert User.count() == 1 |
|
711 |
assert User.select()[0].first_name == 'John' |
|
712 |
assert not User.select()[0].phone |
|
713 | ||
671 | 714 | |
672 | 715 |
def record_error(exception=None, *args, **kwargs): |
673 | 716 |
if exception: |
wcs/ctl/check_hobos.py | ||
---|---|---|
322 | 322 |
formdef.store() |
323 | 323 | |
324 | 324 |
pub.cfg['users']['field_email'] = '_email' |
325 |
if not pub.cfg['users'].get('field_phone'): |
|
326 |
pub.cfg['users']['field_phone'] = '_phone' |
|
325 | 327 |
if not (pub.cfg['users'].get('fullname_template') or pub.cfg['users'].get('field_name')): |
326 | 328 |
pub.cfg['users'][ |
327 | 329 |
'fullname_template' |
328 |
- |