Esempio n. 1
0
    def setUp(self):
        self.execution_info = external_model.ExecutionInfo()
        self.config = script_configs.Config()

        test_utils.setup()

        super().setUp()
Esempio n. 2
0
    def setUp(self):
        super().setUp()
        test_utils.setup()

        authorizer = Authorizer([], [], EmptyGroupProvider())
        self.user1 = User('user1', {})
        self.config_service = ConfigService(authorizer, test_utils.temp_folder)
Esempio n. 3
0
def main():
    # The the path to the app.yaml file and parse it.
    appconfigs = getconfigs(
        os.path.join(os.path.split(os.path.split(os.path.abspath(__file__))[0])[0], "google-app-engine")
    )

    # Set the host names.
    localhost = "localhost:8080"
    remote_host = str(appconfigs.get("version")) + ".latest." + appconfigs.get("application") + ".appspot.com"

    if checkhost(localhost):
        host = localhost
    elif checkhost(remote_host):
        host = remote_host
    else:
        raise Exception("no connection to %s or %s" % (localhost, remote_host))

    # Inform the test suites of the host discovery.
    test_utils.setup(host, (host is localhost))

    # Get the command line arguments.
    suites_ = sys.argv[1:]
    if len(suites_) is 0:
        suites_ = ["full"]

    # Tell the user we're running.
    print ""
    print "Running tests on: %s" % host
    print "Running suites: %s" % suites_
    print ""

    # Run the tests.
    suites.run_suites(suites_)
    def setUp(self):
        super().setUp()
        test_utils.setup()

        authorizer = Authorizer([], ['admin_user'], EmptyGroupProvider())
        self.admin_user = User('admin_user', {})
        self.config_service = ConfigService(authorizer, test_utils.temp_folder)
    def setUp(self) -> None:
        super().setUp()

        test_utils.setup()
        self.requires_explicit_ioloop_factory = os_utils.is_win(
        ) and env_utils.is_min_version('3.8')
        self.windows = os_utils.is_win()
Esempio n. 6
0
    def setUp(self):
        test_utils.setup()

        self.exit_codes = {}
        self.post_info_provider = _MapBasedPostExecInfo(self.exit_codes)

        self.logging_service = ExecutionLoggingService(test_utils.temp_folder)
Esempio n. 7
0
    def setUp(self):
        self.config = create_config_model('config_x')
        self.config.script_command = 'ls'
        executor._process_creator = _MockProcessWrapper

        test_utils.setup()

        super().setUp()
Esempio n. 8
0
    def setUp(self):
        super().setUp()
        test_utils.setup()

        self.user = User('ConfigServiceTest',
                         {AUTH_USERNAME: '******'})
        self.config_service = ConfigService(AnyUserAuthorizer(),
                                            test_utils.temp_folder)
    def setUp(self):
        test_utils.setup()

        self.authorizer = Authorizer([], [], ['power_user'], [],
                                     EmptyGroupProvider())
        self.logging_service = ExecutionLoggingService(test_utils.temp_folder,
                                                       LogNameCreator(),
                                                       self.authorizer)
Esempio n. 10
0
def main():
  localhost = 'localhost:8080'
  passkey = 'secret$key'

  appconfigs = getconfigs(
      os.path.join(
        os.path.split(
          os.path.split(os.path.abspath(__file__))[0])[0],
        'gae_py'))

  remote_host = (str(appconfigs.get('version')) +'.latest.'+
                 appconfigs.get('application') +'.appspot.com')

  if checkhost(localhost):
    host = localhost
    cxn = httplib.HTTPConnection(localhost)
    cxn.request('PUT', '/testsetup', None, {'Content-Length':0})
    response = cxn.getresponse()
    assert response.status == 200, \
        'Test user was not setup (status: %d)'% response.status
    temp_test_admin = response.read().rstrip()
    assert isinstance(temp_test_admin, basestring), \
        'Temp username is not a string ().'% temp_test_admin

  elif checkhost(remote_host):
    host = remote_host
    temp_test_admin, passkey = authenticate(host)
    if temp_test_admin is None:
      print 'User does not exist.'
      exit()
    if passkey is None:
      print 'Invalid passkey... exit()'
      exit()

  else:
    raise Exception('no connection to %s or %s'% (localhost, remote_host))

  test_utils.setup(host, (host is localhost), temp_test_admin, passkey)

  suites_ = sys.argv[1:]
  if len(suites_) is 0:
    suites_ = ['full']

  print ''
  print 'Running tests on: %s' % host 
  print 'Running suites: %s' % suites_
  print 'Using admin account for: %s'% temp_test_admin
  print ''

  suites.run_suites(suites_)

  # Teardown insecure user created for testing.
  try:
    teardown.teardown()
  except Exception, e:
    print ''
    print '!Error in teardown: %r'% e
    print ''
    def setUp(self):
        super().setUp()
        test_utils.setup()

        executor._process_creator = _MockProcessWrapper
        self.executor_service = ExecutionService(AnyUserAuthorizer(), _IdGeneratorMock())

        self.feature = FileDownloadFeature(UserFileStorage(b'123456'), test_utils.temp_folder)
        self.feature.subscribe(self.executor_service)
    def setUp(self):
        super().setUp()
        test_utils.setup()

        executor._process_creator = _MockProcessWrapper
        self.executor_service = ExecutionService(_IdGeneratorMock())

        self.feature = FileDownloadFeature(UserFileStorage(b'123456'), test_utils.temp_folder)
        self.feature.subscribe(self.executor_service)
