0007-hobo_notify-save-user-s-phone-number-upon-provisionn.patch
tests/test_hobo_notify.py | ||
---|---|---|
515 | 515 |
'first_name': 'John', |
516 | 516 |
'last_name': 'Doé', |
517 | 517 |
'email': 'john.doe@example.net', |
518 |
'phone': '+33123456789', |
|
518 | 519 |
'zipcode': '13400', |
519 | 520 |
'is_superuser': False, |
520 | 521 |
'is_active': True, |
... | ... | |
540 | 541 |
assert user.form_data is not None |
541 | 542 |
assert user.form_data['_email'] == 'john.doe@example.net' |
542 | 543 |
assert user.email == 'john.doe@example.net' |
544 |
assert user.phone == '+33123456789' |
|
543 | 545 |
assert user.form_data['_first_name'] == 'John' |
544 | 546 |
assert user.form_data['_last_name'] == force_str('Doé') |
545 | 547 |
assert user.form_data['_zipcode'] == '13400' |
... | ... | |
668 | 670 |
assert User.select()[0].first_name == 'John' |
669 | 671 |
assert not User.select()[0].email |
670 | 672 | |
673 |
# check provisionning an account with no phone works |
|
674 |
for no_phone in (None, ''): |
|
675 |
User.wipe() |
|
676 |
notification = { |
|
677 |
'@type': 'provision', |
|
678 |
'issuer': 'http://idp.example.net/idp/saml/metadata', |
|
679 |
'audience': ['test'], |
|
680 |
'objects': { |
|
681 |
'@type': 'user', |
|
682 |
'data': [ |
|
683 |
{ |
|
684 |
'uuid': 'a' * 32, |
|
685 |
'first_name': 'John', |
|
686 |
'last_name': 'Doé', |
|
687 |
'email': 'john.doe@example.net', |
|
688 |
'phone': no_phone, |
|
689 |
'zipcode': '13400', |
|
690 |
'is_superuser': False, |
|
691 |
'roles': [ |
|
692 |
{ |
|
693 |
'uuid': uuid1, |
|
694 |
'name': 'Service petite enfance', |
|
695 |
'description': 'etc.', |
|
696 |
}, |
|
697 |
{ |
|
698 |
'uuid': uuid2, |
|
699 |
'name': 'Service état civil', |
|
700 |
'description': 'etc.', |
|
701 |
}, |
|
702 |
], |
|
703 |
} |
|
704 |
], |
|
705 |
}, |
|
706 |
} |
|
707 |
CmdHoboNotify.process_notification(notification) |
|
708 |
assert User.count() == 1 |
|
709 |
assert User.select()[0].first_name == 'John' |
|
710 |
assert not User.select()[0].phone |
|
711 | ||
671 | 712 | |
672 | 713 |
def record_error(exception=None, *args, **kwargs): |
673 | 714 |
if exception: |
wcs/ctl/hobo_notify.py | ||
---|---|---|
168 | 168 |
else: |
169 | 169 |
user = User(uuid) |
170 | 170 |
user.form_data = user.form_data or {} |
171 |
if 'phone' in o: |
|
172 |
user.phone = o.pop('phone') |
|
171 | 173 |
for field in formdef.fields: |
172 | 174 |
if not field.id.startswith('_'): |
173 | 175 |
continue |
174 |
- |