Exemplo n.º 1
0
    def test_user_base(self):
        """ Instanciate a BonitaUser with base properties """
        xml = build_bonita_user_xml('user uuid', 'user pass', 'user name')

        user = BonitaUser._instanciate_from_xml(xml)

        assert isinstance(user, BonitaUser)
        assert user.is_modified is False
        assert user.uuid == u'user uuid'
        assert user.username == u'user name'
        assert user.password == u'user pass'
Exemplo n.º 2
0
    def test_user_optional(self):
        """ Instanciate a BonitaUser with optional properties """
        user_properties = {'firstName': u'firstname', 'lastName': u'lastname',
                           'title': u'title', 'jobTitle': u'jobtitle'}
        xml = build_bonita_user_xml('user uuid', 'user pass', 'user name', user_properties)

        user = BonitaUser._instanciate_from_xml(xml)

        assert isinstance(user, BonitaUser)
        assert user.is_modified is False
        assert user.uuid == u'user uuid'
        assert user.username == u'user name'
        assert user.password == u'user pass'
        assert user.firstName == u'firstname'
        assert user.lastName == u'lastname'
        assert user.title == u'title'
        assert user.jobTitle == u'jobtitle'
Exemplo n.º 3
0
    def test_user_with_memberships(self):
        """ Instanciate a BonitaUser with memberships """
        role = BonitaRole('myrole', '', '')
        role.uuid = '1234'

        group1 = BonitaGroup('mygroup1', '', '')
        group1.uuid = '2345'
        group2 = BonitaGroup('mygroup2', '', '')
        group2.uuid = '2346'

        membership1 = BonitaMembership(role, group1)
        membership1.uuid = 'uuid-12'
        membership2 = BonitaMembership(role, group2)
        membership2.uuid = 'uuid-13'

        user_properties = {'firstName': u'firstname', 'lastName': u'lastname',
                           'title': u'title', 'jobTitle': u'jobtitle',
                           'memberships': [membership1, membership2]}
        xml = build_bonita_user_xml('user uuid', 'user pass', 'user name', user_properties)

        user = BonitaUser._instanciate_from_xml(xml)

        assert isinstance(user, BonitaUser)

        assert isinstance(user.memberships, list)
        assert len(user.memberships) == 2

        assert isinstance(user.roles, list)
        #assert len(user.roles) == 1
        assert user.roles[0].name == u'myrole'

        assert isinstance(user.groups, list)
        #assert len(user.groups) == 2
        group_names = [group.name for group in user.groups]
        assert u'mygroup1' in group_names
        assert u'mygroup2' in group_names
Exemplo n.º 4
0
    def test_invalid_xml(self):
        """ Try to instanciate a BonitaUser from invalid XML """
        xml = '<coucou>une valeur</coucou>'

        BonitaUser._instanciate_from_xml(xml)