def test_compile(self): wc = WebClient('http://w4043.see.ed.ac.uk/machination/hierarchy', 'os_instance:test-win7-1') path = '/by_os/windows/by_version/7/os_instance:test-win7-1' idpair = wc.call("IdPair", path) channel = wc.call("ProfChannel", idpair['type_id']) data = wc.call("GetAssertionList", path, channel) ac = xmltools.AssertionCompiler(wc) st, res = ac.compile(data) # print(xmltools.pstring(st.getroot())) print(etree.tostring(st, pretty_print=True, encoding='utf8').decode('utf8'))
def connectToService(self, url = None, method = None, cred = None): '''Connect to a machination hierarchy service. ''' if url is None: ok = self.d_service_url.exec_() if ok: url = self.d_service_url.textValue() else: return if method is None or cred is None: d = CredentialsDialog(self.ui, url) selt = etree.fromstring( "<service><hierarchy id='{}'/></service>".format(url) ) tmpwc = WebClient(url, 'public', 'person') istr = tmpwc.call('ServiceConfig') info = etree.fromstring(istr) auth_type_elts = info.xpath('authentication/type') authtypes = [x.get("id") for x in auth_type_elts] d.setAuthMethodsList(authtypes) if method is None: method = info.xpath('authentication/objType[@id="person"]/@defaultAuth')[0] d.default_auth_method = method d.setAuthMethod(method) ok = d.exec_() if ok: cred = d.getCred() method = d.current_auth_method self.wcs[url] = WebClient(url, method, 'person', credentials = cred) self.model.add_service(self.wcs[url])