当前位置: 首页>>代码示例>>Python>>正文


Python manager.SecretManager类代码示例

本文整理汇总了Python中buildbot.secrets.manager.SecretManager的典型用法代码示例。如果您正苦于以下问题:Python SecretManager类的具体用法?Python SecretManager怎么用?Python SecretManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SecretManager类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestRenderSecrets

class TestRenderSecrets(unittest.TestCase):

    def setUp(self):
        self.master = fakemaster.make_master()
        fakeStorageService = FakeSecretStorage(secretdict={"foo": "bar",
                                                       "other": "value"})
        self.secretsrv = SecretManager()
        self.secretsrv.services = [fakeStorageService]
        self.secretsrv.setServiceParent(self.master)
        self.srvtest = FakeServiceUsingSecrets()
        self.srvtest.setServiceParent(self.master)
        self.successResultOf(self.master.startService())

    @defer.inlineCallbacks
    def tearDown(self):
        yield self.master.stopService()

    @defer.inlineCallbacks
    def test_secret_rendered(self):
        yield self.srvtest.configureService()
        new = FakeServiceUsingSecrets(foo=Secret("foo"), other=Secret("other"))
        yield self.srvtest.reconfigServiceWithSibling(new)
        self.assertEqual("bar", self.srvtest.returnRenderedSecrets("foo"))

    @defer.inlineCallbacks
    def test_secret_rendered_not_found(self):
        new = FakeServiceUsingSecrets(foo=Secret("foo"))
        yield self.srvtest.reconfigServiceWithSibling(new)
        self.assertRaises(Exception, self.srvtest.returnRenderedSecrets, "more")
开发者ID:Cray,项目名称:buildbot,代码行数:29,代码来源:test_secret_rendered_service.py

示例2: TestInterpolateSecrets

class TestInterpolateSecrets(unittest.TestCase, ConfigErrorsMixin):

    def setUp(self):
        self.master = fakemaster.make_master()
        fakeStorageService = FakeSecretStorage()
        fakeStorageService.reconfigService(secretdict={"foo": "bar",
                                                       "other": "value"})
        self.secretsrv = SecretManager()
        self.secretsrv.services = [fakeStorageService]
        self.secretsrv.setServiceParent(self.master)
        self.build = FakeBuildWithMaster(self.master)

    @defer.inlineCallbacks
    def test_secret(self):
        command = Interpolate("echo %(secret:foo)s")
        rendered = yield self.build.render(command)
        self.assertEqual(rendered, "echo bar")

    @defer.inlineCallbacks
    def test_secret_not_found(self):
        command = Interpolate("echo %(secret:fuo)s")
        yield self.assertFailure(self.build.render(command), defer.FirstError)
        gc.collect()
        self.flushLoggedErrors(defer.FirstError)
        self.flushLoggedErrors(KeyError)
开发者ID:ewongbb,项目名称:buildbot,代码行数:25,代码来源:test_interpolate_secrets.py

示例3: setUp

    def setUp(self):
        if requests is None:
            raise unittest.SkipTest("Need to install requests to test oauth2")

        self.patch(requests, 'request', mock.Mock(spec=requests.request))
        self.patch(requests, 'post', mock.Mock(spec=requests.post))
        self.patch(requests, 'get', mock.Mock(spec=requests.get))

        self.googleAuth = oauth2.GoogleAuth("ggclientID", "clientSECRET")
        self.githubAuth = oauth2.GitHubAuth("ghclientID", "clientSECRET")
        self.githubAuth_v4 = oauth2.GitHubAuth(
            "ghclientID", "clientSECRET", apiVersion=4)
        self.githubAuth_v4_teams = oauth2.GitHubAuth(
            "ghclientID", "clientSECRET", apiVersion=4, getTeamsMembership=True)
        self.githubAuthEnt = oauth2.GitHubAuth(
            "ghclientID", "clientSECRET", serverURL="https://git.corp.fakecorp.com")
        self.gitlabAuth = oauth2.GitLabAuth(
            "https://gitlab.test/", "glclientID", "clientSECRET")
        self.bitbucketAuth = oauth2.BitbucketAuth("bbclientID", "clientSECRET")

        for auth in [self.googleAuth, self.githubAuth, self.githubAuth_v4, self.githubAuth_v4_teams,
                     self.githubAuthEnt, self.gitlabAuth, self.bitbucketAuth]:
            self._master = master = self.make_master(url='h:/a/b/', auth=auth)
            auth.reconfigAuth(master, master.config)

        self.githubAuth_secret = oauth2.GitHubAuth(
            Secret("client-id"), Secret("client-secret"), apiVersion=4)
        self._master = master = self.make_master(url='h:/a/b/', auth=auth)
        fake_storage_service = FakeSecretStorage()
        fake_storage_service.reconfigService(secretdict={"client-id": "secretClientId",
                                                         "client-secret": "secretClientSecret"})
        secret_service = SecretManager()
        secret_service.services = [fake_storage_service]
        secret_service.setServiceParent(self._master)
        self.githubAuth_secret.reconfigAuth(master, master.config)