Esempio n. 13
0
    def setUp(self) -> None:
        super().setUp()

        test_utils.setup()
        self.requires_explicit_ioloop_factory = os_utils.is_win(
        ) and env_utils.is_min_version('3.8')
        self.windows = os_utils.is_win()

        self.conf_folder = test_utils.create_dir(os.path.join('conf'))
        self.runners_folder = os.path.join(self.conf_folder, 'runners')
Esempio n. 14
0
    def setUp(self):
        test_utils.setup()

        executor._process_creator = _MockProcessWrapper

        self.logging_service = ExecutionLoggingService(test_utils.temp_folder, LogNameCreator())
        self.executor_service = ExecutionService(_IdGeneratorMock())

        self.controller = ExecutionLoggingController(self.executor_service, self.logging_service)
        self.controller.start()
Esempio n. 15
0
    def setUp(self):
        super().setUp()
        test_utils.setup()

        authorizer = Authorizer([], ['admin_user'], EmptyGroupProvider())
        self.admin_user = User('admin_user', {})
        self.config_service = ConfigService(authorizer, test_utils.temp_folder)

        for suffix in 'XYZ':
            _create_script_config_file('conf' + suffix, name='Conf ' + suffix)
Esempio n. 16
0
    def setUp(self):
        test_utils.setup()

        executor._process_creator = _MockProcessWrapper

        authorizer = Authorizer([], [], [], EmptyGroupProvider())
        self.logging_service = ExecutionLoggingService(test_utils.temp_folder, LogNameCreator(), authorizer)
        self.executor_service = ExecutionService(_IdGeneratorMock())

        self.controller = ExecutionLoggingController(self.executor_service, self.logging_service)
        self.controller.start()
Esempio n. 17
0
    def setUp(self) -> None:
        test_utils.setup()

        executor._process_creator = _MockProcessWrapper
        self.executor_service = ExecutionService(_IdGeneratorMock())

        self.file_download_feature = file_download_feature.FileDownloadFeature(
            UserFileStorage(b'123456'), test_utils.temp_folder)
        self.file_download_feature.subscribe(self.executor_service)

        self.images = []
Esempio n. 18
0
    def setUp(self):
        super().setUp()

        self.socket = None

        application = tornado.web.Application(
            [(r'/scripts/([^/]*)', ScriptConfigSocket)],
            login_url='/login.html',
            cookie_secret='12345')
        application.auth = TornadoAuth(None)
        application.authorizer = Authorizer(ANY_USER, [], [],
                                            EmptyGroupProvider())
        application.identification = IpBasedIdentification(
            TrustedIpValidator(['127.0.0.1']), None)
        application.config_service = ConfigService(application.authorizer,
                                                   test_utils.temp_folder)

        server = httpserver.HTTPServer(application)
        socket, self.port = testing.bind_unused_port()
        server.add_socket(socket)

        test_utils.setup()

        for dir in ['x', 'y', 'z']:
            for file in range(1, 4):
                filename = dir + str(file) + '.txt'
                test_utils.create_file(
                    os.path.join('test1_files', dir, filename))

        test1_files_path = os.path.join(test_utils.temp_folder, 'test1_files')
        test_utils.write_script_config(
            {
                'name':
                'Test script 1',
                'script_path':
                'ls',
                'parameters': [
                    test_utils.create_script_param_config('text 1',
                                                          required=True),
                    test_utils.create_script_param_config(
                        'list 1', type='list', allowed_values=['A', 'B', 'C']),
                    test_utils.create_script_param_config(
                        'file 1',
                        type='server_file',
                        file_dir=test1_files_path),
                    test_utils.create_script_param_config(
                        'list 2',
                        type='list',
                        values_script='ls ' + test1_files_path + '/${file 1}')
                ]
            }, 'test_script_1')
