コード例 #1
0
 def setUp(self):
     super(IsolateServiceTest, self).setUp()
     self.testbed.init_blobstore_stub()
     self.testbed.init_urlfetch_stub()
     # It seems like there is a singleton state preserved across the tests,
     # making it hard to re-run the complete setUp procedure. Therefore we pre-
     # register all the possible identities being used in the tests.
     all_authed_ids = [
         auth.Identity(auth.IDENTITY_USER, '*****@*****.**'),
         auth.Identity(auth.IDENTITY_USER,
                       '*****@*****.**'),
         auth.Identity(auth.IDENTITY_SERVICE, 'adminapp'),
     ]
     admin = all_authed_ids[0]
     full_access_group = config.settings().auth.full_access_group
     auth.bootstrap_group(full_access_group, all_authed_ids)
     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(
         handlers_backend.create_application(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)
コード例 #2
0
ファイル: test_env_handlers.py プロジェクト: pombreda/luci-py
    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()

        # 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)
コード例 #3
0
def create_application(debug):
    replication.configure_as_primary()
    rest_api.set_config_locked(config.is_remote_configured)

    # Configure UI appearance, add all custom tabs.
    ui.configure_ui(app_name='Auth Service',
                    ui_tabs=[
                        ui.GroupsHandler,
                        ui.ChangeLogHandler,
                        ui.LookupHandler,
                        ServicesHandler,
                        ui.OAuthConfigHandler,
                        ui.IPWhitelistsHandler,
                        ConfigHandler,
                        ui.ApiDocHandler,
                    ],
                    ui_data_callback=get_additional_ui_data)
    template.bootstrap({'auth_service': TEMPLATES_DIR})

    # Add a fake admin for local dev server.
    if utils.is_local_dev_server():
        auth.bootstrap_group(
            auth.ADMIN_GROUP,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')],
            'Users that can manage groups')
    return webapp2.WSGIApplication(get_routes(), debug=debug)
コード例 #4
0
ファイル: handlers_frontend.py プロジェクト: rmistry/luci-py
def create_application(debug):
  replication.configure_as_primary()
  rest_api.set_config_locked(config.is_remote_configured)

  # Configure UI appearance, add all custom tabs.
  ui.configure_ui(
      app_name='Auth Service',
      ui_tabs=[
        ui.GroupsHandler,
        ui.ChangeLogHandler,
        ServicesHandler,
        ui.OAuthConfigHandler,
        ui.IPWhitelistsHandler,
        ConfigHandler,
      ],
      env_callback=get_additional_ui_environment)
  template.bootstrap({'auth_service': TEMPLATES_DIR})

  # Add a fake admin for local dev server.
  if utils.is_local_dev_server():
    auth.bootstrap_group(
        auth.ADMIN_GROUP,
        [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')],
        'Users that can manage groups')
  return webapp2.WSGIApplication(get_routes(), debug=debug)
コード例 #5
0
ファイル: test_env_handlers.py プロジェクト: rmistry/luci-py
  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()

    # 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)
コード例 #6
0
ファイル: api_test.py プロジェクト: mcgreevy/chromium-infra
 def test_backfill_tag_index_fails(self):
     auth.bootstrap_group(auth.ADMIN_GROUP, [auth.Anonymous])
     self.call_api('backfill_tag_index', {}, status=400)
     self.call_api('backfill_tag_index', {'tag': 'buildset'}, status=400)
     self.call_api('backfill_tag_index', {
         'tag': 'buildset',
         'shards': 0
     },
                   status=400)
コード例 #7
0
ファイル: handler_utils.py プロジェクト: nicko96/Chrome-Infra
def init_local_dev_server():
  members = [
    auth.Identity.from_bytes('anonymous:anonymous'),
    auth.Identity.from_bytes('user:[email protected]'),
    auth.Identity.from_bytes(
        'user:590116423158-ngd238l7s0a6cbpe96oqkjk5hetbbdjn@'
        'developer.gserviceaccount.com')
  ]
  auth.bootstrap_group('service-account-monitoring-proxy', members)
  auth.bootstrap_group('project-chrome-infra-monitoring-team', members)
コード例 #8
0
def init_local_dev_server():
    members = [
        auth.Identity.from_bytes('anonymous:anonymous'),
        auth.Identity.from_bytes('user:[email protected]'),
        auth.Identity.from_bytes(
            'user:590116423158-ngd238l7s0a6cbpe96oqkjk5hetbbdjn@'
            'developer.gserviceaccount.com')
    ]
    auth.bootstrap_group('service-account-monitoring-proxy', members)
    auth.bootstrap_group('project-chrome-infra-monitoring-team', members)
コード例 #9
0
ファイル: acl.py プロジェクト: brandonscott1780/luci-py
def bootstrap_dev_server_acls():
    """Adds localhost to IP whitelist and Swarming groups."""
    assert utils.is_local_dev_server()
    if auth.is_replica():
        return

    bots = auth.bootstrap_loopback_ips()

    auth_settings = config.settings().auth
    admins_group = auth_settings.admins_group
    users_group = auth_settings.users_group
    bot_bootstrap_group = auth_settings.bot_bootstrap_group

    auth.bootstrap_group(users_group, bots, 'Swarming users')
    auth.bootstrap_group(bot_bootstrap_group, bots, 'Bot bootstrap')

    # Add a swarming admin. [email protected] is used in
    # server_smoke_test.py
    admin = auth.Identity(auth.IDENTITY_USER, '*****@*****.**')
    auth.bootstrap_group(admins_group, [admin], 'Swarming administrators')

    # Add an instance admin (for easier manual testing when running dev server).
    auth.bootstrap_group(
        auth.ADMIN_GROUP,
        [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')],
        'Users that can manage groups')
コード例 #10
0
ファイル: acl.py プロジェクト: misscache/luci-py
def bootstrap():
  """Adds 127.0.0.1 as a whitelisted IP when testing."""
  if not utils.is_local_dev_server() or auth.is_replica():
    return

  # Allow local bots full access.
  bots = auth.bootstrap_loopback_ips()
  auth.bootstrap_group(
      FULL_ACCESS_GROUP, bots, 'Can read and write from/to Isolate')

  # Add a fake admin for local dev server.
  auth.bootstrap_group(
      auth.ADMIN_GROUP,
      [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')],
      'Users that can manage groups')
コード例 #11
0
ファイル: api_test.py プロジェクト: mcgreevy/chromium-infra
 def test_backfill_tag_index(self, enqueue_task):
     auth.bootstrap_group(auth.ADMIN_GROUP, [auth.Anonymous])
     req = {
         'tag': 'buildset',
         'shards': '64',
     }
     self.call_api('backfill_tag_index', req, status=(200, 204))
     enqueue_task.assert_called_once_with(
         'backfill-tag-index',
         '/internal/task/buildbucket/backfill-tag-index/tag:buildset-start',
         utils.encode_to_json({
             'action': 'start',
             'tag': 'buildset',
             'shards': 64,
         }))
コード例 #12
0
ファイル: acl.py プロジェクト: rmistry/luci-py
def bootstrap():
    """Adds 127.0.0.1 as a whitelisted IP when testing."""
    if not utils.is_local_dev_server() or auth.is_replica():
        return

    # Allow local bots full access.
    bots = auth.bootstrap_loopback_ips()
    auth.bootstrap_group(FULL_ACCESS_GROUP, bots,
                         'Can read and write from/to Isolate')

    # Add a fake admin for local dev server.
    auth.bootstrap_group(
        auth.ADMIN_GROUP,
        [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')],
        'Users that can manage groups')
コード例 #13
0
 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()
コード例 #14
0
 def setUp(self):
     """Creates a new app instance for every test case."""
     super(MainTest, self).setUp()
     self.testbed.init_blobstore_stub()
     self.testbed.init_urlfetch_stub()
     admin = auth.Identity(auth.IDENTITY_USER, '*****@*****.**')
     full_access_group = config.settings().auth.full_access_group
     auth.bootstrap_group(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'
     self.app = webtest.TestApp(
         handlers_backend.create_application(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)
コード例 #15
0
    def setUp(self):
        """Creates a new app instance for every test case."""
        super(MainTest, self).setUp()
        self.testbed.init_user_stub()

        self.source_ip = '192.168.0.1'
        self.app = webtest.TestApp(
            handlers_frontend.create_application(debug=True),
            extra_environ={'REMOTE_ADDR': self.source_ip})

        self.auth_app = webtest.TestApp(
            auth.create_wsgi_application(debug=True),
            extra_environ={
                'REMOTE_ADDR': self.source_ip,
                'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'],
            })

        full_access_group = config.settings().auth.full_access_group
        readonly_access_group = config.settings().auth.readonly_access_group

        auth.bootstrap_group(
            auth.ADMIN_GROUP,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
        auth.bootstrap_group(
            readonly_access_group,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
        auth.bootstrap_group(
            full_access_group,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
        self.set_as_anonymous()
コード例 #16
0
def create_application(debug):
  replication.configure_as_primary()

  # Configure UI appearance, add all custom tabs.
  ui.configure_ui(
      app_name='Auth Service',
      ui_tabs=[
        # Standard tabs provided by auth component.
        ui.GroupsHandler,
        ui.OAuthConfigHandler,
        ui.IPWhitelistsHandler,
        # Additional tabs available only on auth service.
        ConfigHandler,
        ServicesHandler,
      ])
  template.bootstrap({'auth_service': TEMPLATES_DIR})

  # Add a fake admin for local dev server.
  if utils.is_local_dev_server():
    auth.bootstrap_group(
        auth.ADMIN_GROUP,
        [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')],
        'Users that can manage groups')
  return webapp2.WSGIApplication(get_routes(), debug=debug)
コード例 #17
0
ファイル: test_env_handlers.py プロジェクト: rmoorman/luci-py
    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, '*****@*****.**')])
コード例 #18
0
ファイル: acl.py プロジェクト: misscache/luci-py
def bootstrap_dev_server_acls():
  """Adds localhost to IP whitelist and Swarming groups."""
  assert utils.is_local_dev_server()
  if auth.is_replica():
    return

  bots = auth.bootstrap_loopback_ips()
  auth.bootstrap_group(BOTS_GROUP, bots, 'Swarming bots')
  auth.bootstrap_group(USERS_GROUP, bots, 'Swarming users')

  # Add a swarming admin. [email protected] is used in
  # server_smoke_test.py
  admin = auth.Identity(auth.IDENTITY_USER, '*****@*****.**')
  auth.bootstrap_group(ADMINS_GROUP, [admin], 'Swarming administrators')

  # Add an instance admin (for easier manual testing when running dev server).
  auth.bootstrap_group(
      auth.ADMIN_GROUP,
      [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')],
      'Users that can manage groups')
コード例 #19
0
ファイル: handlers_test.py プロジェクト: stefb965/luci-py
    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_frontend = webtest.TestApp(
            handlers_frontend.create_application(debug=True),
            extra_environ={'REMOTE_ADDR': self.source_ip})
        # This is awkward but both the frontend and backend applications uses the
        # same template variables.
        template.reset()
        self.app_backend = webtest.TestApp(
            handlers_backend.create_application(debug=True),
            extra_environ={'REMOTE_ADDR': self.source_ip})
        # Tasks are enqueued on the backend.
        self.app = self.app_backend

        self.auth_app = webtest.TestApp(
            auth.create_wsgi_application(debug=True),
            extra_environ={
                'REMOTE_ADDR': self.source_ip,
                'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'],
            })

        full_access_group = config.settings().auth.full_access_group
        readonly_access_group = config.settings().auth.readonly_access_group

        auth.bootstrap_group(
            auth.ADMIN_GROUP,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
        auth.bootstrap_group(
            readonly_access_group,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
        auth.bootstrap_group(
            full_access_group,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
        # TODO(maruel): Create a BOTS_GROUP.

        self.set_as_anonymous()
コード例 #20
0
  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_frontend = webtest.TestApp(
        handlers_frontend.create_application(debug=True),
        extra_environ={'REMOTE_ADDR': self.source_ip})
    # This is awkward but both the frontend and backend applications uses the
    # same template variables.
    template.reset()
    self.app_backend = webtest.TestApp(
        handlers_backend.create_application(debug=True),
        extra_environ={'REMOTE_ADDR': self.source_ip})
    # Tasks are enqueued on the backend.
    self.app = self.app_backend

    self.auth_app = webtest.TestApp(
        auth.create_wsgi_application(debug=True),
        extra_environ={
          'REMOTE_ADDR': self.source_ip,
          'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'],
        })

    auth.bootstrap_group(
        auth.ADMIN_GROUP,
        [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
    auth.bootstrap_group(
        acl.READONLY_ACCESS_GROUP,
        [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
    auth.bootstrap_group(
        acl.FULL_ACCESS_GROUP,
        [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
    # TODO(maruel): Create a BOTS_GROUP.

    self.set_as_anonymous()
コード例 #21
0
 def test_backfill_tag_index(self, launch_tag_index_backfilling):
   auth.bootstrap_group(auth.ADMIN_GROUP, [auth.Anonymous])
   req = {'tag_key': 'buildset'}
   self.call_api('backfill_tag_index', req, status=(200, 204))
   launch_tag_index_backfilling.assert_called_once_with('buildset')
コード例 #22
0
    def setUp(self):
        super(SwarmbucketApiTest, self).setUp()

        self.patch('components.utils.utcnow',
                   autospec=True,
                   return_value=datetime.datetime(2015, 11, 30))

        self.patch(
            'google.appengine.api.app_identity.get_default_version_hostname',
            return_value='cr-buildbucket.appspot.com')

        self.patch('creation._should_be_canary', side_effect=lambda p: p > 50)

        auth_testing.reset_local_state()
        auth.bootstrap_group('all', [auth.Anonymous])
        user.clear_request_cache()

        chromium_cfg = test_util.parse_bucket_cfg('''
          name: "luci.chromium.try"
          acls {
            role: SCHEDULER
            group: "all"
          }
          swarming {
            hostname: "swarming.example.com"
            builders {
              name: "linux"
              swarming_host: "swarming.example.com"
              category: "Chromium"
              build_numbers: YES
              recipe {
                cipd_package: "infra/recipe_bundle"
                cipd_version: "refs/heads/master"
                name: "presubmit"
                properties: "foo:bar"
                properties_j: "baz:1"
              }
              dimensions: "foo:bar"
              dimensions: "baz:baz"
              auto_builder_dimension: YES

              # Override builder cache without timeout to make tests
              # simpler.
              caches {
                path: "builder"
                name: "builder_cache_name"
              }
            }
            builders {
              name: "windows"
              category: "Chromium"
              swarming_host: "swarming.example.com"
              recipe {
                cipd_package: "infra/recipe_bundle"
                cipd_version: "refs/heads/master"
                name: "presubmit"
              }

              # Override builder cache without timeout to make tests
              # simpler.
              caches {
                path: "builder"
                name: "builder_cache_name"
              }
            }
          }
    ''')
        config.put_bucket('chromium', 'deadbeef', chromium_cfg)

        v8_cfg = test_util.parse_bucket_cfg('''
      name: "luci.v8.try"
      acls {
        role: READER
        group: "all"
      }
    ''')
        config.put_bucket('v8', 'deadbeef', v8_cfg)

        props_def = {
            'extra_args': [
                'cook',
                '-recipe',
                '${recipe}',
                '-properties',
                '${properties_json}',
                '-logdog-project',
                '${project}',
            ],
            'cipd_input': {
                'packages': [
                    {
                        'package_name': 'infra/test/bar/${os_ver}',
                        'path': '.',
                        'version': 'latest',
                    },
                    {
                        'package_name': 'infra/test/foo/${platform}',
                        'path': 'third_party',
                        'version': 'stable',
                    },
                ],
            },
        }
        self.task_template = {
            'name':
            'bb-${build_id}-${project}-${builder}',
            'task_slices': [{
                'properties': props_def,
                'wait_for_capacity': False,
            }],
        }

        self.patch(
            'swarming._get_task_template',
            autospec=True,
            return_value=('rev', self.task_template),
        )

        self.settings = service_config_pb2.SettingsCfg(
            swarming=dict(
                milo_hostname='milo.example.com',
                luci_runner_package=dict(
                    package_name='infra/tools/luci_runner',
                    version='luci-runner-version',
                ),
                kitchen_package=dict(
                    package_name='infra/tools/kitchen',
                    version='kitchen-version',
                ),
                user_packages=[
                    dict(
                        package_name='infra/tools/git',
                        version='git-version',
                    ),
                ],
            ),
            logdog=dict(hostname='logdog.example.com'),
        )
        self.patch(
            'config.get_settings_async',
            autospec=True,
            return_value=future(self.settings),
        )
コード例 #23
0
ファイル: main.py プロジェクト: pombreda/luci-py
# Copyright 2014 The Swarming Authors. All rights reserved.
# Use of this source code is governed by the Apache v2.0 license that can be
# found in the LICENSE file.

import webapp2

from components import auth
from components import utils


class WarmupHandler(webapp2.RequestHandler):
    def get(self):
        auth.warmup()
        self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
        self.response.write('ok')


assert utils.is_local_dev_server()
auth.disable_process_cache()

# Add a fake admin for local dev server.
if not auth.is_replica():
    auth.bootstrap_group(
        auth.ADMIN_GROUP,
        [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')],
        'Users that can manage groups')

# /_ah/warmup is used by the smoke test to detect that app is alive.
app = webapp2.WSGIApplication([webapp2.Route(r'/_ah/warmup', WarmupHandler)],
                              debug=True)
コード例 #24
0
ファイル: main.py プロジェクト: mellowdistrict/luci-py
from google.appengine.api import datastore_errors
from google.appengine.ext import ndb

from components import auth
from components import utils


class WarmupHandler(webapp2.RequestHandler):
  def get(self):
    auth.warmup()
    self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
    self.response.write('ok')


assert utils.is_local_dev_server()
auth.disable_process_cache()

# See components/auth/change_log.py, is_changle_log_indexed.
ndb.add_flow_exception(datastore_errors.NeedIndexError)

# Add a fake admin for local dev server.
if not auth.is_replica():
  auth.bootstrap_group(
      auth.ADMIN_GROUP,
      [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')],
      'Users that can manage groups')

# /_ah/warmup is used by the smoke test to detect that app is alive.
app = webapp2.WSGIApplication(
    [webapp2.Route(r'/_ah/warmup', WarmupHandler)], debug=True)
コード例 #25
0
  def setUp(self):
    super(SwarmbucketApiTest, self).setUp()

    self.patch(
        'components.utils.utcnow', autospec=True,
        return_value=datetime.datetime(2015, 11, 30))

    auth_testing.reset_local_state()
    auth.bootstrap_group('all', [auth.Anonymous])

    chromium_cfg = '''
      name: "luci.chromium.try"
      acls {
        role: SCHEDULER
        group: "all"
      }
      swarming {
        hostname: "swarming.example.com"
        builders {
          name: "linux_chromium_rel_ng"
          category: "Chromium"
          build_numbers: true
          recipe {
            repository: "https://example.com"
            name: "presubmit"
          }
        }
        builders {
          name: "win_chromium_rel_ng"
          category: "Chromium"
        }
      }
    '''
    config.Bucket(
        id='luci.chromium.try',
        project_id='chromium',
        revision='deadbeef',
        config_content=chromium_cfg,
        config_content_binary=config_test.text_to_binary(chromium_cfg),
    ).put()

    v8_cfg = '''
      name: "luci.v8.try"
      acls {
        role: READER
        group: "all"
      }
    '''
    config.Bucket(
        id='luci.v8.try',
        project_id='v8',
        revision='deadbeef',
        config_content=v8_cfg,
        config_content_binary=config_test.text_to_binary(v8_cfg),
    ).put()

    self.task_template = {
      'name': 'buildbucket:${bucket}:${builder}',
      'priority': '100',
      'expiration_secs': '3600',
      'properties': {
        'execution_timeout_secs': '3600',
        'extra_args': [
          'cook',
          '-repository', '${repository}',
          '-revision', '${revision}',
          '-recipe', '${recipe}',
          '-properties', '${properties_json}',
          '-logdog-project', '${project}',
        ],
        'caches': [
          {'path': '${cache_dir}/builder', 'name': 'builder_${builder_hash}'},
        ],
        'cipd_input': {
          'packages': [
            {
              'package_name': 'infra/test/bar/${os_ver}',
              'path': '.',
              'version': 'latest',
            },
            {
              'package_name': 'infra/test/foo/${platform}',
              'path': 'third_party',
              'version': 'stable',
            },
          ],
        },
      }
    }

    self.patch(
        'swarming.swarming.get_task_template_async',
        return_value=future(('rev', self.task_template, False)))
コード例 #26
0
 def _add_to_group(group):
     auth.bootstrap_group(group, [auth.get_current_identity()])
     auth_testing.reset_local_state()
コード例 #27
0
    def setUp(self):
        super(SwarmbucketApiTest, self).setUp()

        self.patch('components.utils.utcnow',
                   autospec=True,
                   return_value=datetime.datetime(2015, 11, 30))

        self.patch(
            'google.appengine.api.app_identity.get_default_version_hostname',
            return_value='cr-buildbucket.appspot.com')

        self.patch('creation._should_be_canary', side_effect=lambda p: p > 50)

        auth_testing.reset_local_state()
        auth.bootstrap_group('all', [auth.Anonymous])
        user.clear_request_cache()

        chromium_cfg = test_util.parse_bucket_cfg('''
          name: "luci.chromium.try"
          acls {
            role: SCHEDULER
            group: "all"
          }
          swarming {
            hostname: "swarming.example.com"
            builders {
              name: "linux"
              swarming_host: "swarming.example.com"
              category: "Chromium"
              build_numbers: YES
              recipe {
                cipd_package: "infra/recipe_bundle"
                cipd_version: "refs/heads/master"
                name: "presubmit"
                properties: "foo:bar"
                properties_j: "baz:1"
              }
              dimensions: "foo:bar"
              dimensions: "baz:baz"
              auto_builder_dimension: YES

              # Override builder cache without timeout to make tests
              # simpler.
              caches {
                path: "builder"
                name: "builder_cache_name"
              }
            }
            builders {
              name: "windows"
              category: "Chromium"
              swarming_host: "swarming.example.com"
              recipe {
                cipd_package: "infra/recipe_bundle"
                cipd_version: "refs/heads/master"
                name: "presubmit"
              }

              # Override builder cache without timeout to make tests
              # simpler.
              caches {
                path: "builder"
                name: "builder_cache_name"
              }
            }
          }
    ''')
        config.put_bucket('chromium', 'deadbeef', chromium_cfg)

        v8_cfg = test_util.parse_bucket_cfg('''
      name: "luci.v8.try"
      acls {
        role: READER
        group: "all"
      }
    ''')
        config.put_bucket('v8', 'deadbeef', v8_cfg)

        self.settings = service_config_pb2.SettingsCfg(
            swarming=dict(
                milo_hostname='milo.example.com',
                bbagent_package=dict(
                    package_name='infra/tools/bbagent',
                    version='luci-runner-version',
                ),
                kitchen_package=dict(
                    package_name='infra/tools/kitchen',
                    version='kitchen-version',
                ),
                user_packages=[
                    dict(
                        package_name='infra/tools/git',
                        version='git-version',
                    ),
                ],
            ),
            logdog=dict(hostname='logdog.example.com'),
        )
        self.patch(
            'config.get_settings_async',
            autospec=True,
            return_value=future(self.settings),
        )
コード例 #28
0
 def test_backfill_tag_index_fails(self):
   auth.bootstrap_group(auth.ADMIN_GROUP, [auth.Anonymous])
   self.call_api('backfill_tag_index', {}, status=400)
   self.call_api('backfill_tag_index', {'tag_key': 'a:b'}, status=400)