예제 #1
0
    def selectItem(self, title, item_type="Workspace"):
        fl = self.fl
        html = fl.getBody()
        if item_type in ['Section', 'SectionRoot']:
            start = html.find('form id="section_content"')
        else:
            start = html.find('form id="document_content"')
        end = html.find(title, start)
        fl.assert_(end > 0, 'Item with title "%s" not found.' % title)
        start = html.rfind('<tr class', start, end)

        checkbox_id = extractToken(html[start:end], 'input id="', '"')
        fl.assert_(checkbox_id, 'item "%s" not found.' % title)
        checkbox_ajax_onclick_id = checkbox_id + '_ajax_onclick'
        table_name = checkbox_id.split(':', 1)[0]

        params = [
            ['AJAXREQUEST', 'cv_' + table_name + '_0_region'],
            [checkbox_id, 'on'],
            ['javax.faces.ViewState', fl.getLastJsfState()],
            [checkbox_ajax_onclick_id, checkbox_ajax_onclick_id],
            [table_name, table_name]]
        fl.post(fl.server_url + "/view_documents.faces", params,
                description='Select document "%s"' % title)

        return self
예제 #2
0
파일: pages.py 프로젝트: skogtroll/nuxeo
    def selectItem(self, title, item_type="Workspace"):
        fl = self.fl
        html = fl.getBody()
        if item_type in ['Section', 'SectionRoot']:
            start = html.find('form id="section_content"')
        else:
            start = html.find('form id="document_content"')
        end = html.find(title, start)
        fl.assert_(end > 0, 'Item with title "%s" not found.' % title)
        start = html.rfind('<tr class', start, end)

        checkbox_id = extractToken(html[start:end], 'input id="', '"')
        fl.assert_(checkbox_id, 'item "%s" not found.' % title)
        table_name = checkbox_id.split(':', 1)[0]

        params = [[table_name, table_name], [checkbox_id, 'on'],
                  ['javax.faces.ViewState',
                   fl.getLastJsfState()], ['javax.faces.source', checkbox_id],
                  ['javax.faces.partial.event', 'click'],
                  ['javax.faces.partial.execute', checkbox_id],
                  [
                      'javax.faces.partial.render',
                      table_name + '_buttons:ajax_selection_buttons'
                  ], ['javax.faces.behavior.event', 'click'],
                  ['AJAX:EVENTS_COUNT', '1'], ['rfExt', 'null'],
                  ['javax.faces.partial.ajax', 'true']]

        fl.post(fl.server_url + "/view_documents.faces",
                params,
                description='Select document "%s"' % title)

        return self
예제 #3
0
    def selectItem(self, title, item_type="Workspace"):
        fl = self.fl
        html = fl.getBody()
        if item_type in ['Section', 'SectionRoot']:
            start = html.find('form id="section_content"')
        else:
            start = html.find('form id="document_content"')
        end = html.find(title, start)
        fl.assert_(end > 0, 'Item with title "%s" not found.' % title)
        start = html.rfind('<tr class', start, end)

        checkbox_id = extractToken(html[start:end], 'input id="', '"')
        fl.assert_(checkbox_id, 'item "%s" not found.' % title)
        table_name = checkbox_id.split(':', 1)[0]

        params = [
            [table_name, table_name],
            [checkbox_id, 'on'],
            ['javax.faces.ViewState', fl.getLastJsfState()],
            ['javax.faces.source', checkbox_id],
            ['javax.faces.partial.event', 'click'],
            ['javax.faces.partial.execute', checkbox_id],
            ['javax.faces.partial.render', table_name + '_buttons:ajax_selection_buttons'],
            ['javax.faces.behavior.event', 'click'],
            ['AJAX:EVENTS_COUNT', '1'],
            ['rfExt', 'null'],
            ['javax.faces.partial.ajax', 'true']]

        fl.post(fl.server_url + "/view_documents.faces", params,
                description='Select document "%s"' % title)

        return self
