# Path: openid/yadis/etxrd.py
# class XRDSError(Exception):
# class XRDSFraud(XRDSError):
# class _Max(object):
# def parseXRDS(text):
# def nsTag(ns, t):
# def mkXRDTag(t):
# def mkXRDSTag(t):
# def isXRDS(xrd_tree):
# def getYadisXRD(xrd_tree):
# def getXRDExpiration(xrd_element, default=None):
# def getCanonicalID(iname, xrd_tree):
#     def __eq__(self, other):
#     def __gt__(self, other):
# def getPriorityStrict(element):
# def getPriority(element):
# def prioSort(elements):
# def iterServices(xrd_tree):
# def sortedURIs(service_element):
# def getTypeURIs(service_element):
# def expandService(service_element):
# def expandServices(service_elements):
# XRD_NS_2_0 = 'xri://$xrd*($v*2.0)'
# XRDS_NS = 'xri://$xrds'
# 
# Path: openid/yadis/services.py
# def getServiceEndpoints(input_url, flt=None):
# def applyFilter(normalized_uri, xrd_data, flt=None):
# 
# Path: openid/yadis/xri.py
# XRI_AUTHORITIES = ['!', '=', '@', '+', '$', '(']
# def identifierScheme(identifier):
# def toIRINormal(xri):
# def _escape_xref(xref_match):
# def escapeForIRI(xri):
# def toURINormal(xri):
# def iriToURI(iri):
# def providerIsAuthoritative(providerID, canonicalID):
# def rootAuthority(xri):
# def XRI(xri):


import os.path
import tempfile
import unittest
import six
from lxml import etree
from openid.yadis import etxrd, services, xri
            tree = etxrd.parseXRDS(xml.encode('utf-8'))
            self.assertNotIn(xxe_content, etree.tostring(tree))
        finally:
            os.remove(tmp_file)


class TestServiceParser(unittest.TestCase):
    def setUp(self):
        with open(XRD_FILE, 'rb') as xrd_file:
            self.xmldoc = xrd_file.read()
        self.yadis_url = 'http://unittest.url/'

    def _getServices(self, flt=None):
        return list(services.applyFilter(self.yadis_url, self.xmldoc, flt))

    def testParse(self):
        """Make sure that parsing succeeds at all"""
        self._getServices()

    def testParseOpenID(self):
        """Parse for OpenID services with a transformer function"""
        services = self._getServices(simpleOpenIDTransformer)

        expectedServices = [
            ("http://www.myopenid.com/server", "http://josh.myopenid.com/"),
            ("http://www.schtuff.com/openid", "http://users.schtuff.com/josh"),
            ("http://www.livejournal.com/openid/server.bml",
             "http://www.livejournal.com/users/nedthealpaca/"),
        ]


# Path: openid/yadis/etxrd.py
# class XRDSError(Exception):
# class XRDSFraud(XRDSError):
# class _Max(object):
# def parseXRDS(text):
# def nsTag(ns, t):
# def mkXRDTag(t):
# def mkXRDSTag(t):
# def isXRDS(xrd_tree):
# def getYadisXRD(xrd_tree):
# def getXRDExpiration(xrd_element, default=None):
# def getCanonicalID(iname, xrd_tree):
#     def __eq__(self, other):
#     def __gt__(self, other):
# def getPriorityStrict(element):
# def getPriority(element):
# def prioSort(elements):
# def iterServices(xrd_tree):
# def sortedURIs(service_element):
# def getTypeURIs(service_element):
# def expandService(service_element):
# def expandServices(service_elements):
# XRD_NS_2_0 = 'xri://$xrd*($v*2.0)'
# XRDS_NS = 'xri://$xrds'
# 
# Path: openid/yadis/services.py
# def getServiceEndpoints(input_url, flt=None):
# def applyFilter(normalized_uri, xrd_data, flt=None):
# 
# Path: openid/yadis/xri.py
# XRI_AUTHORITIES = ['!', '=', '@', '+', '$', '(']
# def identifierScheme(identifier):
# def toIRINormal(xri):
# def _escape_xref(xref_match):
# def escapeForIRI(xri):
# def toURINormal(xri):
# def iriToURI(iri):
# def providerIsAuthoritative(providerID, canonicalID):
# def rootAuthority(xri):
# def XRI(xri):


# Path: openid/test/test_etxrd.py
import os.path
import tempfile
import unittest
import six
from lxml import etree
from openid.yadis import etxrd, services, xri

            tree = etxrd.parseXRDS(xml.encode('utf-8'))
            self.assertNotIn(xxe_content, etree.tostring(tree))
        finally:
            os.remove(tmp_file)


class TestServiceParser(unittest.TestCase):
    def setUp(self):
        with open(XRD_FILE, 'rb') as xrd_file:
            self.xmldoc = xrd_file.read()
        self.yadis_url = 'http://unittest.url/'

    def _getServices(self, flt=None):
        return list(services.applyFilter(self.yadis_url, self.xmldoc, flt))

    def testParse(self):
        """Make sure that parsing succeeds at all"""
        self._getServices()

    def testParseOpenID(self):
        """Parse for OpenID services with a transformer function"""
        services = self._getServices(simpleOpenIDTransformer)

        expectedServices = [
            ("http://www.myopenid.com/server", "http://josh.myopenid.com/"),
            ("http://www.schtuff.com/openid", "http://users.schtuff.com/josh"),
            ("http://www.livejournal.com/openid/server.bml",
             "http://www.livejournal.com/users/nedthealpaca/"),
        ]


        it = iter(services)