示例#1
0
 def test_make_websocket_url_without_base_url(self):
     wcommon = WebServiceCommon(reactor=the_reactor,
                                title='',
                                ws_endpoint_string='tcp:1234')
     request = FakeRequest()
     self.assertEqual('ws://fake-request-hostname:1234/testpath',
                      wcommon.make_websocket_url(request, '/testpath'))
示例#2
0
 def test_make_websocket_url_with_base_url_with_path(self):
     wcommon = WebServiceCommon(reactor=the_reactor,
                                title='',
                                ws_endpoint_string='tcp:1234',
                                ws_base_url='wss://wshost:5678/ws/')
     request = FakeRequest()
     self.assertEqual('wss://wshost:5678/ws/testpath',
                      wcommon.make_websocket_url(request, '/testpath'))
示例#3
0
 def setUp(self):
     wcommon = WebServiceCommon.stub(reactor=the_reactor)
     self.obj = StateSpecimen()
     r = BlockResource(self.obj, wcommon, None)
     self.port = the_reactor.listenTCP(0,
                                       SiteWithDefaultHeaders(r),
                                       interface="127.0.0.1")  # pylint: disable=no-member
示例#4
0
 def __init__(self, reactor, cap_table, http_endpoint, ws_endpoint, root_cap, title):
     # Constants
     self.__http_endpoint_string = str(http_endpoint)
     self.__http_endpoint = endpoints.serverFromString(reactor, self.__http_endpoint_string)
     self.__ws_endpoint = endpoints.serverFromString(reactor, str(ws_endpoint))
     self.__visit_path = _make_cap_url(root_cap)
     
     wcommon = WebServiceCommon(
         reactor=reactor,
         title=title,
         ws_endpoint_string=ws_endpoint)
     # TODO: Create poller actually for the given reactor w/o redundancy -- perhaps there should be a one-poller-per-reactor map
     subscription_context = SubscriptionContext(reactor=reactor, poller=the_poller)
     
     def resource_factory(entry_point):
         # TODO: If not an IWebEntryPoint, return a generic result
         return IWebEntryPoint(entry_point).get_entry_point_resource(wcommon=wcommon)  # pylint: disable=redundant-keyword-arg
     
     server_root = CapAccessResource(cap_table=cap_table, resource_factory=resource_factory)
     _put_root_static(wcommon, server_root)
     
     if UNIQUE_PUBLIC_CAP in cap_table:
         # TODO: consider factoring out "generate URL for cap"
         server_root.putChild('', Redirect(_make_cap_url(UNIQUE_PUBLIC_CAP)))
         
     self.__ws_protocol = txws.WebSocketFactory(
         FactoryWithArgs.forProtocol(WebSocketDispatcherProtocol, cap_table, subscription_context))
     self.__site = SiteWithDefaultHeaders(server_root)
     
     self.__ws_port_obj = None
     self.__http_port_obj = None
示例#5
0
 def test_resource_smoke(self):
     IResource(self.session.get_entry_point_resource(
         wcommon=WebServiceCommon.stub(reactor=the_reactor)))
示例#6
0
 def test_make_websocket_url_relative(self):
     wcommon = WebServiceCommon.stub(the_reactor)
     request = FakeRequest()
     self.assertRaises(
         AssertionError,
         lambda: wcommon.make_websocket_url(request, 'boguspath'))
示例#7
0
 def setUp(self):
     wcommon = WebServiceCommon.stub(reactor=the_reactor)
     self.obj = StateSpecimen()
     r = BlockResource(self.obj, wcommon, None)
     self.port = the_reactor.listenTCP(0, SiteWithDefaultHeaders(r), interface="127.0.0.1")  # pylint: disable=no-member
示例#8
0
 def test_resource_smoke(self):
     IResource(self.session.get_entry_point_resource(
         wcommon=WebServiceCommon.stub(reactor=the_reactor)))