Ejemplo n.º 1
0
    def test_group_with_one_parent(self):
        """ Instanciate a Bonita group with one parent """
        # Build up parent and child XML
        parent_xml = build_bonita_group_xml('parent uuid','parent name','parent description','parent label','12',None, True)
        child_xml = build_bonita_group_xml('group uuid','group name',description='a desc',label='a label')
        
        # Add the parent XML to the Child
        parent_soup = BeautifulSoup(parent_xml,'xml').parentGroup
        child_soup = BeautifulSoup(child_xml,'xml')
        child_soup.Group.append(parent_soup)

        xml = unicode(child_soup.Group)

        group = BonitaGroup._instanciate_from_xml(xml)

        assert isinstance(group,BonitaGroup)
        assert group.uuid == u'group uuid'
        assert group.name == u'group name'
        assert group.description == u'a desc'
        assert group.label == u'a label'

        assert group.parent is not None
        assert isinstance(group.parent, BonitaGroup)
        assert group.parent.uuid == u'parent uuid'
        assert group.parent.parent is None
Ejemplo n.º 2
0
 def test_instanciate_bad_role_xml(self):
     """ Instanciate a Bonita membership from XML : role is not well formed """
     role_xml = '<Role>et boom</Role>'
     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')
     print 'xml : %s (%s)' % (xml,type(xml))
     membership = BonitaMembership._instanciate_from_xml(xml)
Ejemplo n.º 3
0
    def test_known_group_deep_path(self):
        """ Retrieve a group using the path (deep path) """
        # Setup the response for MockServer
        BonitaServer.use('localhost', 9090, 'restuser', 'restbpm')
        url = '/identityAPI/getGroupUsingPath'
        code = 200
        gran_father_xml = build_bonita_group_xml(uuid='996631',name='gran-father',as_parent=True)
        father_xml = build_bonita_group_xml(uuid='996632',name='father',parent=gran_father_xml, as_parent=True)
        xml = build_bonita_group_xml(uuid='996633',name='child-group',parent=father_xml)
        BonitaServer.set_response_list([[url,code,xml]])

        group = BonitaGroup.get_by_path('/gran-father/father/child-group')

        assert isinstance(group,BonitaGroup)
        assert group.uuid == '996633'
        assert isinstance(group.parent,BonitaGroup)
        assert group.parent.uuid == '996632'
        assert isinstance(group.parent.parent,BonitaGroup)
        assert group.parent.parent.uuid == '996631'
Ejemplo n.º 4
0
    def test_group_without_parent(self):
        """ Instanciate a Bonita group without any parent """
        xml = build_bonita_group_xml('group uuid','group name',description='a desc',label='a label')

        group = BonitaGroup._instanciate_from_xml(xml)

        assert isinstance(group,BonitaGroup)
        assert group.uuid == u'group uuid'
        assert group.name == u'group name'
        assert group.description == u'a desc'
        assert group.label == u'a label'
        assert group.parent is None
Ejemplo n.º 5
0
    def test_group_with_several_parents(self):
        """ Instanciate a Boinita group with a hierarchy of parents """
        # Build up parents and child XML
        parentA_xml = build_bonita_group_xml('parentA uuid','parentA name','parentA description','parentA label','vieux-1',None, True)
        parentB_xml = build_bonita_group_xml('parentB uuid','parentB name','parentB description','parentB label','vieux-2',None, True)
        parentC_xml = build_bonita_group_xml('parentC uuid','parentC name','parentC description','parentC label','vieux-3',None, True)
        child_xml = build_bonita_group_xml('group uuid','group name',description='a desc',label='a label')
        
        # Add the hierachy of parents to the Child
        parentA_soup = BeautifulSoup(parentA_xml,'xml').parentGroup
        parentB_soup = BeautifulSoup(parentB_xml,'xml').parentGroup
        parentC_soup = BeautifulSoup(parentC_xml,'xml').parentGroup

        parentB_soup.append(parentC_soup)
        parentA_soup.append(parentB_soup)

        child_soup = BeautifulSoup(child_xml,'xml')
        child_soup.Group.append(parentA_soup)

        xml = unicode(child_soup.Group)

        group = BonitaGroup._instanciate_from_xml(xml)

        assert isinstance(group,BonitaGroup)
        assert group.uuid == u'group uuid'
        assert group.name == u'group name'
        assert group.description == u'a desc'
        assert group.label == u'a label'

        assert group.parent is not None
        assert isinstance(group.parent, BonitaGroup)
        assert group.parent.uuid == u'parentA uuid'

        assert group.parent.parent is not None
        assert isinstance(group.parent.parent, BonitaGroup)
        assert group.parent.parent.uuid == u'parentB uuid'

        assert group.parent.parent.parent is not None
        assert isinstance(group.parent.parent.parent, BonitaGroup)
        assert group.parent.parent.parent.uuid == u'parentC uuid'
Ejemplo n.º 6
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)
Ejemplo n.º 7
0
    def test_known_group(self):
        """ Retrieve a group using the UUID """
        # Setup the response for MockServer
        BonitaServer.use('localhost', 9090, 'restuser', 'restbpm')
        url = '/identityAPI/getGroupByUUID'
        code = 200
        xml = build_bonita_group_xml(uuid='996633',name='mygroup')
        BonitaServer.set_response_list([[url,code,xml]])

        group = BonitaGroup.get_by_uuid('996633')

        assert isinstance(group,BonitaGroup)
        assert group.uuid == '996633'
Ejemplo n.º 8
0
    def test_get_group_by_path(self):
        """ Retrieve a group with path """
        # Setup the response for MockServer
        BonitaServer.use('localhost', 9090, 'restuser', 'restbpm')
        url = '/identityAPI/getGroupUsingPath'
        code = 200
        xml = build_bonita_group_xml(uuid='996633',name='mygroup')
        BonitaServer.set_response_list([[url,code,xml]])

        group = BonitaGroup.get(path='/mygroup')

        assert isinstance(group,BonitaGroup)
        assert group.name == 'mygroup'
Ejemplo n.º 9
0
    def test_root_group(self):
        """ Retrieve root group : /platform """
        # Setup the response for MockServer
        BonitaServer.use('localhost', 9090, 'restuser', 'restbpm')
        url = '/identityAPI/getGroupUsingPath'
        code = 200
        xml = build_bonita_group_xml(uuid='996633',name='platform')
        BonitaServer.set_response_list([[url,code,xml]])

        group = BonitaGroup.get_default_root()

        assert isinstance(group,BonitaGroup)
        assert group.name == u'platform'
        assert group.parent is None
Ejemplo n.º 10
0
    def test_known_group_at_root(self):
        """ Retrieve a group using the path (at root) """
        # Setup the response for MockServer
        BonitaServer.use('localhost', 9090, 'restuser', 'restbpm')
        url = '/identityAPI/getGroupUsingPath'
        code = 200
        xml = build_bonita_group_xml(uuid='996633',name='something')
        BonitaServer.set_response_list([[url,code,xml]])

        group = BonitaGroup.get_by_path('/something')

        assert isinstance(group,BonitaGroup)
        assert group.uuid == '996633'
        assert group.parent is None
Ejemplo n.º 11
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'
Ejemplo n.º 12
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)
Ejemplo n.º 13
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'