开发者ID:ewongbb,项目名称:buildbot,代码行数:35,代码来源:test_www_oauth.py

示例4: testGetNoDataManagerService

 def testGetNoDataManagerService(self):
     secret_service_manager = SecretManager()
     fakeStorageService = FakeSecretStorage()
     fakeStorageService.reconfigService(secretdict={"foo": "bar",
                                                    "other": "value"})
     secret_service_manager.services = [fakeStorageService]
     secret_result = yield secret_service_manager.get("foo2")
     self.assertEqual(secret_result, None)
开发者ID:buildbot,项目名称:buildbot,代码行数:8,代码来源:test_fake_secrets_manager.py

示例5: testGetDataMultipleManagerServiceNoDatas

 def testGetDataMultipleManagerServiceNoDatas(self):
     secret_service_manager = SecretManager()
     self.master.config.secretsProviders = [FakeSecretStorage({"foo": "bar",
                                                              "other": "value"}),
                                            FakeSecretStorage({"foo2": "bar",
                                                              "other2": "value"})
                                            ]
     SecretManager.master = self.master
     secret_result = yield secret_service_manager.get("foo3")
     self.assertEqual(secret_result, None)
开发者ID:zgwmike,项目名称:buildbot,代码行数:10,代码来源:test_fake_secrets_manager.py

示例6: testGetDataMultipleManagerValues

 def testGetDataMultipleManagerValues(self):
     secret_service_manager = SecretManager()
     self.master.config.secretsProviders = [FakeSecretStorage({"foo": "bar",
                                                              "other": ""}),
                                            OtherFakeSecretStorage({"foo2": "bar2", "other": ""})
                                            ]
     SecretManager.master = self.master
     expectedSecretDetail = SecretDetails(FakeSecretStorage.__name__,
                                          "other",
                                          "")
     secret_result = yield secret_service_manager.get("other")
     self.assertEqual(secret_result, expectedSecretDetail)
开发者ID:zgwmike,项目名称:buildbot,代码行数:12,代码来源:test_fake_secrets_manager.py

示例7: testGetManagerService

 def testGetManagerService(self):
     secret_service_manager = SecretManager()
     SecretManager.master = self.master
     expectedClassName = FakeSecretStorage.__name__
     expectedSecretDetail = SecretDetails(expectedClassName, "foo", "bar")
     secret_result = yield secret_service_manager.get("foo")
     strExpectedSecretDetail = str(secret_result)
     self.assertEqual(secret_result, expectedSecretDetail)
     self.assertEqual(secret_result.key, "foo")
     self.assertEqual(secret_result.value, "bar")
     self.assertEqual(secret_result.source, expectedClassName)
     self.assertEqual(strExpectedSecretDetail,
                      "FakeSecretStorage foo: 'bar'")
开发者ID:zgwmike,项目名称:buildbot,代码行数:13,代码来源:test_fake_secrets_manager.py

示例8: testGetDataMultipleManagerValues

    def testGetDataMultipleManagerValues(self):
        secret_service_manager = SecretManager()
        fakeStorageService = FakeSecretStorage()
        fakeStorageService.reconfigService(secretdict={"foo": "bar",
                                                              "other": ""})
        otherFakeStorageService = FakeSecretStorage()
        otherFakeStorageService.reconfigService(secretdict={"foo2": "bar2",
                                                            "other": ""})

        secret_service_manager.services = [fakeStorageService, otherFakeStorageService]
        expectedSecretDetail = SecretDetails(FakeSecretStorage.__name__,
                                             "other",
                                             "")
        secret_result = yield secret_service_manager.get("other")
        self.assertEqual(secret_result, expectedSecretDetail)
