def test_host(self): vhost = VHost('test vhost', 80, 'HTTP', '/www', '/system', [Log('ACCESSLOG')]) self.assertEqual({}, vhost.get_host()) vhost.add_host('foo.bar.com', False) vhost.add_host('test.me.org') self.assertEqual({'foo.bar.com': False, 'test.me.org': None}, vhost.get_host()) vhost.remove_host('foo.bar.com') self.assertEqual({'test.me.org': None}, vhost.get_host()) vhost = VHost('test vhost', 80, 'HTTP', '/www', '/system', [Log('ACCESSLOG'), Log('WARNINGLOG')], ['127.0.0.0/8', '192.168.0.0/16'], {'test.me.org': None}) self.assertEqual({'test.me.org': None}, vhost.get_host()) vhost = VHost('test vhost', 80, 'HTTP', '/www', '/system', [Log('ACCESSLOG'), Log('WARNINGLOG')], host = {'test.me.org': None}) self.assertEqual({'test.me.org': None}, vhost.get_host())
def test_equality(self): vhost_0 = VHost('test vhost', 80, 'HTTP', '/www', '/system', [Log('ACCESSLOG'), Log('WARNINGLOG')], ['127.0.0.0/8', '192.168.0.0/16'], {'host.domain': None}, 'private_key', 'certificate') vhost_1 = VHost('test vhost', 80, 'HTTP', '/www', '/system', [Log('ACCESSLOG'), Log('WARNINGLOG')], ['127.0.0.0/8', '192.168.0.0/16'], {'host.domain': None}, 'private_key', 'certificate') self.assertEqual(vhost_0, vhost_1) vhost_1 = VHost.from_string(str(vhost_0)) vhost_1.set_name('different') self.assertNotEqual(vhost_0, vhost_1) vhost_1 = VHost.from_string(str(vhost_0)) vhost_1.set_port(81) self.assertNotEqual(vhost_0, vhost_1) vhost_1 = VHost.from_string(str(vhost_0)) vhost_1.set_protocol('HTTPS') self.assertNotEqual(vhost_0, vhost_1) vhost_1 = VHost.from_string(str(vhost_0)) vhost_1.set_doc_root('/var/www') self.assertNotEqual(vhost_0, vhost_1) vhost_1 = VHost.from_string(str(vhost_0)) vhost_1.set_sys_root('/var/system') self.assertNotEqual(vhost_0, vhost_1) vhost_1 = VHost.from_string(str(vhost_0)) vhost_1.add_log(Log('NEWLOG')) self.assertNotEqual(vhost_0, vhost_1) vhost_1 = VHost.from_string(str(vhost_0)) vhost_1.add_ip('10.0.0.0/8') self.assertNotEqual(vhost_0, vhost_1) vhost_1 = VHost.from_string(str(vhost_0)) vhost_1.add_host('newhost', None) self.assertNotEqual(vhost_0, vhost_1) vhost_1 = VHost.from_string(str(vhost_0)) vhost_1.set_private_key('new_key') self.assertNotEqual(vhost_0, vhost_1) vhost_1 = VHost.from_string(str(vhost_0)) vhost_1.set_certificate('new certificate') self.assertNotEqual(vhost_0, vhost_1) self.assertNotEqual(vhost_0, [])
def test_host(self): vhost = VHost('test vhost', 80, 'HTTP', '/www', '/system', [Log('ACCESSLOG')]) self.assertEqual({}, vhost.get_host()) vhost.add_host('foo.bar.com', False) vhost.add_host('test.me.org') self.assertEqual({ 'foo.bar.com': False, 'test.me.org': None }, vhost.get_host()) vhost.remove_host('foo.bar.com') self.assertEqual({'test.me.org': None}, vhost.get_host()) vhost = VHost('test vhost', 80, 'HTTP', '/www', '/system', [Log('ACCESSLOG'), Log('WARNINGLOG')], ['127.0.0.0/8', '192.168.0.0/16'], {'test.me.org': None}) self.assertEqual({'test.me.org': None}, vhost.get_host()) vhost = VHost('test vhost', 80, 'HTTP', '/www', '/system', [Log('ACCESSLOG'), Log('WARNINGLOG')], host={'test.me.org': None}) self.assertEqual({'test.me.org': None}, vhost.get_host())