Exemplo n.º 1
0
 def setUp(self):
     super(ClientApiTest, self).setUp()
     # By default requests in tests are coming from bot with fake IP.
     routes = handlers_bot.get_routes() + handlers_api.get_routes()
     app = webapp2.WSGIApplication(routes, debug=True)
     self.app = webtest.TestApp(
         app, extra_environ={"REMOTE_ADDR": self.source_ip, "SERVER_SOFTWARE": os.environ["SERVER_SOFTWARE"]}
     )
     self.mock(ereporter2, "log_request", lambda *args, **kwargs: self.fail("%s, %s" % (args, kwargs)))
     # Client API test cases run by default as user.
     self.set_as_user()
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
 def setUp(self):
   test_case.EndpointsTestCase.setUp(self)
   super(BaseTest, self).setUp()
   self.mock(auth, 'is_group_member', lambda *_args, **_kwargs: True)
   # handlers_bot is necessary to create fake tasks.
   self.app = webtest.TestApp(
       webapp2.WSGIApplication(handlers_bot.get_routes(), debug=True),
       extra_environ={
         'REMOTE_ADDR': self.source_ip,
         'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'],
       })
   self.mock(
       ereporter2, 'log_request',
       lambda *args, **kwargs: self.fail('%s, %s' % (args, kwargs)))
   # Client API test cases run by default as user.
   self.set_as_user()
Exemplo n.º 5
0
 def setUp(self):
     super(BotApiTest, self).setUp()
     # By default requests in tests are coming from bot with fake IP.
     routes = handlers_bot.get_routes() + handlers_api.get_routes()
     app = webapp2.WSGIApplication(routes, debug=True)
     self.app = webtest.TestApp(app,
                                extra_environ={
                                    'REMOTE_ADDR':
                                    self.source_ip,
                                    'SERVER_SOFTWARE':
                                    os.environ['SERVER_SOFTWARE'],
                                })
     self.mock(ereporter2, 'log_request',
               lambda *args, **kwargs: self.fail('%s, %s' % (args, kwargs)))
     # Bot API test cases run by default as bot.
     self.set_as_bot()
Exemplo n.º 6
0
 def setUp(self):
   super(BotApiTest, self).setUp()
   # By default requests in tests are coming from bot with fake IP.
   routes = handlers_bot.get_routes()
   app = webapp2.WSGIApplication(routes, debug=True)
   self.app = webtest.TestApp(
       app,
       extra_environ={
         'REMOTE_ADDR': self.source_ip,
         'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'],
       })
   self.mock(
       ereporter2, 'log_request',
       lambda *args, **kwargs: self.fail('%s, %s' % (args, kwargs)))
   # Bot API test cases run by default as bot.
   self.set_as_bot()
Exemplo n.º 7
0
 def setUp(self):
   test_case.EndpointsTestCase.setUp(self)
   super(BaseTest, self).setUp()
   self.mock(auth, 'is_group_member', lambda *_args, **_kwargs: True)
   # handlers_bot is necessary to create fake tasks.
   self.app = webtest.TestApp(
       webapp2.WSGIApplication(handlers_bot.get_routes(), debug=True),
       extra_environ={
         'REMOTE_ADDR': self.source_ip,
         'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'],
       })
   self.mock(
       ereporter2, 'log_request',
       lambda *args, **kwargs: self.fail('%s, %s' % (args, kwargs)))
   # Client API test cases run by default as user.
   self.set_as_user()
 def setUp(self):
   super(PRPCTest, self).setUp()
   # handlers_bot is necessary to run fake tasks.
   routes = handlers_prpc.get_routes() + handlers_bot.get_routes()
   self.app = webtest.TestApp(
       webapp2.WSGIApplication(routes, debug=True),
       extra_environ={
         'REMOTE_ADDR': self.source_ip,
         'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'],
       },
   )
   self._headers = {
     'Content-Type': encoding.Encoding.JSON[1],
     'Accept': encoding.Encoding.JSON[1],
   }
   self._enqueue_task_orig = self.mock(
       utils, 'enqueue_task', self._enqueue_task)
   self.now = datetime.datetime(2010, 1, 2, 3, 4, 5)
   self.mock_now(self.now)
   self.mock_default_pool_acl([])
def create_application(debug):
    routes = []
    routes.extend(get_routes())
    routes.extend(handlers_bot.get_routes())
    routes.extend(handlers_endpoints.get_routes())
    return webapp2.WSGIApplication(routes, debug=debug)