开发者ID:buildbot,项目名称:buildbot,代码行数:15,代码来源:test_fake_secrets_manager.py

示例9: setUp

 def setUp(self):
     self.master = fakemaster.make_master()
     self.master.config.secretsProviders = [FakeSecretStorage({"foo": "bar",
                                                              "other": "value"})]
     self.secretsrv = SecretManager()
     self.secretsrv.setServiceParent(self.master)
     self.build = FakeBuildWithMaster(self.master)
开发者ID:zgwmike,项目名称:buildbot,代码行数:7,代码来源:test_interpolate_secrets.py

示例10: testGetManagerService

 def testGetManagerService(self):
     secret_service_manager = SecretManager()
     fakeStorageService = FakeSecretStorage()
     fakeStorageService.reconfigService(secretdict={"foo": "bar",
                                                    "other": "value"})
     secret_service_manager.services = [fakeStorageService]
     expectedClassName = FakeSecretStorage.__name__
     expectedSecretDetail = SecretDetails(expectedClassName, "foo", "bar")
     secret_result = yield secret_service_manager.get("foo")
     strExpectedSecretDetail = str(secret_result)
     self.assertEqual(secret_result, expectedSecretDetail)
     self.assertEqual(secret_result.key, "foo")
     self.assertEqual(secret_result.value, "bar")
     self.assertEqual(secret_result.source, expectedClassName)
     self.assertEqual(strExpectedSecretDetail,
                      "FakeSecretStorage foo: 'bar'")
开发者ID:buildbot,项目名称:buildbot,代码行数:16,代码来源:test_fake_secrets_manager.py

示例11: setUp

 def setUp(self):
     self.master = fakemaster.make_master()
     fakeStorageService = FakeSecretStorage()
     fakeStorageService.reconfigService(secretdict={"foo": "bar",
                                                    "other": "value"})
     self.secretsrv = SecretManager()
     self.secretsrv.services = [fakeStorageService]
     self.secretsrv.setServiceParent(self.master)
     self.build = FakeBuildWithMaster(self.master)
开发者ID:craig5,项目名称:buildbot,代码行数:9,代码来源:test_interpolate_secrets.py

示例12: TestInterpolateSecretsHiddenSecrets

class TestInterpolateSecretsHiddenSecrets(unittest.TestCase):

    def setUp(self):
        self.master = fakemaster.make_master()
        fakeStorageService = FakeSecretStorage()
        fakeStorageService.reconfigService(secretdict={"foo": "bar",
                                                       "other": "value"})
        self.secretsrv = SecretManager()
        self.secretsrv.services = [fakeStorageService]
        self.secretsrv.setServiceParent(self.master)
        self.build = FakeBuildWithMaster(self.master)

    @defer.inlineCallbacks
    def test_secret(self):
        command = Interpolate("echo %(secret:foo)s")
        rendered = yield self.build.render(command)
        cleantext = self.build.build_status.properties.cleanupTextFromSecrets(rendered)
        self.assertEqual(cleantext, "echo <foo>")
开发者ID:ewongbb,项目名称:buildbot,代码行数:18,代码来源:test_interpolate_secrets.py

示例13: setUp

 def setUp(self):
     self.master = fakemaster.make_master()
     fakeStorageService = FakeSecretStorage(secretdict={"foo": "bar",
                                                    "other": "value"})
     self.secretsrv = SecretManager()
     self.secretsrv.services = [fakeStorageService]
     self.secretsrv.setServiceParent(self.master)
     self.srvtest = FakeServiceUsingSecrets()
     self.srvtest.setServiceParent(self.master)
     self.successResultOf(self.master.startService())
开发者ID:Cray,项目名称:buildbot,代码行数:10,代码来源:test_secret_rendered_service.py

示例14: testGetNoDataManagerService

 def testGetNoDataManagerService(self):
     secret_service_manager = SecretManager()
     SecretManager.master = self.master
     secret_result = yield secret_service_manager.get("foo2")
     self.assertEqual(secret_result, None)
开发者ID:zgwmike,项目名称:buildbot,代码行数:5,代码来源:test_fake_secrets_manager.py


注:本文中的buildbot.secrets.manager.SecretManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。