def setup (self): XMLRPCServerTester.setup(self) self.server = XMLRPCServer(("localhost", 5900), register=False) self.server.require_auth = True self.server.credentials = dict(user="******") self.server.register_instance(c) self.proxy = xmlrpclib.ServerProxy("http://*****:*****@localhost:5900")
class TestXMLRPCServer_http_auth (TestXMLRPCServer_http): def setup (self): XMLRPCServerTester.setup(self) self.server = XMLRPCServer(("localhost", 5900), register=False, keyfile=keypath, certfile=certpath, cafile=capath) self.server.require_auth = True self.server.credentials = dict(user="******") self.server.register_instance(c) self.proxy = xmlrpclib.ServerProxy("https://*****:*****@localhost:5900") def test_require_auth (self): assert self.server.require_auth == \ self.server.RequestHandlerClass.require_auth == True self.server.RequestHandlerClass.require_auth = False assert self.server.require_auth == \ self.server.RequestHandlerClass.require_auth == False self.server.require_auth = True assert self.server.require_auth == \ self.server.RequestHandlerClass.require_auth == True def test_credentials (self): assert self.server.credentials is \ self.server.RequestHandlerClass.credentials == dict(user="******") self.server.credentials = None assert self.server.credentials is \ self.server.RequestHandlerClass.credentials is None def test_ping_without_auth (self): self.proxy = xmlrpclib.ServerProxy("https://*****:*****@localhost:5900") try: self.test_ping() except: pass else: assert not "Allowed unauthorized access." def test_ping_wrong_password (self): self.proxy = xmlrpclib.ServerProxy("https://*****:*****@localhost:5900") try: self.test_ping() except: pass else: assert not "Allowed unauthorized access."
class TestXMLRPCServer_http_auth (TestXMLRPCServer_http): def setup (self): XMLRPCServerTester.setup(self) self.server = XMLRPCServer(("localhost", 5900), register=False) self.server.require_auth = True self.server.credentials = dict(user="******") self.server.register_instance(c) self.proxy = xmlrpclib.ServerProxy("http://*****:*****@localhost:5900") def test_require_auth (self): assert self.server.require_auth == \ self.server.RequestHandlerClass.require_auth == True self.server.RequestHandlerClass.require_auth = False assert self.server.require_auth == \ self.server.RequestHandlerClass.require_auth == False self.server.require_auth = True assert self.server.require_auth == \ self.server.RequestHandlerClass.require_auth == True def test_credentials (self): assert self.server.credentials is \ self.server.RequestHandlerClass.credentials == dict(user="******") self.server.credentials = None assert self.server.credentials is \ self.server.RequestHandlerClass.credentials is None def test_ping_without_auth (self): self.proxy = xmlrpclib.ServerProxy("http://*****:*****@localhost:5900") try: self.test_ping() except xmlrpclib.Fault: pass else: assert not "Allowed unauthorized access." def test_ping_wrong_password (self): self.proxy = xmlrpclib.ServerProxy("http://*****:*****@localhost:5900") try: self.test_ping() except xmlrpclib.Fault: pass else: assert not "Allowed unauthorized access."
class TestXMLRPCServer_http (XMLRPCServerTester): def setup (self): XMLRPCServerTester.setup(self) self.server = XMLRPCServer(("localhost", 5900), register=False, keyfile=keypath, certfile=certpath, cafile=capath) self.server.register_instance(c) self.proxy = xmlrpclib.ServerProxy("https://localhost:5900") def test_secure (self): assert ssl.PROTOCOL_SSLv23 == self.server.ssl_protocol, self.server.ssl_protocol def test_url (self): hname = socket.gethostname() assert self.server.url == "https://%s:5900" % hname, self.server.url
class TestXMLRPCServer_http (XMLRPCServerTester): def setup (self): XMLRPCServerTester.setup(self) self.server = XMLRPCServer(("localhost", 5900), register=False) self.server.register_instance(c) self.proxy = xmlrpclib.ServerProxy("http://localhost:5900") def test_secure (self): assert not self.server.secure def test_url (self): hname = socket.gethostname() assert self.server.url == "http://%s:5900" % hname
class TestXMLRPCServer_https (XMLRPCServerTester): def setup (self): XMLRPCServerTester.setup(self) assert os.path.exists("keyfile") and os.path.exists("certfile") self.server = XMLRPCServer(("localhost", 5900), keyfile="keyfile", certfile="certfile", register=False) self.server.register_instance(c) self.proxy = xmlrpclib.ServerProxy("https://localhost:5900") def test_secure (self): assert self.server.secure def test_url (self): hname = socket.gethostname() assert self.server.url == "https://%s:5900" % hname
def setup (self): XMLRPCServerTester.setup(self) self.server = XMLRPCServer(("localhost", 5900), register=False, keyfile=keypath, certfile=certpath, cafile=capath) self.server.require_auth = True self.server.credentials = dict(user="******") self.server.register_instance(c) self.proxy = xmlrpclib.ServerProxy("https://*****:*****@localhost:5900")
def setup (self): XMLRPCServerTester.setup(self) assert os.path.exists(keypath) and os.path.exists(certpath) self.server = XMLRPCServer(("localhost", 5900), keyfile=keypath, certfile=certpath, cafile=capath, register=False) self.server.register_instance(c) self.proxy = xmlrpclib.ServerProxy("https://localhost:5900")
cp = ConfigParser.ConfigParser() cp.read([Cobalt.CONFIG_FILES[0]]) keypath = os.path.expandvars(cp.get('communication', 'key')) except: keypath = '/etc/cobalt.key' if single_threaded: server = BaseXMLRPCServer(location, keyfile=keypath, certfile=keypath, register=register, timeout=time_out) else: server = XMLRPCServer(location, keyfile=keypath, certfile=keypath, register=register, timeout=time_out) server.register_instance(component) try: server.serve_forever() finally: server.server_close() def exposed(func): """Mark a method to be exposed publically. Examples: class MyComponent (Component):
def setup (self): XMLRPCServerTester.setup(self) assert os.path.exists("keyfile") and os.path.exists("certfile") self.server = XMLRPCServer(("localhost", 5900), keyfile="keyfile", certfile="certfile", register=False) self.server.register_instance(c) self.proxy = xmlrpclib.ServerProxy("https://localhost:5900")
def setup (self): XMLRPCServerTester.setup(self) self.server = XMLRPCServer(("localhost", 5900), register=False) self.server.register_instance(c) self.proxy = xmlrpclib.ServerProxy("http://localhost:5900")