當前位置: 首頁>>代碼示例>>Python>>正文


Python secret.Secret類代碼示例

本文整理匯總了Python中app.util.secret.Secret的典型用法代碼示例。如果您正苦於以下問題:Python Secret類的具體用法?Python Secret怎麽用?Python Secret使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Secret類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_matching_digests_should_return_true

    def test_matching_digests_should_return_true(self):
        secret = 'secrettoken'
        message = 'message blah blah horse battery staple'
        Secret.set(secret)
        digest_received = Secret._get_hex_digest(message, secret)

        self.assertTrue(Secret.digest_is_valid(digest_received, message))
開發者ID:drobertduke,項目名稱:ClusterRunner,代碼行數:7,代碼來源:test_secret.py

示例2: test_unspecified_digest_should_return_false

    def test_unspecified_digest_should_return_false(self):
        secret = 'secrettoken'
        message = 'message blah blah horse battery staple'
        Secret.set(secret)
        digest_received = None

        self.assertFalse(Secret.digest_is_valid(digest_received, message))
開發者ID:drobertduke,項目名稱:ClusterRunner,代碼行數:7,代碼來源:test_secret.py

示例3: test_non_matching_digests_should_return_false

    def test_non_matching_digests_should_return_false(self):
        secret = 'secrettoken'
        message = 'message blah blah horse battery staple'
        Secret.set(secret)
        digest_received = Secret._get_hex_digest('not the original message', secret)

        self.assertFalse(Secret.digest_is_valid(digest_received, message))
開發者ID:drobertduke,項目名稱:ClusterRunner,代碼行數:7,代碼來源:test_secret.py

示例4: setUp

    def setUp(self):
        # Configure logging to go to stdout. This makes debugging easier by allowing us to see logs for failed tests.
        log.configure_logging('DEBUG')

        Secret.set('testsecret')

        self.cluster = FunctionalTestCluster(verbose=self._get_test_verbosity())
開發者ID:fengshao0907,項目名稱:ClusterRunner,代碼行數:7,代碼來源:base_functional_test_case.py

示例5: _set_secret

def _set_secret(config_filename):
    if 'secret' in Configuration and Configuration['secret'] is not None:
        secret = Configuration['secret']
    else:  # No secret found, generate one and persist it
        secret = hashlib.sha512().hexdigest()
        conf_file = ConfigFile(config_filename)
        conf_file.write_value('secret', secret, BASE_CONFIG_FILE_SECTION)
    Secret.set(secret)
開發者ID:Medium,項目名稱:ClusterRunner,代碼行數:8,代碼來源:main.py

示例6: _set_secret

def _set_secret(config_filename):
    if 'secret' in Configuration and Configuration['secret'] is not None:
        secret = Configuration['secret']
    else:  # No secret found, generate one and persist it
        secret_length = 128
        chars = string.ascii_lowercase + string.digits
        secret = ''.join(random.SystemRandom().choice(chars) for _ in range(secret_length))
        conf_file = ConfigFile(config_filename)
        conf_file.write_value('secret', secret, BASE_CONFIG_FILE_SECTION)
    Secret.set(secret)
開發者ID:box,項目名稱:ClusterRunner,代碼行數:10,代碼來源:__main__.py

示例7: setUp

    def setUp(self):
        # Configure logging to go to stdout. This makes debugging easier by allowing us to see logs for failed tests.
        log.configure_logging('DEBUG')

        self._reset_config()
        Secret.set('testsecret')
        SlaveRegistry.reset_singleton()

        self.cluster = FunctionalTestCluster(verbose=self._get_test_verbosity())
        self._network = Network()
開發者ID:box,項目名稱:ClusterRunner,代碼行數:10,代碼來源:base_functional_test_case.py

示例8: setUp

    def setUp(self):
        # Configure logging to go to stdout. This makes debugging easier by allowing us to see logs for failed tests.
        log.configure_logging('DEBUG')

        Secret.set('testsecret')
        self.test_app_base_dir = tempfile.TemporaryDirectory()

        self.test_conf_file_path = self._create_test_config_file({
            'secret': Secret.get(),
            'base_directory': self.test_app_base_dir.name,
        })

        self.cluster = FunctionalTestCluster(
            conf_file_path=self.test_conf_file_path,
            verbose=self._get_test_verbosity(),
        )
開發者ID:drobertduke,項目名稱:ClusterRunner,代碼行數:16,代碼來源:base_functional_test_case.py

示例9: kill

 def kill(self):
     """
     Instructs the slave process to kill itself.
     """
     kill_url = self._slave_api.url('kill')
     self._network.post_with_digest(kill_url, {}, Secret.get())
     self.mark_dead()
開發者ID:fengshao0907,項目名稱:ClusterRunner,代碼行數:7,代碼來源:slave.py

