6 |
6 |
from wcs.qommon.http_request import HTTPRequest
|
7 |
7 |
from wcs.ctl.hobo_notify import CmdHoboNotify
|
8 |
8 |
from wcs.roles import Role
|
|
9 |
from wcs.qommon import storage as st
|
9 |
10 |
|
10 |
11 |
from utilities import create_temporary_pub, clean_temporary_pub
|
11 |
12 |
|
... | ... | |
716 |
717 |
CmdHoboNotify.process_notification(notification)
|
717 |
718 |
assert e.value.args == ('invalid role',)
|
718 |
719 |
assert Role.count() == 0
|
|
720 |
|
|
721 |
|
|
722 |
def test_process_user_deprovision(pub):
|
|
723 |
User = pub.user_class
|
|
724 |
|
|
725 |
# setup an hobo profile
|
|
726 |
from wcs.ctl.check_hobos import CmdCheckHobos
|
|
727 |
User.wipe()
|
|
728 |
Role.wipe()
|
|
729 |
CmdCheckHobos().update_profile(PROFILE, pub)
|
|
730 |
|
|
731 |
user = User()
|
|
732 |
user.name = 'Pierre'
|
|
733 |
user.name_identifiers = ['a' * 32]
|
|
734 |
user.store()
|
|
735 |
|
|
736 |
notification = {
|
|
737 |
u'@type': u'deprovision',
|
|
738 |
u'issuer': 'http://idp.example.net/idp/saml/metadata',
|
|
739 |
u'audience': [u'test'],
|
|
740 |
u'objects': {
|
|
741 |
u'@type': 'user',
|
|
742 |
u'data': [
|
|
743 |
{
|
|
744 |
u'uuid': u'a' * 32,
|
|
745 |
}
|
|
746 |
]
|
|
747 |
}
|
|
748 |
}
|
|
749 |
|
|
750 |
assert User.count() == 1
|
|
751 |
assert len(User.select([st.Equal('deleted', True)])) == 0
|
|
752 |
CmdHoboNotify.process_notification(notification)
|
|
753 |
assert User.count() == 1
|
|
754 |
assert len(User.select([st.Equal('deleted', True)])) == 1
|
|
755 |
pub.clean_deleted_users()
|
|
756 |
assert User.count() == 0
|
|
757 |
|
|
758 |
|
|
759 |
def test_process_user_deprovision_with_data(pub):
|
|
760 |
from wcs.formdef import FormDef
|
|
761 |
|
|
762 |
User = pub.user_class
|
|
763 |
|
|
764 |
# setup an hobo profile
|
|
765 |
from wcs.ctl.check_hobos import CmdCheckHobos
|
|
766 |
User.wipe()
|
|
767 |
FormDef.wipe()
|
|
768 |
CmdCheckHobos().update_profile(PROFILE, pub)
|
|
769 |
|
|
770 |
user = User()
|
|
771 |
user.name = 'Pierre'
|
|
772 |
user.name_identifiers = ['a' * 32]
|
|
773 |
user.store()
|
|
774 |
|
|
775 |
formdef = FormDef()
|
|
776 |
formdef.name = 'foobar'
|
|
777 |
formdef.url_name = 'foobar'
|
|
778 |
formdef.fields = []
|
|
779 |
formdef.store()
|
|
780 |
data_class = formdef.data_class()
|
|
781 |
|
|
782 |
formdata = data_class()
|
|
783 |
formdata.user_id = user.id
|
|
784 |
formdata.store()
|
|
785 |
|
|
786 |
notification = {
|
|
787 |
u'@type': u'deprovision',
|
|
788 |
u'issuer': 'http://idp.example.net/idp/saml/metadata',
|
|
789 |
u'audience': [u'test'],
|
|
790 |
u'objects': {
|
|
791 |
u'@type': 'user',
|
|
792 |
u'data': [
|
|
793 |
{
|
|
794 |
u'uuid': u'a' * 32,
|
|
795 |
}
|
|
796 |
]
|
|
797 |
}
|
|
798 |
}
|
|
799 |
|
|
800 |
assert User.count() == 1
|
|
801 |
assert len(User.select([st.Equal('deleted', True)])) == 0
|
|
802 |
CmdHoboNotify.process_notification(notification)
|
|
803 |
assert User.count() == 1
|
|
804 |
assert len(User.select([st.Equal('deleted', True)])) == 1
|
|
805 |
pub.clean_deleted_users()
|
|
806 |
assert User.count() == 1
|