예제 #4
0
 def viewRandomDocument(self, pattern):
     fl = self.fl
     # hack to parse only the table listing instead of the broken html page
     table = extractToken(self.fl.getBody(), '<table class="dataOutput">', "</table")
     self.fl._response.body = table
     hrefs = fl.listHref(content_pattern=pattern, url_pattern="@view_documents")
     fl.assert_(len(hrefs), "No doc found with pattern: " + pattern)
     doc_url = random.choice(hrefs)
     fl.get(doc_url, description="View a random document")
     return DocumentPage(self.fl)
예제 #5
0
 def viewRandomDocument(self, pattern):
     fl = self.fl
     # hack to parse only the table listing instead of the broken html page
     table = extractToken(self.fl.getBody(),
                          '<table class="dataOutput">', '</table')
     self.fl._response.body = table
     hrefs = fl.listHref(content_pattern=pattern,
                         url_pattern='@view_documents')
     fl.assert_(len(hrefs), "No doc found with pattern: " + pattern)
     doc_url = random.choice(hrefs)
     fl.get(doc_url, description="View a random document")
     return DocumentPage(self.fl)
예제 #6
0
    def selectItem(self, title, item_type="Workspace"):
        fl = self.fl
        conversation_id = self.getConversationId()
        folder_uid = self.getDocUid()
        html = fl.getBody()
        if item_type in ['Section', 'SectionRoot']:
            start = html.find('form id="section_content"')
        else:
            start = html.find('form id="document_content"')
        end = html.find(title, start)
        fl.assert_(end > 0, 'Item with title "%s" not found.' % title)
        start = html.rfind('<tr class', start, end)

        # seam remoting selection is now done in ajax
#        doc_uid = extractToken(html[start:end], 'docRef:', '"')
#        fl.assert_(doc_uid, 'item "%s" not found.' % title)
#        sel = 'CURRENT_SELECTION'
#        if item_type == "Section":
#            sel = 'CURRENT_SELECTION_SECTIONS'
#        xml = '''<envelope><header><context><conversationId>%s</conversationId></context></header><body><call component="documentActions" method="checkCurrentDocAndProcessSelectRow" id="0">
#<params><param><str>%s</str></param><param><str>CURRENT_DOC_CHILDREN</str></param><param><str>%s</str></param><param><bool>true</bool></param><param><str>%s</str></param></params><refs></refs></call></body></envelope>''' % (
#            conversation_id, doc_uid, sel, folder_uid)
#        #print "%s" % xml
#        fl.post(fl.server_url + "/seam/resource/remoting/execute",
#                Data('application/xml; charset=UTF-8',
#                     xml),
#                description="Select document")
#        fl.assert_(sel + "_TRASH" in fl.getBody())

        checkbox_id = extractToken(html[start:end], 'input id="', '"')
        fl.assert_(checkbox_id, 'item "%s" not found.' % title)
        checkbox_ajax_onclick_id = checkbox_id + '_ajax_onclick'
        table_name = checkbox_id.split(':', 1)[0]

        params = [
            ['AJAXREQUEST', 'cv_' + table_name + '_0_region'],
            [checkbox_id, 'on'],
            ['javax.faces.ViewState', fl.getLastJsfState()],
            [checkbox_ajax_onclick_id, checkbox_ajax_onclick_id],
            [table_name, table_name]
            ]
        fl.post(fl.server_url + "/view_documents.faces", params,
            description='Select document "%s"' % title)

        return self
예제 #7
0
파일: pages.py 프로젝트: skogtroll/nuxeo
 def getConversationId(self):
     fl = self.fl
     cId = extractToken(fl.getBody(), "var currentConversationId = '", "'")
     fl.assert_(cId, 'Current conversation id not found')
     return cId
예제 #8
0
파일: pages.py 프로젝트: skogtroll/nuxeo
 def getDocUid(self):
     fl = self.fl
     uid = extractToken(fl.getBody(), "var currentDocURL = 'default/", "'")
     fl.assert_(uid, 'Current document uid not found.')
     return uid
