def create_application(debug): template.bootstrap() utils.set_task_queue_module('default') routes = [ # Frontend pages. They return HTML. # Public pages. ('/', RootHandler), ('/stats', stats_gviz.StatsSummaryHandler), # User pages. ('/user/tasks', TasksHandler), ('/user/task/<task_id:[0-9a-fA-F]+>', TaskHandler), ('/user/task/<task_id:[0-9a-fA-F]+>/retry', TaskRetryHandler), ('/user/tasks/cancel', TaskCancelHandler), # Privileged user pages. ('/restricted/bots', BotsListHandler), ('/restricted/bot/<bot_id:[^/]+>', BotHandler), ('/restricted/bot/<bot_id:[^/]+>/delete', BotDeleteHandler), # Admin pages. ('/restricted/config', RestrictedConfigHandler), ('/restricted/upload/bot_config', UploadBotConfigHandler), ('/restricted/upload/bootstrap', UploadBootstrapHandler), # Mapreduce related urls. (r'/restricted/launch_mapreduce', RestrictedLaunchMapReduceJob), # The new APIs: ('/swarming/api/v1/stats/summary/<resolution:[a-z]+>', stats_gviz.StatsGvizSummaryHandler), ('/swarming/api/v1/stats/dimensions/<dimensions:.+>/<resolution:[a-z]+>', stats_gviz.StatsGvizDimensionsHandler), ('/_ah/mail/<to:.+>', EmailHandler), ('/_ah/warmup', WarmupHandler), ] routes = [webapp2.Route(*i) for i in routes] # If running on a local dev server, allow bots to connect without prior # groups configuration. Useful when running smoke test. if utils.is_local_dev_server(): acl.bootstrap_dev_server_acls() # TODO(maruel): Split backend into a separate module. For now add routes here. routes.extend(handlers_backend.get_routes()) routes.extend(handlers_api.get_routes()) routes.extend(handlers_bot.get_routes()) return webapp2.WSGIApplication(routes, debug=debug)
def create_application(debug): template.bootstrap() utils.set_task_queue_module('default') routes = [ # Frontend pages. They return HTML. # Public pages. ('/oldui', OldUIHandler), ('/stats', stats_gviz.StatsSummaryHandler), ('/<page:(bot|botlist|task|tasklist|)>', UIHandler), # User pages. ('/user/tasks', TasksHandler), ('/user/task/<task_id:[0-9a-fA-F]+>', TaskHandler), ('/user/task/<task_id:[0-9a-fA-F]+>/cancel', TaskCancelHandler), ('/user/task/<task_id:[0-9a-fA-F]+>/retry', TaskRetryHandler), # Privileged user pages. ('/restricted/bots', BotsListHandler), ('/restricted/bot/<bot_id:[^/]+>', BotHandler), ('/restricted/bot/<bot_id:[^/]+>/delete', BotDeleteHandler), # Admin pages. ('/restricted/config', RestrictedConfigHandler), ('/restricted/cancel_pending', RestrictedCancelPendingHandler), ('/restricted/upload/bot_config', UploadBotConfigHandler), ('/restricted/upload/bootstrap', UploadBootstrapHandler), # Mapreduce related urls. (r'/restricted/launch_mapreduce', RestrictedLaunchMapReduceJob), # The new APIs: ('/swarming/api/v1/stats/summary/<resolution:[a-z]+>', stats_gviz.StatsGvizSummaryHandler), ('/swarming/api/v1/stats/dimensions/<dimensions:.+>/<resolution:[a-z]+>', stats_gviz.StatsGvizDimensionsHandler), ('/_ah/mail/<to:.+>', EmailHandler), ('/_ah/warmup', WarmupHandler), ] routes = [webapp2.Route(*i) for i in routes] # If running on a local dev server, allow bots to connect without prior # groups configuration. Useful when running smoke test. if utils.is_local_dev_server(): acl.bootstrap_dev_server_acls() routes.extend(handlers_backend.get_routes()) routes.extend(handlers_bot.get_routes()) routes.extend(handlers_endpoints.get_routes()) return webapp2.WSGIApplication(routes, debug=debug)
def setUp(self): super(IsolateServiceTest, self).setUp() self.testbed.init_blobstore_stub() self.testbed.init_urlfetch_stub() auth_testing.mock_get_current_identity(self) version = utils.get_app_version() self.mock(utils, 'get_task_queue_host', lambda: version) self.testbed.setup_env(current_version_id='testbed.version') self.source_ip = '127.0.0.1' # It is needed solely for self.execute_tasks(), which processes tasks queues # on the backend application. self.app = webtest.TestApp( webapp2.WSGIApplication(handlers_backend.get_routes(), debug=True), extra_environ={'REMOTE_ADDR': self.source_ip}) # add a private key; signing depends on config.settings() make_private_key()
def setUp(self): super(IsolateServiceTest, self).setUp() self.testbed.init_blobstore_stub() self.testbed.init_urlfetch_stub() admin = auth.Identity(auth.IDENTITY_USER, '*****@*****.**') auth.bootstrap_group(acl.FULL_ACCESS_GROUP, [admin]) auth_testing.mock_get_current_identity(self, admin) version = utils.get_app_version() self.mock(utils, 'get_task_queue_host', lambda: version) self.testbed.setup_env(current_version_id='testbed.version') self.source_ip = '127.0.0.1' # It is needed solely for self.execute_tasks(), which processes tasks queues # on the backend application. self.app = webtest.TestApp( webapp2.WSGIApplication(handlers_backend.get_routes(), debug=True), extra_environ={'REMOTE_ADDR': self.source_ip}) # add a private key; signing depends on config.settings() make_private_key() # Remove the check for dev server in should_push_to_gs(). self.mock(utils, 'is_local_dev_server', lambda: False)
def setUp(self): """Creates a new app instance for every test case.""" super(MainTest, self).setUp() self.testbed.init_user_stub() # When called during a taskqueue, the call to get_app_version() may fail so # pre-fetch it. version = utils.get_app_version() self.mock(utils, 'get_task_queue_host', lambda: version) self.source_ip = '192.168.0.1' self.app_api = webtest.TestApp( webapp2.WSGIApplication(handlers_api.get_routes(), debug=True), extra_environ={'REMOTE_ADDR': self.source_ip}) # Do not use handlers_backend.create_application() because it also # initializes ereporter2 cron jobs, which requires templates. We want to # make sure templates are not needed for APIs. self.app_backend = webtest.TestApp( webapp2.WSGIApplication(handlers_backend.get_routes(), debug=True), extra_environ={'REMOTE_ADDR': self.source_ip}) # Tasks are enqueued on the backend. self.app = self.app_backend