示例10: _create_test_config_file

    def _create_test_config_file(self, base_dir_sys_path):
        """
        Create a temporary conf file just for this test.

        :param base_dir_sys_path: Sys path of the base app dir
        :type base_dir_sys_path: unicode

        :return: The path to the conf file
        :rtype: str
        """
        # Copy default conf file to tmp location
        self._conf_template_path = join(self._clusterrunner_repo_dir, 'conf', 'default_clusterrunner.conf')
        # Create the conf file inside base dir so we can clean up the test at the end just by removing the base dir
        test_conf_file_path = tempfile.NamedTemporaryFile(dir=base_dir_sys_path).name
        shutil.copy(self._conf_template_path, test_conf_file_path)
        os.chmod(test_conf_file_path, ConfigFile.CONFIG_FILE_MODE)
        conf_file = ConfigFile(test_conf_file_path)

        # Set custom conf file values for this test
        conf_values_to_set = {
            'secret': Secret.get(),
            'base_directory': base_dir_sys_path,
            'max_log_file_size': 1024 * 5,
        }
        for conf_key, conf_value in conf_values_to_set.items():
            conf_file.write_value(conf_key, conf_value, BASE_CONFIG_FILE_SECTION)

        return test_conf_file_path
開發者ID:fengshao0907,項目名稱:ClusterRunner,代碼行數:28,代碼來源:functional_test_cluster.py

示例11: test_git_project_params_are_modified_for_slave

    def test_git_project_params_are_modified_for_slave(self):
        slave = self._create_slave()
        slave._network.post_with_digest = Mock()

        build_request = BuildRequest({
            'type': 'git',
            'url': 'http://original-user-specified-url',
        })
        mock_git = Mock(slave_param_overrides=Mock(return_value={
            'url': 'ssh://new-url-for-clusterrunner-master',
            'extra': 'something_extra',
        }))
        mock_build = MagicMock(spec=Build, build_request=build_request,
                               build_id=Mock(return_value=888), project_type=mock_git)

        slave.setup(mock_build, executor_start_index=777)

        slave._network.post_with_digest.assert_called_with(
            'http://{}/v1/build/888/setup'.format(self._FAKE_SLAVE_URL),
            {
                'build_executor_start_index': 777,
                'project_type_params': {
                    'type': 'git',
                    'url': 'ssh://new-url-for-clusterrunner-master',
                    'extra': 'something_extra'}
            },
            Secret.get()
        )
開發者ID:box,項目名稱:ClusterRunner,代碼行數:28,代碼來源:test_slave.py

示例12: setup

    def setup(self, build: Build, executor_start_index: int) -> bool:
        """
        Execute a setup command on the slave for the specified build. The setup process executes asynchronously on the
        slave and the slave will alert the master when setup is complete and it is ready to start working on subjobs.

        :param build: The build to set up this slave to work on
        :param executor_start_index: The index the slave should number its executors from for this build
        :return: Whether or not the call to start setup on the slave was successful
        """
        slave_project_type_params = build.build_request.build_parameters().copy()
        slave_project_type_params.update(build.project_type.slave_param_overrides())

        setup_url = self._slave_api.url('build', build.build_id(), 'setup')
        post_data = {
            'project_type_params': slave_project_type_params,
            'build_executor_start_index': executor_start_index,
        }

        self.current_build_id = build.build_id()
        try:
            self._network.post_with_digest(setup_url, post_data, Secret.get())
        except (requests.ConnectionError, requests.Timeout) as ex:
            self._logger.warning('Setup call to {} failed with {}: {}.', self, ex.__class__.__name__, str(ex))
            self.mark_dead()
            return False
        return True
開發者ID:box,項目名稱:ClusterRunner,代碼行數:26,代碼來源:slave.py

示例13: setUp

    def setUp(self):
        # Configure logging to go to stdout. This makes debugging easier by allowing us to see logs for failed tests.
        log.configure_logging('DEBUG')

        Secret.set('testsecret')
        self.test_app_base_dir = tempfile.TemporaryDirectory()

        self.test_conf_file_path = self._create_test_config_file({
            'secret': Secret.get(),
            'base_directory': self.test_app_base_dir.name,
            # Set the max log file size to a low value so that we cause  at least one rollover during the test.
            'max_log_file_size': 1024 * 5,
        })

        self.cluster = FunctionalTestCluster(
            conf_file_path=self.test_conf_file_path,
            verbose=self._get_test_verbosity(),
        )
開發者ID:dncarley,項目名稱:ClusterRunner,代碼行數:18,代碼來源:base_functional_test_case.py

示例14: _notify_master_of_state_change

    def _notify_master_of_state_change(self, new_state):
        """
        Send a state notification to the master. This is used to notify the master of events occurring on the slave
        related to build execution progress.

        :type new_state: SlaveState
        """
        state_url = self._master_api.url('slave', self._slave_id)
        self._network.put_with_digest(state_url, request_params={'slave': {'state': new_state}},
                                      secret=Secret.get(), error_on_failure=True)
開發者ID:dncarley,項目名稱:ClusterRunner,代碼行數:10,代碼來源:cluster_slave.py

示例15: _async_start_subjob

    def _async_start_subjob(self, subjob):
        """
        :type subjob: Subjob
        """
        execution_url = self._slave_api.url('build', subjob.build_id(), 'subjob', subjob.subjob_id())
        post_data = {'atomic_commands': subjob.atomic_commands()}
        response = self._network.post_with_digest(execution_url, post_data, Secret.get(), error_on_failure=True)

        subjob_executor_id = response.json().get('executor_id')
        analytics.record_event(analytics.MASTER_TRIGGERED_SUBJOB, executor_id=subjob_executor_id,
                               build_id=subjob.build_id(), subjob_id=subjob.subjob_id(), slave_id=self.id)
開發者ID:fengshao0907,項目名稱:ClusterRunner,代碼行數:11,代碼來源:slave.py


注:本文中的app.util.secret.Secret類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。