예제 #9
0
파일: pages.py 프로젝트: skogtroll/nuxeo
    def dashboardNew(self):
        """open social dashboard"""
        fl = self.fl
        server_url = fl.server_url
        fl.post(
            fl.server_url + "/view_documents.faces",
            params=[[
                'userServicesForm:userServicesActionsTable:0:userServicesActionCommandLink',
                'userServicesForm:userServicesActionsTable:0:userServicesActionCommandLink'
            ], ['javax.faces.ViewState',
                fl.getLastJsfState()],
                    ['userServicesForm', 'userServicesForm']],
            description="Dashboard opensocial")

        ts = str(time.time())
        jid = extractJsessionId(fl)
        uid = extractToken(fl.getBody(), """return "{docRef:'""", "'")
        fl.assert_(len(uid) == 36)

        fl.get(
            server_url +
            "/org.nuxeo.opensocial.container.ContainerEntryPoint/org.nuxeo.opensocial.container.ContainerEntryPoint.nocache.js",
            description="Get container entry point")
        data = Data(
            'text/x-gwt-rpc; charset=utf-8', '''5|0|17|''' + server_url +
            '''/org.nuxeo.opensocial.container.ContainerEntryPoint/|9CCFB53A0997F1E4596C8EE4765CCBAA|org.nuxeo.opensocial.container.client.service.api.ContainerService|getContainer|java.util.Map|java.util.HashMap/962170901|java.lang.String/2004016611|docRef|'''
            + uid + '''|clientUrl|''' + server_url +
            '''/|windowWidth|10|nxBaseUrl|userLanguage|fr|locale|1|2|3|4|1|5|6|6|7|8|7|9|7|10|7|11|7|12|7|13|7|14|-5|7|15|7|16|7|17|-10|'''
        )
        fl.post(server_url + "/gwtcontainer",
                data,
                description="dashboard gwt container")
        fl.assert_('//OK' in fl.getBody())

        # Extract iframes from the gwtcontainer response
        iframes = extractIframes(fl.getBody())
        fl.assert_(len(iframes))

        i = 0
        for iframe in iframes:
            i += 1
            # print "iframe: " + iframe
            fl.get(server_url + iframe, description="dashboard iframe %d" % i)
            fl.assert_(fl.getBody().startswith('<html>'))

        fl.get(
            server_url + "/opensocial/gadgets/makeRequest?refresh=3600&url=" +
            quote_plus(server_url) +
            "%2FrestAPI%2Fdashboard%2FUSER_SITES%3Fformat%3DJSON%26page%3D0%26domain%3Ddefault-domain%26lang%3Den%26ts%3D12766046361930.9475744903817575&httpMethod=GET&headers=Cache-control%3Dno-cache%252C%2520must-revalidate%26X-NUXEO-INTEGRATED-AUTH%3D"
            + jid +
            "&postData=&authz=&st=&contentType=JSON&numEntries=3&getSummaries=false&signOwner=true&signViewer=true&gadget="
            + quote_plus(server_url) +
            "%2Fsite%2Fgadgets%2Fuserdocuments%2Fusersites.xml&container=default&bypassSpecCache=1&nocache=0",
            description="dashboard req1: user sites")
        fl.assert_('USER_SITES' in fl.getBody())

        fl.post(
            server_url + "/opensocial/gadgets/makeRequest",
            params=
            [['authz', ''], ['signOwner', 'true'], ['contentType', 'JSON'],
             ['nocache', '0'
              ],
             ['postData', ''
              ],
             [
                 'headers',
                 'Cache-control=no-cache%2C%20must-revalidate&X-NUXEO-INTEGRATED-AUTH='
                 + jid
             ],
             [
                 'url', server_url +
                 '/restAPI/workflowTasks/default?mytasks=false&format=JSON&ts='
                 + ts +
                 '&lang=en&labels=workflowDirectiveValidation,workflowDirectiveOpinion,workflowDirectiveVerification,workflowDirectiveCheck,workflowDirectiveDiffusion,label.workflow.task.name,label.workflow.task.duedate,label.workflow.task.directive'
             ], ['numEntries', '3'], ['bypassSpecCache', '1'], ['st', ''],
             ['httpMethod', 'GET'], ['signViewer', 'true'],
             ['container', 'default'], ['getSummaries', 'false'],
             [
                 'gadget',
                 server_url + '/site/gadgets/waitingfor/waitingfor.xml'
             ]],
            description="dashboard req2: other tasks")
        fl.assert_('Tasks for' in fl.getBody())

        fl.get(
            server_url + "/opensocial/gadgets/makeRequest?refresh=3600&url=" +
            quote_plus(server_url) +
            "%2FrestAPI%2Fdashboard%2FUSER_WORKSPACES%3Fformat%3DJSON%26page%3D0%26domain%3Ddefault-domain%26lang%3Den%26ts%3D12766046364186.08350334148753&httpMethod=GET&headers=Cache-control%3Dno-cache%252C%2520must-revalidate%26X-NUXEO-INTEGRATED-AUTH%3DEB4D8F264629C549917996193637A4F4&postData=&authz=&st=&contentType=JSON&numEntries=3&getSummaries=false&signOwner=true&signViewer=true&gadget="
            + quote_plus(server_url) +
            "%2Fsite%2Fgadgets%2Fuserworkspaces%2Fuserworkspaces.xml&container=default&bypassSpecCache=1&nocache=0",
            description="dashboard req3: user workspaces")
        fl.assert_('USER_WORKSPACES' in fl.getBody())

        fl.post(
            server_url + "/opensocial/gadgets/makeRequest",
            params=
            [['authz', ''], ['signOwner', 'true'], ['contentType', 'JSON'],
             ['nocache', '0'
              ],
             ['postData', ''
              ],
             [
                 'headers',
                 'Cache-control=no-cache%2C%20must-revalidate&X-NUXEO-INTEGRATED-AUTH=EB4D8F264629C549917996193637A4F4'
             ],
             [
                 'url', server_url +
                 '/restAPI/workflowTasks/default?mytasks=true&format=JSON&ts='
                 + ts +
                 '&lang=en&labels=workflowDirectiveValidation,workflowDirectiveOpinion,workflowDirectiveVerification,workflowDirectiveCheck,workflowDirectiveDiffusion,label.workflow.task.name,label.workflow.task.duedate,label.workflow.task.directive'
             ], ['numEntries', '3'], ['bypassSpecCache', '1'], ['st', ''],
             ['httpMethod', 'GET'], ['signViewer', 'true'],
             ['container', 'default'], ['getSummaries', 'false'],
             ['gadget', server_url + '/site/gadgets/tasks/tasks.xml']],
            description="dashboard req4: my tasks")
        fl.assert_('Tasks for' in fl.getBody())

        fl.get(
            server_url + "/opensocial/gadgets/makeRequest?refresh=3600&url=" +
            quote_plus(server_url) +
            "%2FrestAPI%2Fdashboard%2FRELEVANT_DOCUMENTS%3Fformat%3DJSON%26page%3D0%26domain%3Ddefault-domain%26lang%3Den%26ts%3D12766046370131.186666326174645&httpMethod=GET&headers=Cache-control%3Dno-cache%252C%2520must-revalidate%26X-NUXEO-INTEGRATED-AUTH%3DEB4D8F264629C549917996193637A4F4&postData=&authz=&st=&contentType=JSON&numEntries=3&getSummaries=false&signOwner=true&signViewer=true&gadget="
            + quote_plus(server_url) +
            "%2Fsite%2Fgadgets%2Fuserdocuments%2Fuserdocuments.xml&container=default&bypassSpecCache=1&nocache=0",
            description="dashboard req5: relevant docs")
        fl.assert_('RELEVANT_DOCUMENTS' in fl.getBody())
        return self