Esempio n. 19
0
    def setUp(self) -> None:
        super().setUp()
        test_utils.setup()

        authorizer = Authorizer([], ['admin_user', 'admin_non_editor'], [],
                                ['admin_user'], EmptyGroupProvider())
        self.admin_user = User('admin_user', {})
        self.config_service = ConfigService(authorizer, test_utils.temp_folder)

        for pair in [('script.py', b'123'), ('another.py', b'xyz'),
                     ('binary 1.bin', bytes.fromhex('300000004000000a')),
                     ('my_python', bytes.fromhex('7F454C46'))]:
            path = os.path.join(test_utils.temp_folder, pair[0])
            file_utils.write_file(path, pair[1], byte_content=True)
    def setUp(self) -> None:
        super().setUp()

        self.patcher = patch('sched.scheduler')
        self.scheduler_mock = MagicMock()
        self.patcher.start().return_value = self.scheduler_mock

        schedule_service._sleep = MagicMock()
        schedule_service._sleep.side_effect = lambda x: time.sleep(0.001)

        self.unschedulable_scripts = set()
        self.config_service = MagicMock()
        self.config_service.load_config_model.side_effect = lambda name, b, c: test_utils.create_config_model(
            name,
            schedulable=name not in self.unschedulable_scripts)

        self.execution_service = MagicMock()

        self.schedule_service = ScheduleService(self.config_service, self.execution_service, test_utils.temp_folder)

        date_utils._mocked_now = mocked_now

        test_utils.setup()
Esempio n. 21
0
    def setUp(self) -> None:
        super().setUp()
        test_utils.setup()

        self.patcher = patch('sched.scheduler')
        self.scheduler_mock = MagicMock()
        self.patcher.start().return_value = self.scheduler_mock

        schedule_service._sleep = MagicMock()
        schedule_service._sleep.side_effect = lambda x: time.sleep(0.001)

        self.config_service = ConfigService(AnyUserAuthorizer(),
                                            test_utils.temp_folder)

        self.create_config('my_script_A')
        self.create_config('unschedulable-script', scheduling_enabled=False)

        self.execution_service = MagicMock()

        self.schedule_service = ScheduleService(self.config_service,
                                                self.execution_service,
                                                test_utils.temp_folder)

        date_utils._mocked_now = mocked_now
    def setUp(self):
        test_utils.setup()

        os.makedirs(_UPLOADS_FOLDER)
Esempio n. 23
0
    def setUp(self):
        test_utils.setup()

        self.logging_service = ExecutionLoggingService(test_utils.temp_folder, LogNameCreator())
    def setUp(self):
        test_utils.setup()

        os.makedirs(_UPLOADS_FOLDER)
Esempio n. 25
0
    def setUp(self) -> None:
        super().setUp()
        test_utils.setup()

        self.file_path = test_utils.create_file('some_file',
                                                text=htpasswd_content)
Esempio n. 26
0
    def setUp(self):
        self.output_stream = Observable()

        test_utils.setup()

        super().setUp()
Esempio n. 27
0
    def setUp(self):
        test_utils.setup()

        super().setUp()
Esempio n. 28
0
 def setUp(self):
     test_utils.setup()
     self.__storage = UserFileStorage(b'12345678')
     self.upload_feature = FileUploadFeature(self.__storage, test_utils.temp_folder)
Esempio n. 29
0
 def setUp(self):
     super().setUp()
     test_utils.setup()
Esempio n. 30
0
    def setUp(self):
        test_utils.setup()

        self.logging_service = ExecutionLoggingService(test_utils.temp_folder,
                                                       LogNameCreator())
Esempio n. 31
0
 def setUp(self):
     test_utils.setup()
Esempio n. 32
0
 def setUp(self):
     test_utils.setup()
Esempio n. 33
0
    def setUp(self):
        self.output_stream = Observable()

        test_utils.setup()

        super().setUp()
Esempio n. 34
0
 def setUp(self):
     executor._process_creator = _MockProcessWrapper
     test_utils.setup()
Esempio n. 35
0
    def setUp(self):
        super().setUp()
        test_utils.setup()

        self.user = User('ConfigServiceTest', {AUTH_USERNAME: '******'})
        self.config_service = ConfigService(AnyUserAuthorizer(), test_utils.temp_folder)
Esempio n. 36
0
 def setUp(self) -> None:
     test_utils.setup()
Esempio n. 37
0
 def setUp(self):
     test_utils.setup()
     self.storage = UserFileStorage(b'12345678')
Esempio n. 38
0
    def setUp(self) -> None:
        super().setUp()
        test_utils.setup()

        mock_time.return_value = 10000.01
Esempio n. 39
0
    def setUp(self) -> None:
        super().setUp()

        test_utils.setup()
Esempio n. 40
0
    def setUp(self):
        test_utils.setup()

        self.auth_wrapper = self.create_wrapper()
Esempio n. 41
0
 def setUp(self):
     test_utils.setup()
     self.storage = UserFileStorage(b'12345678')