Esempio n. 1
0
    def test_instanciate_bad_group_xml(self):
        """ Instanciate a Bonita membership from XML : group is not well formed """
        role_xml = build_bonita_role_xml(uuid='334455',name='myrole',with_class=True)
        group_xml = '<PasGroup><uuid>1234</uuid></PasGroup>'
        xml = build_bonita_membership_xml(uuid='uuid-12',role=role_xml, group=group_xml,dbid='dbid-1234')

        membership = BonitaMembership._instanciate_from_xml(xml)
Esempio n. 2
0
    def test_role(self):
        """ Instanciate a Bonita role """
        xml = build_bonita_role_xml('role uuid','role name',description='a role desc',label='a role label',dbid='dbid-1234')

        role = BonitaRole._instanciate_from_xml(xml)

        assert isinstance(role,BonitaRole)
        assert role.uuid == u'role uuid'
        assert role.name == u'role name'
        assert role.description == u'a role desc'
        assert role.label == u'a role label'
        assert role.dbid == u'dbid-1234'
Esempio n. 3
0
    def test_instanciate(self):
        """ Instanciate a Bonita membership from XML """
        role_xml = build_bonita_role_xml(uuid='334455',name='myrole',with_class=True)
        group_xml = build_bonita_group_xml(uuid='112233',name='mygroup',with_class=True)
        xml = build_bonita_membership_xml(uuid='uuid-12',role=role_xml, group=group_xml,dbid='dbid-1234')

        membership = BonitaMembership._instanciate_from_xml(xml)

        assert isinstance(membership,BonitaMembership)
        assert membership.uuid == u'uuid-12'
        assert membership.dbid == u'dbid-1234'
        assert isinstance(membership.role,BonitaRole)
        assert isinstance(membership.group,BonitaGroup)
Esempio n. 4
0
    def test_get_role_by_name(self):
        """ Retrieve a role with name """
        # Setup the response for MockServer
        BonitaServer.use('localhost', 9090, 'restuser', 'restbpm')
        url = '/identityAPI/getRole'
        code = 200
        xml = build_bonita_role_xml(uuid='996633',name='myrole')
        BonitaServer.set_response_list([[url,code,xml]])

        role = BonitaRole.get(name='myrole')

        assert isinstance(role,BonitaRole)
        assert role.name == 'myrole'
Esempio n. 5
0
    def test_known_membership(self):
        """ Retrieve a membership using the UUID """
        # Setup the response for MockServer
        BonitaServer.use('localhost', 9090, 'restuser', 'restbpm')
        url = '/identityAPI/getMembershipByUUID'
        code = 200
        role_xml = build_bonita_role_xml(uuid='334455',name='myrole',with_class=True)
        group_xml = build_bonita_group_xml(uuid='112233',name='mygroup',with_class=True)
        xml = build_bonita_membership_xml(uuid='996633',role=role_xml, group=group_xml)
        BonitaServer.set_response_list([[url,code,xml]])

        membership = BonitaMembership.get_by_uuid('996633')

        assert isinstance(membership,BonitaMembership)
        assert membership.uuid == '996633'
Esempio n. 6
0
    def test_get_membership_by_uuid(self):
        """ Retrieve a membership using UUID """
        BonitaServer.use('localhost', 9090, 'restuser', 'restbpm')
        url = '/identityAPI/getMembershipByUUID'
        code = 200
        role_xml = build_bonita_role_xml(uuid='334455',name='myrole',with_class=True)
        group_xml = build_bonita_group_xml(uuid='112233',name='mygroup',with_class=True)
        xml = build_bonita_membership_xml(uuid='uuid-12',role=role_xml, group=group_xml)
        BonitaServer.set_response_list([[url,code,xml]])

        membership = BonitaMembership.get_by_uuid('uuid-12')

        assert isinstance(membership,BonitaMembership)
        assert membership.uuid == u'uuid-12'
        assert isinstance(membership.role,BonitaRole)
        assert isinstance(membership.group,BonitaGroup)
Esempio n. 7
0
    def test_get_membership_by_role_and_group_uuid(self):
        """ Retrieve a membership using role and group UUID """
        BonitaServer.use('localhost', 9090, 'restuser', 'restbpm')
        url = '/identityAPI/getMembershipForRoleAndGroup'
        code = 200

        role_xml = build_bonita_role_xml(uuid='334455',name='role-2',with_class=True)
        group_xml = build_bonita_group_xml(uuid='112233',name='group-14',with_class=True)
        xml = build_bonita_membership_xml(uuid='996633',role=role_xml, group=group_xml)
        BonitaServer.set_response_list([[url,code,xml]])

        membership = BonitaMembership.get(role_uuid='334455',group_uuid='112233')

        assert isinstance(membership,BonitaMembership)
        assert isinstance(membership.role,BonitaRole)
        assert membership.role.uuid == u'334455'
        assert isinstance(membership.group,BonitaGroup)
        assert membership.group.uuid == u'112233'