5 |
5 |
from wcs.qommon.http_request import HTTPRequest
|
6 |
6 |
from wcs.ctl.hobo_notify import CmdHoboNotify
|
7 |
7 |
from wcs.roles import Role
|
|
8 |
from wcs.qommon import storage as st
|
8 |
9 |
|
9 |
10 |
from utilities import create_temporary_pub, clean_temporary_pub
|
10 |
11 |
|
... | ... | |
684 |
685 |
CmdHoboNotify.process_notification(notification)
|
685 |
686 |
assert e.value.args == ('invalid role',)
|
686 |
687 |
assert Role.count() == 0
|
|
688 |
|
|
689 |
|
|
690 |
def test_process_user_deprovision(pub):
|
|
691 |
User = pub.user_class
|
|
692 |
|
|
693 |
# setup an hobo profile
|
|
694 |
from wcs.ctl.check_hobos import CmdCheckHobos
|
|
695 |
User.wipe()
|
|
696 |
Role.wipe()
|
|
697 |
CmdCheckHobos().update_profile(PROFILE, pub)
|
|
698 |
|
|
699 |
user = User()
|
|
700 |
user.name = 'Pierre'
|
|
701 |
user.name_identifiers = ['a' * 32]
|
|
702 |
user.store()
|
|
703 |
|
|
704 |
notification = {
|
|
705 |
u'@type': u'deprovision',
|
|
706 |
u'issuer': 'http://idp.example.net/idp/saml/metadata',
|
|
707 |
u'audience': [u'test'],
|
|
708 |
u'objects': {
|
|
709 |
u'@type': 'user',
|
|
710 |
u'data': [
|
|
711 |
{
|
|
712 |
u'uuid': u'a' * 32,
|
|
713 |
}
|
|
714 |
]
|
|
715 |
}
|
|
716 |
}
|
|
717 |
|
|
718 |
assert User.count() == 1
|
|
719 |
assert len(User.select([st.Equal('deleted', True)])) == 0
|
|
720 |
CmdHoboNotify.process_notification(notification)
|
|
721 |
assert User.count() == 1
|
|
722 |
assert len(User.select([st.Equal('deleted', True)])) == 1
|
|
723 |
User.clean_deleted_users()
|
|
724 |
assert User.count() == 0
|
|
725 |
|
|
726 |
|
|
727 |
def test_process_user_deprovision_with_data(pub):
|
|
728 |
from wcs.formdef import FormDef
|
|
729 |
|
|
730 |
User = pub.user_class
|
|
731 |
|
|
732 |
# setup an hobo profile
|
|
733 |
from wcs.ctl.check_hobos import CmdCheckHobos
|
|
734 |
User.wipe()
|
|
735 |
FormDef.wipe()
|
|
736 |
CmdCheckHobos().update_profile(PROFILE, pub)
|
|
737 |
|
|
738 |
user = User()
|
|
739 |
user.name = 'Pierre'
|
|
740 |
user.name_identifiers = ['a' * 32]
|
|
741 |
user.store()
|
|
742 |
|
|
743 |
formdef = FormDef()
|
|
744 |
formdef.name = 'foobar'
|
|
745 |
formdef.url_name = 'foobar'
|
|
746 |
formdef.fields = []
|
|
747 |
formdef.store()
|
|
748 |
data_class = formdef.data_class()
|
|
749 |
|
|
750 |
formdata = data_class()
|
|
751 |
formdata.user_id = user.id
|
|
752 |
formdata.store()
|
|
753 |
|
|
754 |
notification = {
|
|
755 |
u'@type': u'deprovision',
|
|
756 |
u'issuer': 'http://idp.example.net/idp/saml/metadata',
|
|
757 |
u'audience': [u'test'],
|
|
758 |
u'objects': {
|
|
759 |
u'@type': 'user',
|
|
760 |
u'data': [
|
|
761 |
{
|
|
762 |
u'uuid': u'a' * 32,
|
|
763 |
}
|
|
764 |
]
|
|
765 |
}
|
|
766 |
}
|
|
767 |
|
|
768 |
assert User.count() == 1
|
|
769 |
assert len(User.select([st.Equal('deleted', True)])) == 0
|
|
770 |
CmdHoboNotify.process_notification(notification)
|
|
771 |
assert User.count() == 1
|
|
772 |
assert len(User.select([st.Equal('deleted', True)])) == 1
|
|
773 |
User.clean_deleted_users()
|
|
774 |
assert User.count() == 1
|