Esempio n. 1
0
 def setUp(self):
     self.o = SIDNEppProtocol()
Esempio n. 2
0
class testSIDNEppProtocol(unittest.TestCase):

    xml1 = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
    <command>
    <login>
    <clID>username</clID>
    <pw>password</pw>
    <options>
    <version>1.0</version>
    <lang>nl</lang>
    </options>
    <svcs>
    <objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>
    <objURI>urn:ietf:params:xml:ns:host-1.0</objURI>
    <objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>
    <svcExtension>
    <extURI>urn:ietf:params:xml:ns:sidn-ext-epp-1.0</extURI>
    </svcExtension>
    </svcs>
    </login>
    </command>
    </epp>"""

    xml2 = """<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<epp xmlns:sidn-ext-epp="http://rxsd.domain-registry.nl/sidn-ext-epp-1.0"
    xmlns="urn:ietf:params:xml:ns:epp-1.0">
  <command>
    <create>
      <contact:create xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
        <contact:id>JAN100827-NFGNT</contact:id>
        <contact:postalInfo type="loc">
          <contact:name>Jan Janssen BV</contact:name>
          <contact:org>Technisch Beheer</contact:org>
          <contact:addr>
            <contact:street>Wolvenplein 16</contact:street>
            <contact:city>Utrecht</contact:city>
            <contact:pc>3512CK</contact:pc>
            <contact:cc>NL</contact:cc>
          </contact:addr>
        </contact:postalInfo>
        <contact:voice>+31.0858779997</contact:voice>
        <contact:fax>+31.0858779996</contact:fax>
        <contact:email>[email protected]</contact:email>
        <contact:authInfo>
          <contact:pw>unused</contact:pw>
        </contact:authInfo>
      </contact:create>
    </create>
    <extension>
      <sidn-ext-epp:ext>
        <sidn-ext-epp:create>
          <sidn-ext-epp:contact>
            <sidn-ext-epp:legalForm>BV</sidn-ext-epp:legalForm>
            <sidn-ext-epp:legalFormRegNo>14633770</sidn-ext-epp:legalFormRegNo>
          </sidn-ext-epp:contact>
        </sidn-ext-epp:create>
      </sidn-ext-epp:ext>
    </extension>
  </command>
</epp>

"""

    def setUp(self):
        self.o = SIDNEppProtocol()

    def test_parse(self):
        self.o.parse(self.xml1)
        self.o.parse(self.xml2)

    def testQuery(self):
        e = self.o.parse(self.xml1)
        r1 = e.xpath('//epp:command',
                     namespaces={'epp': "urn:ietf:params:xml:ns:epp-1.0"})
        self.failUnless(len(r1) == 1)
        r2 = self.o.query(e, "//epp:command")
        self.failUnless(r1 == r2)
        r3 = self.o.query(e, "//epp:login")
        self.failUnless(type(r3) == type(r2))

    def testMaker(self):
        e = self.o.e_epp

        x = e.epp(
            e.command(
                e.login()
            )
        )

        expect = """<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<epp xmlns:sidn-ext-epp="http://rxsd.domain-registry.nl/sidn-ext-epp-1.0" xmlns="urn:ietf:params:xml:ns:epp-1.0">
  <command>
    <login/>
  </command>
</epp>
"""
        self.failUnless(expect == self.o.render(x))

        h = self.o.e_host
        x = e.epp(
            e.command(
                e.create(
                    h.create(
                        h.name("ns10.nfgs.net"),
                        h.addr("194.109.214.3", ip="v4"),
                    )
                )
            )
        )
        expect = """<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<epp xmlns:sidn-ext-epp="http://rxsd.domain-registry.nl/sidn-ext-epp-1.0" xmlns="urn:ietf:params:xml:ns:epp-1.0">
  <command>
    <create>
      <host:create xmlns:host="urn:ietf:params:xml:ns:host-1.0">
        <host:name>ns10.nfgs.net</host:name>
        <host:addr ip="v4">194.109.214.3</host:addr>
      </host:create>
    </create>
  </command>
</epp>
"""
        self.failUnless(expect == self.o.render(x))