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


Python strcred.makeChecker函数代码示例

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


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

示例1: test_warnWithBadFilename

 def test_warnWithBadFilename(self):
     """
     When the file auth plugin is given a file that doesn't exist, it
     should produce a warning.
     """
     oldOutput = cred_file.theFileCheckerFactory.errorOutput
     newOutput = StringIO.StringIO()
     cred_file.theFileCheckerFactory.errorOutput = newOutput
     strcred.makeChecker('file:' + self._fakeFilename())
     cred_file.theFileCheckerFactory.errorOutput = oldOutput
     self.assertIn(cred_file.invalidFileWarning, newOutput.getvalue())
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:11,代码来源:test_strcred.py

示例2: get_www

def get_www():
    from buildbot.plugins import util
    from twisted.cred import strcred
    import private

    return dict(
        port = "unix:/home/buildbot/buildbot.sock",
        plugins = dict(
            waterfall_view = {},
            console_view = {},
            grid_view = {},
            badges = {}
        ),
        auth = util.GitHubAuth(
            private.github_client_id,
            private.github_client_secret,
            apiVersion = 4,
            getTeamsMembership = True
        ),
        authz = util.Authz(
            allowRules = [
                util.AnyControlEndpointMatcher(role = "SFML")
            ],
            roleMatchers = [
                util.RolesFromGroups()
            ]
        ),
        change_hook_dialects = {'base': True, 'github' : {}},
        change_hook_auth = [strcred.makeChecker("file:changehook.passwd")]
    )
开发者ID:binary1248,项目名称:SFML-Buildbot,代码行数:30,代码来源:status.py

示例3: setUp

 def setUp(self):
     self.admin = credentials.UsernamePassword('admin', 'asdf')
     self.alice = credentials.UsernamePassword('alice', 'foo')
     self.badPass = credentials.UsernamePassword('alice', 'foobar')
     self.badUser = credentials.UsernamePassword('x', 'yz')
     self.filename = self.mktemp()
     FilePath(self.filename).setContent('admin:asdf\nalice:foo\n')
     self.checker = strcred.makeChecker('file:' + self.filename)
开发者ID:ali-hallaji,项目名称:twisted,代码行数:8,代码来源:test_strcred.py

示例4: test_isChecker

 def test_isChecker(self):
     """
     Verifies that strcred.makeChecker('anonymous') returns an object
     that implements the L{ICredentialsChecker} interface.
     """
     checker = strcred.makeChecker('anonymous')
     self.assertTrue(checkers.ICredentialsChecker.providedBy(checker))
     self.assertIn(credentials.IAnonymous, checker.credentialInterfaces)
开发者ID:ali-hallaji,项目名称:twisted,代码行数:8,代码来源:test_strcred.py

