コード例 #1
0
ファイル: idwsf1_tests.py プロジェクト: smartdata-x/mylib
    def test01(self):
        '''Test a data service query'''
        wsc_service = self.get_pp_service()
        wsc_service.initQuery('/pp10:PP/pp10:InformalName', 'name')
        wsc_service.buildSoapRequestMsg()
        self.failUnless(
            lasso.getRequestTypeFromSoapMsg(wsc_service.msgBody) ==
            lasso.REQUEST_TYPE_DST_QUERY)

        self.wsp = self.get_wsp_server()
        wsp_service = lasso.DataService(self.wsp)
        wsp_service.processRequestMsg(wsc_service.msgBody)
        self.failUnless(isinstance(wsp_service.request, lasso.DstQuery))
        wsp_service.resourceData = '''
            <PP xmlns="urn:liberty:id-sis-pp:2003-08">
                    <InformalName>Damien</InformalName>
            </PP>'''
        wsp_service.validateRequest()
        wsp_service.buildResponseMsg()

        wsc_service.processQueryResponseMsg(wsp_service.msgBody)
        self.failUnless(
            wsc_service.getAnswer() ==
            '<InformalName xmlns="urn:liberty:id-sis-pp:2003-08">Damien</InformalName>'
        )
コード例 #2
0
ファイル: idwsf1_tests.py プロジェクト: smartdata-x/mylib
    def test03(self):
        '''Test a data service modify with redirect for consent'''

        xpath = '/pp:PP/pp:InformalName'
        old_data = '''<PP xmlns="urn:liberty:id-sis-pp:2003-08">
                <InformalName>Damien</InformalName>
            </PP>'''
        new_data = '<InformalName>Alain</InformalName>'

        new_full_data = '''<PP xmlns="urn:liberty:id-sis-pp:2003-08">
                <pp:InformalName xmlns:pp="urn:liberty:id-sis-pp:2003-08">Alain</pp:InformalName>
            </PP>'''
        redir_url = 'http://site/redirect_for_consent'

        wsc_service = self.get_pp_service()
        wsc_service.initModify()
        wsc_service.addModification(xpath, new_data, overrideAllowed=True)
        wsc_service.buildRequestMsg()

        request_type = lasso.getRequestTypeFromSoapMsg(wsc_service.msgBody)
        self.failUnless(request_type == lasso.REQUEST_TYPE_DST_MODIFY)

        self.wsp = self.get_wsp_server()
        wsp_service = lasso.DataService(self.wsp)
        wsp_service.processRequestMsg(wsc_service.msgBody)
        wsp_service.resourceData = old_data

        wsp_service.initInteractionServiceRedirect(redir_url)
        wsp_service.buildModifyResponseMsg()
        # Save the new wsp_service.resourceData here

        # Data mustn't have been modified here
        self.failUnless(wsp_service.resourceData == old_data)
        self.failUnless(wsp_service.msgBody is not None)

        try:
            wsc_service.processModifyResponseMsg(wsp_service.msgBody)
        except lasso.SoapRedirectRequestFaultError:
            pass
        except Exception, e:
            self.fail(e)
コード例 #3
0
ファイル: idwsf1_tests.py プロジェクト: smartdata-x/mylib
    def test01(self):
        '''Test a data service modify'''

        xpath = '/pp10:PP/pp10:InformalName'
        old_data = '''
            <PP xmlns="urn:liberty:id-sis-pp:2003-08">
                <InformalName>Damien</InformalName>
            </PP>'''
        new_data = '<InformalName>Alain</InformalName>'

        new_full_data = '''<PP xmlns="urn:liberty:id-sis-pp:2003-08">
                <pp10:InformalName xmlns:pp10="urn:liberty:id-sis-pp:2003-08">Alain</pp10:InformalName>
            </PP>'''

        wsc_service = self.get_pp_service()
        wsc_service.initModify()
        wsc_service.addModification(xpath, new_data, overrideAllowed=True)
        wsc_service.buildRequestMsg()

        request_type = lasso.getRequestTypeFromSoapMsg(wsc_service.msgBody)
        self.failUnless(request_type == lasso.REQUEST_TYPE_DST_MODIFY)

        self.wsp = self.get_wsp_server()
        wsp_service = lasso.DataService(self.wsp)
        wsp_service.processRequestMsg(wsc_service.msgBody)

        item = wsp_service.request.modification[0]
        self.failUnless(
            item.newData.any[0] ==
            '<pp10:InformalName xmlns:pp10="urn:liberty:id-sis-pp:2003-08">Alain</pp10:InformalName>'
        )
        self.failUnless(item.select == '/pp10:PP/pp10:InformalName')

        wsp_service.resourceData = old_data
        wsp_service.validateRequest()
        wsp_service.buildModifyResponseMsg()
        # Save the new wsp_service.resourceData here

        self.failUnless(wsp_service.resourceData == new_full_data)

        wsc_service.processModifyResponseMsg(wsp_service.msgBody)