예제 #10
0
 def getConversationId(self):
     fl = self.fl
     cId = extractToken(fl.getBody(), "var currentConversationId = '", "'")
     fl.assert_(cId, 'Current conversation id not found')
     return cId
예제 #11
0
 def getDocUid(self):
     fl = self.fl
     uid = extractToken(fl.getBody(), "var currentDocURL = 'default/", "'")
     fl.assert_(uid, 'Current document uid not found.')
     return uid
예제 #12
0
    def dashboardNew(self):
        """open social dashboard"""
        fl = self.fl
        server_url = fl.server_url
        fl.post(fl.server_url + "/view_documents.faces", params=[
            ['userServicesForm:userServicesActionsTable:0:userServicesActionCommandLink', 'userServicesForm:userServicesActionsTable:0:userServicesActionCommandLink'],
            ['javax.faces.ViewState', fl.getLastJsfState()],
            ['userServicesForm', 'userServicesForm']],
                description="Dashboard opensocial")

        ts = str(time.time())
        jid = extractJsessionId(fl)
        uid = extractToken(fl.getBody(), """return "{docRef:'""", "'")
        fl.assert_(len(uid) == 36)

        fl.get(server_url + "/org.nuxeo.opensocial.container.ContainerEntryPoint/org.nuxeo.opensocial.container.ContainerEntryPoint.nocache.js",
                 description="Get container entry point")
        data =  Data('text/x-gwt-rpc; charset=utf-8', '''5|0|17|''' + server_url + '''/org.nuxeo.opensocial.container.ContainerEntryPoint/|9CCFB53A0997F1E4596C8EE4765CCBAA|org.nuxeo.opensocial.container.client.service.api.ContainerService|getContainer|java.util.Map|java.util.HashMap/962170901|java.lang.String/2004016611|docRef|''' + uid + '''|clientUrl|''' + server_url + '''/|windowWidth|10|nxBaseUrl|userLanguage|fr|locale|1|2|3|4|1|5|6|6|7|8|7|9|7|10|7|11|7|12|7|13|7|14|-5|7|15|7|16|7|17|-10|''')
        fl.post(server_url + "/gwtcontainer", data,
                description="dashboard gwt container")
        fl.assert_('//OK' in fl.getBody())

        # Extract iframes from the gwtcontainer response
        iframes = extractIframes(fl.getBody())
        fl.assert_(len(iframes))

        i = 0
        for iframe in iframes:
            i += 1
            # print "iframe: " + iframe
            fl.get(server_url + iframe,
                   description="dashboard iframe %d" % i)
            fl.assert_(fl.getBody().startswith('<html>'))

        fl.get(server_url + "/opensocial/gadgets/makeRequest?refresh=3600&url=" + quote_plus(server_url) + "%2FrestAPI%2Fdashboard%2FUSER_SITES%3Fformat%3DJSON%26page%3D0%26domain%3Ddefault-domain%26lang%3Den%26ts%3D12766046361930.9475744903817575&httpMethod=GET&headers=Cache-control%3Dno-cache%252C%2520must-revalidate%26X-NUXEO-INTEGRATED-AUTH%3D" + jid + "&postData=&authz=&st=&contentType=JSON&numEntries=3&getSummaries=false&signOwner=true&signViewer=true&gadget=" + quote_plus(server_url) + "%2Fsite%2Fgadgets%2Fuserdocuments%2Fusersites.xml&container=default&bypassSpecCache=1&nocache=0",
               description="dashboard req1: user sites")
        fl.assert_('USER_SITES' in fl.getBody())

        fl.post(server_url + "/opensocial/gadgets/makeRequest", params=[
            ['authz', ''],
            ['signOwner', 'true'],
            ['contentType', 'JSON'],
            ['nocache', '0'],
            ['postData', ''],
            ['headers', 'Cache-control=no-cache%2C%20must-revalidate&X-NUXEO-INTEGRATED-AUTH=' + jid],
            ['url', server_url + '/restAPI/workflowTasks/default?mytasks=false&format=JSON&ts=' + ts + '&lang=en&labels=workflowDirectiveValidation,workflowDirectiveOpinion,workflowDirectiveVerification,workflowDirectiveCheck,workflowDirectiveDiffusion,label.workflow.task.name,label.workflow.task.duedate,label.workflow.task.directive'],
            ['numEntries', '3'],
            ['bypassSpecCache', '1'],
            ['st', ''],
            ['httpMethod', 'GET'],
            ['signViewer', 'true'],
            ['container', 'default'],
            ['getSummaries', 'false'],
            ['gadget', server_url + '/site/gadgets/waitingfor/waitingfor.xml']],
            description="dashboard req2: other tasks")
        fl.assert_('Tasks for' in fl.getBody())

        fl.get(server_url + "/opensocial/gadgets/makeRequest?refresh=3600&url=" + quote_plus(server_url) + "%2FrestAPI%2Fdashboard%2FUSER_WORKSPACES%3Fformat%3DJSON%26page%3D0%26domain%3Ddefault-domain%26lang%3Den%26ts%3D12766046364186.08350334148753&httpMethod=GET&headers=Cache-control%3Dno-cache%252C%2520must-revalidate%26X-NUXEO-INTEGRATED-AUTH%3DEB4D8F264629C549917996193637A4F4&postData=&authz=&st=&contentType=JSON&numEntries=3&getSummaries=false&signOwner=true&signViewer=true&gadget=" + quote_plus(server_url) + "%2Fsite%2Fgadgets%2Fuserworkspaces%2Fuserworkspaces.xml&container=default&bypassSpecCache=1&nocache=0",
               description="dashboard req3: user workspaces")
        fl.assert_('USER_WORKSPACES' in fl.getBody())

        fl.post(server_url + "/opensocial/gadgets/makeRequest", params=[
            ['authz', ''],
            ['signOwner', 'true'],
            ['contentType', 'JSON'],
            ['nocache', '0'],
            ['postData', ''],
            ['headers', 'Cache-control=no-cache%2C%20must-revalidate&X-NUXEO-INTEGRATED-AUTH=EB4D8F264629C549917996193637A4F4'],
            ['url', server_url + '/restAPI/workflowTasks/default?mytasks=true&format=JSON&ts=' + ts + '&lang=en&labels=workflowDirectiveValidation,workflowDirectiveOpinion,workflowDirectiveVerification,workflowDirectiveCheck,workflowDirectiveDiffusion,label.workflow.task.name,label.workflow.task.duedate,label.workflow.task.directive'],
            ['numEntries', '3'],
            ['bypassSpecCache', '1'],
            ['st', ''],
            ['httpMethod', 'GET'],
            ['signViewer', 'true'],
            ['container', 'default'],
            ['getSummaries', 'false'],
            ['gadget', server_url + '/site/gadgets/tasks/tasks.xml']],
            description="dashboard req4: my tasks")
        fl.assert_('Tasks for' in fl.getBody())

        fl.get(server_url + "/opensocial/gadgets/makeRequest?refresh=3600&url=" + quote_plus(server_url) + "%2FrestAPI%2Fdashboard%2FRELEVANT_DOCUMENTS%3Fformat%3DJSON%26page%3D0%26domain%3Ddefault-domain%26lang%3Den%26ts%3D12766046370131.186666326174645&httpMethod=GET&headers=Cache-control%3Dno-cache%252C%2520must-revalidate%26X-NUXEO-INTEGRATED-AUTH%3DEB4D8F264629C549917996193637A4F4&postData=&authz=&st=&contentType=JSON&numEntries=3&getSummaries=false&signOwner=true&signViewer=true&gadget=" + quote_plus(server_url) + "%2Fsite%2Fgadgets%2Fuserdocuments%2Fuserdocuments.xml&container=default&bypassSpecCache=1&nocache=0",
               description="dashboard req5: relevant docs")
        fl.assert_('RELEVANT_DOCUMENTS' in fl.getBody())
        return self
예제 #13
0
def extractSyncDate(text):
    return extractToken(text, '"syncDate":', ',')
예제 #14
0
def extractSyncIds(text):
    return  extractToken(text, 'activeSynchronizationRootDefinitions":"', '"')
예제 #15
0
def extractDownloadUrl(text):
    """Extract dowload url from json response"""
    return extractToken(text, 'downloadURL":"', '"')