def test_to_lxml_full(self): vhost = VHost('test vhost', 80, 'HTTP', '/www', '/system', [Log('ACCESSLOG'), Log('WARNINGLOG')], ['127.0.0.0/8', '192.168.0.0/16'], {'host.domain': True, 'test.domain': None}, 'private_key', 'certificate') copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_to_lxml_full(self): vhost = VHost('test vhost', 80, 'HTTP', '/www', '/system', [Log('ACCESSLOG'), Log('WARNINGLOG')], ['127.0.0.0/8', '192.168.0.0/16'], { 'host.domain': True, 'test.domain': None }, 'private_key', 'certificate') copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_from_lxml_full(self): text = '''<VHOST> <NAME>test vhost</NAME> <PORT>80</PORT> <PROTOCOL>HTTP</PROTOCOL> <DOCROOT>/www</DOCROOT> <SYSROOT>/system</SYSROOT> <ACCESSLOG /> <WARNINGLOG /> <IP>127.0.0.0/8</IP> <IP>192.168.0.0/16</IP> <HOST useRegex="YES">host.domain</HOST> <HOST>test.domain</HOST> <SSL_PRIVATEKEY>private_key</SSL_PRIVATEKEY> <SSL_CERTIFICATE>certificate</SSL_CERTIFICATE> </VHOST>''' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost('test vhost', 80, 'HTTP', '/www', '/system', [Log('ACCESSLOG'), Log('WARNINGLOG')], ['127.0.0.0/8', '192.168.0.0/16'], {'host.domain': True, 'test.domain': None}, 'private_key', 'certificate') self.assertEqual(vhost, right)
def test_from_lxml_full(self): text = '''<VHOST> <NAME>test vhost</NAME> <PORT>80</PORT> <PROTOCOL>HTTP</PROTOCOL> <DOCROOT>/www</DOCROOT> <SYSROOT>/system</SYSROOT> <ACCESSLOG /> <WARNINGLOG /> <IP>127.0.0.0/8</IP> <IP>192.168.0.0/16</IP> <HOST useRegex="YES">host.domain</HOST> <HOST>test.domain</HOST> <SSL_PRIVATEKEY>private_key</SSL_PRIVATEKEY> <SSL_CERTIFICATE>certificate</SSL_CERTIFICATE> </VHOST>''' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost('test vhost', 80, 'HTTP', '/www', '/system', [Log('ACCESSLOG'), Log('WARNINGLOG')], ['127.0.0.0/8', '192.168.0.0/16'], { 'host.domain': True, 'test.domain': None }, 'private_key', 'certificate') self.assertEqual(vhost, right)
def test_from_lxml_private_key(self): text = '<VHOST><SSL_PRIVATEKEY>private_key</SSL_PRIVATEKEY></VHOST>' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost(private_key='private_key') self.assertEqual(vhost, right)
def test_from_lxml_ip(self): text = '<VHOST><IP>127.0.0.0/8</IP></VHOST>' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost(ip=['127.0.0.0/8']) self.assertEqual(vhost, right)
def test_from_lxml_sys_folder(self): text = '<VHOST><SYSROOT>/system</SYSROOT></VHOST>' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost(sys_root='/system') self.assertEqual(vhost, right)
def test_from_lxml_protocol(self): text = '<VHOST><PROTOCOL>HTTP</PROTOCOL></VHOST>' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost(protocol='HTTP') self.assertEqual(vhost, right)
def test_from_lxml_name(self): text = '<VHOST><NAME>test vhost</NAME></VHOST>' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost('test vhost') self.assertEqual(vhost, right)
def test_to_lxml_host(self): vhost = VHost(host={'.*': True, 'a.org': None}) copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_to_lxml_doc_root(self): vhost = VHost(doc_root='/www') copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_from_lxml_certificate(self): text = '<VHOST><SSL_CERTIFICATE>certificate</SSL_CERTIFICATE></VHOST>' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost(certificate = 'certificate') self.assertEqual(vhost, right)
def test_from_lxml_private_key(self): text = '<VHOST><SSL_PRIVATEKEY>private_key</SSL_PRIVATEKEY></VHOST>' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost(private_key = 'private_key') self.assertEqual(vhost, right)
def test_from_lxml_host(self): text = '<VHOST><HOST useRegex="YES">.*</HOST><HOST>a.org</HOST></VHOST>' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost(host = {'.*': True, 'a.org': None}) self.assertEqual(vhost, right)
def test_from_lxml_ip(self): text = '<VHOST><IP>127.0.0.0/8</IP></VHOST>' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost(ip = ['127.0.0.0/8']) self.assertEqual(vhost, right)
def test_from_lxml_logs(self): text = '<VHOST><ACCESSLOG /><SOMELOG /></VHOST>' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost(logs = [Log('ACCESSLOG'), Log('SOMELOG')]) self.assertEqual(vhost, right)
def test_from_lxml_sys_folder(self): text = '<VHOST><SYSROOT>/system</SYSROOT></VHOST>' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost(sys_root = '/system') self.assertEqual(vhost, right)
def test_from_lxml_doc_root(self): text = '<VHOST><DOCROOT>/www</DOCROOT></VHOST>' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost(doc_root = '/www') self.assertEqual(vhost, right)
def test_to_lxml_port(self): vhost = VHost(port=80) copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_to_lxml_name(self): vhost = VHost('test vhost') copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_to_lxml_logs(self): vhost = VHost(logs=[Log('ACCESSLOG'), Log('SOMELOG')]) copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_to_lxml_port(self): vhost = VHost(port = 80) copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_from_lxml_protocol(self): text = '<VHOST><PROTOCOL>HTTP</PROTOCOL></VHOST>' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost(protocol = 'HTTP') self.assertEqual(vhost, right)
def test_to_lxml_protocol(self): vhost = VHost(protocol = 'HTTP') copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_from_lxml_port(self): text = '<VHOST><PORT>80</PORT></VHOST>' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost(port=80) self.assertEqual(vhost, right)
def test_to_lxml_doc_root(self): vhost = VHost(doc_root = '/www') copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_from_lxml_doc_root(self): text = '<VHOST><DOCROOT>/www</DOCROOT></VHOST>' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost(doc_root='/www') self.assertEqual(vhost, right)
def test_to_lxml_sys_root(self): vhost = VHost(sys_root = '/system') copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_from_lxml_logs(self): text = '<VHOST><ACCESSLOG /><SOMELOG /></VHOST>' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost(logs=[Log('ACCESSLOG'), Log('SOMELOG')]) self.assertEqual(vhost, right)
def test_to_lxml_logs(self): vhost = VHost(logs = [Log('ACCESSLOG'), Log('SOMELOG')]) copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_from_lxml_host(self): text = '<VHOST><HOST useRegex="YES">.*</HOST><HOST>a.org</HOST></VHOST>' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost(host={'.*': True, 'a.org': None}) self.assertEqual(vhost, right)
def test_to_lxml_ip(self): vhost = VHost(ip = ['127.0.0.0/8']) copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_from_lxml_certificate(self): text = '<VHOST><SSL_CERTIFICATE>certificate</SSL_CERTIFICATE></VHOST>' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost(certificate='certificate') self.assertEqual(vhost, right)
def test_to_lxml_host(self): vhost = VHost(host = {'.*': True, 'a.org': None}) copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_to_lxml_private_key(self): vhost = VHost(private_key = 'private_key') copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_to_lxml_protocol(self): vhost = VHost(protocol='HTTP') copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_to_lxml_certificate(self): vhost = VHost(certificate = 'certificate') copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_to_lxml_sys_root(self): vhost = VHost(sys_root='/system') copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_to_lxml_certificate(self): vhost = VHost(certificate='certificate') copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_to_lxml_ip(self): vhost = VHost(ip=['127.0.0.0/8']) copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_to_lxml_private_key(self): vhost = VHost(private_key='private_key') copy = VHost.from_lxml_element(vhost.to_lxml_element()) self.assertEqual(vhost, copy)
def test_from_lxml_port(self): text = '<VHOST><PORT>80</PORT></VHOST>' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost(port = 80) self.assertEqual(vhost, right)
def test_from_lxml(self): text = '<VHOST />' vhost = VHost.from_lxml_element(etree.XML(text)) right = VHost() self.assertEqual(vhost, right)