示例5: makeService

    def makeService(self, options):
        with open(options.config, "r") as config_file:
            config = json.load(config_file)

        root = resource.Resource()
        root.putChild('jsMath', static.File(config["global"]["jsmath"]))

        bot = service.MultiService()
        xmppclient = XMPPClient(JID(config["global"]["jid"]),
                                config["global"]["password"])
        xmppclient.logTraffic = options['verbose']
        xmppclient.setServiceParent(bot)
        xmppclient.dbpool = DatabaseRunner(config["global"]["database"])
        xmppclient.rooms = dict()

        xmlrpc_port = config["global"].get("xml-rpc-port", None)
        if xmlrpc_port is not None:
            xmlrpcinterface = XMLRPCInterface(xmppclient)
            rpc = internet.TCPServer(xmlrpc_port, server.Site(xmlrpcinterface))
            rpc.setName('XML-RPC')
            rpc.setServiceParent(bot)

        for muc_config in config["mucs"]:
            room_jid = JID(muc_config["jid"])
            mucbot = KITBot(room_jid, muc_config.get("password", None),
                            config["global"]["logpath"])
            mucbot.setHandlerParent(xmppclient)

            if "xml-rpc-id" in muc_config:
                xmppclient.rooms[muc_config["xml-rpc-id"]] = mucbot

            # Log resource
            portal = Portal(
                LogViewRealm(os.path.join(config["global"]['logpath'],
                                          room_jid.user + '.log')),
                [strcred.makeChecker(muc_config["log-auth"])]
            )
            credential_factory = DigestCredentialFactory('md5', 'Hello Kitty!')
            auth_resource = HTTPAuthSessionWrapper(portal, [credential_factory])
            root.putChild(room_jid.user, auth_resource)

        httpd_log_view = internet.TCPServer(config["global"]["http-port"],
                                            server.Site(root))
        httpd_log_view.setServiceParent(bot)

        # REPL over SSH
        def makeREPLProtocol():
            namespace = dict(bot=xmppclient)
            return insults.ServerProtocol(manhole.ColoredManhole, namespace)
        repl_realm = manhole_ssh.TerminalRealm()
        repl_realm.chainedProtocolFactory = makeREPLProtocol
        repl_checker = checkers.SSHPublicKeyDatabase()
        repl_portal = Portal(repl_realm, [repl_checker])
        repl_factory = manhole_ssh.ConchFactory(repl_portal)
        repl = internet.TCPServer(config["global"]["ssh-port"], repl_factory)
        repl.setServiceParent(bot)

        return bot
开发者ID:lorenzhs,项目名称:kitbot,代码行数:58,代码来源:kitbot_plugin.py

示例6: testAnonymousAccessSucceeds

 def testAnonymousAccessSucceeds(self):
     """
     Test that we can log in anonymously using this checker.
     """
     checker = strcred.makeChecker('anonymous')
     request = checker.requestAvatarId(credentials.Anonymous())
     def _gotAvatar(avatar):
         self.assertIdentical(checkers.ANONYMOUS, avatar)
     return request.addCallback(_gotAvatar)
开发者ID:ali-hallaji,项目名称:twisted,代码行数:9,代码来源:test_strcred.py

示例7: setUp

 def setUp(self):
     self.admin = credentials.UsernamePassword('admin', 'asdf')
     self.alice = credentials.UsernamePassword('alice', 'foo')
     self.badPass = credentials.UsernamePassword('alice', 'foobar')
     self.badUser = credentials.UsernamePassword('x', 'yz')
     self.checker = strcred.makeChecker('unix')
     # Hack around the pwd and spwd modules, since we can't really
     # go about reading your /etc/passwd or /etc/shadow files
     if pwd:
         self._pwd_getpwnam = pwd.getpwnam
         pwd.getpwnam = self._pwd
     if spwd:
         self._spwd_getspnam = spwd.getspnam
         spwd.getspnam = self._spwd
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:14,代码来源:test_strcred.py

示例8: test_setupSiteWithHookAndAuth

    def test_setupSiteWithHookAndAuth(self):
        fn = self.mktemp()
        with open(fn, 'w') as f:
            f.write("user:pass")
        new_config = self.makeConfig(
            port=8080,
            plugins={},
            change_hook_dialects={'base': True},
            change_hook_auth=[strcred.makeChecker("file:" + fn)])
        self.svc.setupSite(new_config)

        yield self.svc.reconfigServiceWithBuildbotConfig(new_config)
        rsrc = self.svc.site.resource.getChildWithDefault('', mock.Mock())

        res = yield self.render_resource(rsrc, '')
        self.assertIn('{"type": "file"}', res)

        rsrc = self.svc.site.resource.getChildWithDefault('change_hook', mock.Mock())
        res = yield self.render_resource(rsrc, '/change_hook/base')
        # as UnauthorizedResource is in private namespace, we cannot use assertIsInstance :-(
        self.assertIn('UnauthorizedResource', repr(res))
开发者ID:dinatale2,项目名称:buildbot,代码行数:21,代码来源:test_www_service.py


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