Exemplo n.º 1
0
  def setUp(self):
    super(V1ApiTest, self).setUp()
    gae_ts_mon.reset_for_unittest(disable=True)
    auth.disable_process_cache()
    user.clear_request_cache()

    self.patch(
        'components.utils.utcnow', return_value=datetime.datetime(2017, 1, 1)
    )
    self.future_date = utils.utcnow() + datetime.timedelta(days=1)
    # future_ts is str because INT64 values are formatted as strings.
    self.future_ts = str(utils.datetime_to_timestamp(self.future_date))

    config.put_bucket(
        'chromium',
        'a' * 40,
        test_util.parse_bucket_cfg(
            '''
            name: "luci.chromium.try"
            acls {
              role: SCHEDULER
              identity: "anonymous:anonymous"
            }
            '''
        ),
    )

    self.build_infra = test_util.build_bundle(id=1).infra
    self.build_infra.put()
Exemplo n.º 2
0
    def setUp(self):
        super(AppTestBase, self).setUp()
        self.bot_version = None
        self.source_ip = '192.168.2.2'
        self.testbed.init_user_stub()

        gae_ts_mon.reset_for_unittest(disable=True)

        # By default requests in tests are coming from bot with fake IP.
        # WSGI app that implements auth REST API.
        self.auth_app = webtest.TestApp(
            auth.create_wsgi_application(debug=True),
            extra_environ={
                'REMOTE_ADDR': self.source_ip,
                'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'],
            })

        # Note that auth.ADMIN_GROUP != acl.ADMINS_GROUP.
        auth.bootstrap_group(
            auth.ADMIN_GROUP,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
        auth.bootstrap_group(
            acl.ADMINS_GROUP,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
        auth.bootstrap_group(
            acl.PRIVILEGED_USERS_GROUP,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
        auth.bootstrap_group(
            acl.USERS_GROUP,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])

        self.mock(stats_framework, 'add_entry', self._parse_line)
Exemplo n.º 3
0
 def setUp(self):
     super(WaterfallTestCase, self).setUp()
     self.UpdateUnitTestConfigSettings()
     self.maxDiff = None
     # Make sure that no tests derived from this actually call urlfetch.fetch.
     mock.patch.object(
         urlfetch,
         'fetch',
         side_effect=AssertionError(
             'unittests must not perform actual network requests. Instead, '
             'mocks should be provided for the methods that do any network '
             'operations')).start()
     gae_ts_mon.reset_for_unittest(disable=True)
Exemplo n.º 4
0
 def setUp(self):
     super(FindItAPITestCase, self).setUp()
     gae_ts_mon.reset_for_unittest(disable=True)
     self.maxDiff = None
     self.client = mock.Mock()
     self.build_client = mock.Mock(return_value=self.client)
     self.patchers = [
         mock.patch('endpoints_client.endpoints.build_client',
                    self.build_client),
         mock.patch('endpoints_client.endpoints.retry_request',
                    mock.Mock()),
     ]
     for patcher in self.patchers:
         patcher.start()
Exemplo n.º 5
0
    def setUpTests(self):
        gae_ts_mon.reset_for_unittest(disable=True)
        auth.disable_process_cache()

        self.future_date = utils.utcnow() + datetime.timedelta(minutes=1)
        # future_ts is str because INT64 values are formatted as strings.
        self.future_ts = str(utils.datetime_to_timestamp(self.future_date))
        self.test_build = model.Build(
            id=1,
            bucket='chromium',
            parameters={
                'buildername': 'linux_rel',
            },
        )
Exemplo n.º 6
0
    def setUp(self):
        super(AppTestBase, self).setUp()
        self.bot_version = None
        self.source_ip = '192.168.2.2'
        self.testbed.init_user_stub()

        gae_ts_mon.reset_for_unittest(disable=True)
        event_mon_metrics.initialize()

        # By default requests in tests are coming from bot with fake IP.
        # WSGI app that implements auth REST API.
        self.auth_app = webtest.TestApp(
            auth.create_wsgi_application(debug=True),
            extra_environ={
                'REMOTE_ADDR': self.source_ip,
                'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'],
            })

        admins_group = 'test_admins_group'
        priv_users_group = 'test_priv_users_group'
        users_group = 'test_users_group'

        cfg = config_pb2.SettingsCfg(auth=config_pb2.AuthSettings(
            admins_group=admins_group,
            privileged_users_group=priv_users_group,
            users_group=users_group,
        ))
        self.mock(config, '_get_settings', lambda: ('test_rev', cfg))
        utils.clear_cache(config.settings)

        # Note that auth.ADMIN_GROUP != admins_group.
        auth.bootstrap_group(
            auth.ADMIN_GROUP,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
        auth.bootstrap_group(
            admins_group,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
        auth.bootstrap_group(
            priv_users_group,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
        auth.bootstrap_group(
            users_group,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
Exemplo n.º 7
0
  def setUp(self):
    super(AppTestBase, self).setUp()
    self.bot_version = None
    self.source_ip = '192.168.2.2'
    self.testbed.init_user_stub()
    self.testbed.init_search_stub()

    gae_ts_mon.reset_for_unittest(disable=True)

    # By default requests in tests are coming from bot with fake IP.
    # WSGI app that implements auth REST API.
    self.auth_app = webtest.TestApp(
        auth.create_wsgi_application(debug=True),
        extra_environ={
          'REMOTE_ADDR': self.source_ip,
          'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'],
        })

    # Note that auth.ADMIN_GROUP != acl.ADMINS_GROUP.
    auth.bootstrap_group(
        auth.ADMIN_GROUP,
        [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
    auth.bootstrap_group(
        acl.ADMINS_GROUP,
        [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
    auth.bootstrap_group(
        acl.PRIVILEGED_USERS_GROUP,
        [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
    auth.bootstrap_group(
        acl.USERS_GROUP,
        [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
    auth.bootstrap_group(
        acl.BOTS_GROUP,
        [auth.Identity(auth.IDENTITY_BOT, self.source_ip)])

    self.mock(stats_framework, 'add_entry', self._parse_line)
Exemplo n.º 8
0
 def setUp(self):
     super(MetricsTest, self).setUp()
     gae_ts_mon.reset_for_unittest(disable=True)
Exemplo n.º 9
0
 def setUp(self):
     super(TestMetrics, self).setUp()
     gae_ts_mon.reset_for_unittest()
     gae_ts_mon.initialize()
     self.now = datetime.datetime(2016, 4, 7)
     self.mock_now(self.now)
Exemplo n.º 10
0
 def setUp(self):
     super(WaterfallTestCase, self).setUp()
     self.UpdateUnitTestConfigSettings()
     self.maxDiff = None
     gae_ts_mon.reset_for_unittest(disable=True)
Exemplo n.º 11
0
 def setUp(self):
     super(AppengineTestCase, self).setUp()
     CrashConfig.Get().Update(users.User(email='*****@*****.**'), True,
                              **DEFAULT_CONFIG_DATA)
     gae_ts_mon.reset_for_unittest(disable=True)
Exemplo n.º 12
0
 def setUp(self):
   super(CQStatusTestCase, self).setUp()
   gae_ts_mon.reset_for_unittest(disable=True)
Exemplo n.º 13
0
 def setUp(self):
   super(TestMetrics, self).setUp()
   gae_ts_mon.reset_for_unittest()
   gae_ts_mon.initialize()
   self.now = datetime.datetime(2016, 4, 7)
   self.mock_now(self.now)