# Path: ldaptor/protocols/ldap/distinguishedname.py
# def escape(s):
# def unescape(s):
# def _splitOnNotEscaped(s, separator):
#     def __init__(self, rdn):
#     def __str__(self):
#     def __init__(self, stringValue=None, attributeType=None, value=None):
#     def __str__(self):
#     def __repr__(self):
#     def __hash__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __lt__(self, other):
#     def __gt__(self, other):
#     def __le__(self, other):
#     def __ge__(self, other):
#     def __init__(self, magic=None, stringValue=None, attributeTypesAndValues=None):
#     def split(self):
#     def __str__(self):
#     def __repr__(self):
#     def __hash__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __lt__(self, other):
#     def __gt__(self, other):
#     def __le__(self, other):
#     def __ge__(self, other):
#     def count(self):
#     def __init__(self, magic=None, stringValue=None, listOfRDNs=None):
#     def split(self):
#     def up(self):
#     def __str__(self):
#     def __repr__(self):
#     def __hash__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __cmp__(self, other):
#     def getDomainName(self):
#     def contains(self, other):
# class InvalidRelativeDistinguishedName(Exception):
# class LDAPAttributeTypeAndValue:
# class RelativeDistinguishedName:
# class DistinguishedName:


from twisted.trial import unittest
from ldaptor.protocols.ldap import distinguishedname as dn

        )

class LDAPDistinguishedName_DomainName(unittest.TestCase):
    def testNonDc(self):
        d=dn.DistinguishedName('cn=foo,o=bar,c=us')
        assert d.getDomainName() is None

    def testNonTrailingDc(self):
        d=dn.DistinguishedName('cn=foo,o=bar,dc=foo,c=us')
        assert d.getDomainName() is None

    def testSimple_ExampleCom(self):
        d=dn.DistinguishedName('dc=example,dc=com')
        assert d.getDomainName() == 'example.com'

    def testSimple_SubExampleCom(self):
        d=dn.DistinguishedName('dc=sub,dc=example,dc=com')
        assert d.getDomainName() == 'sub.example.com'

    def testSimple_HostSubExampleCom(self):
        d=dn.DistinguishedName('cn=host,dc=sub,dc=example,dc=com')
        assert d.getDomainName() == 'sub.example.com'

    def testInterleaved_SubHostSubExampleCom(self):
        d=dn.DistinguishedName('dc=sub2,cn=host,dc=sub,dc=example,dc=com')
        assert d.getDomainName() == 'sub.example.com'

class LDAPDistinguishedName_contains(unittest.TestCase):
    shsec=dn.DistinguishedName('dc=sub2,cn=host,dc=sub,dc=example,dc=com')

# Path: ldaptor/protocols/ldap/distinguishedname.py
# def escape(s):
# def unescape(s):
# def _splitOnNotEscaped(s, separator):
#     def __init__(self, rdn):
#     def __str__(self):
#     def __init__(self, stringValue=None, attributeType=None, value=None):
#     def __str__(self):
#     def __repr__(self):
#     def __hash__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __lt__(self, other):
#     def __gt__(self, other):
#     def __le__(self, other):
#     def __ge__(self, other):
#     def __init__(self, magic=None, stringValue=None, attributeTypesAndValues=None):
#     def split(self):
#     def __str__(self):
#     def __repr__(self):
#     def __hash__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __lt__(self, other):
#     def __gt__(self, other):
#     def __le__(self, other):
#     def __ge__(self, other):
#     def count(self):
#     def __init__(self, magic=None, stringValue=None, listOfRDNs=None):
#     def split(self):
#     def up(self):
#     def __str__(self):
#     def __repr__(self):
#     def __hash__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __cmp__(self, other):
#     def getDomainName(self):
#     def contains(self, other):
# class InvalidRelativeDistinguishedName(Exception):
# class LDAPAttributeTypeAndValue:
# class RelativeDistinguishedName:
# class DistinguishedName:


# Path: ldaptor/test/test_distinguishedname.py
from twisted.trial import unittest
from ldaptor.protocols.ldap import distinguishedname as dn


        )

class LDAPDistinguishedName_DomainName(unittest.TestCase):
    def testNonDc(self):
        d=dn.DistinguishedName('cn=foo,o=bar,c=us')
        assert d.getDomainName() is None

    def testNonTrailingDc(self):
        d=dn.DistinguishedName('cn=foo,o=bar,dc=foo,c=us')
        assert d.getDomainName() is None

    def testSimple_ExampleCom(self):
        d=dn.DistinguishedName('dc=example,dc=com')
        assert d.getDomainName() == 'example.com'

    def testSimple_SubExampleCom(self):
        d=dn.DistinguishedName('dc=sub,dc=example,dc=com')
        assert d.getDomainName() == 'sub.example.com'

    def testSimple_HostSubExampleCom(self):
        d=dn.DistinguishedName('cn=host,dc=sub,dc=example,dc=com')
        assert d.getDomainName() == 'sub.example.com'

    def testInterleaved_SubHostSubExampleCom(self):
        d=dn.DistinguishedName('dc=sub2,cn=host,dc=sub,dc=example,dc=com')
        assert d.getDomainName() == 'sub.example.com'

class LDAPDistinguishedName_contains(unittest.TestCase):
    shsec=dn.DistinguishedName('dc=sub2,cn=host,dc=sub,dc=example,dc=com')

    hsec=dn.DistinguishedName('cn=host,dc=sub,dc=example,dc=com')