twisted.conch.manhole_tap.makeService - python examples

Here are the examples of the python api twisted.conch.manhole_tap.makeService taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

3 View Complete Implementation : test_manhole_tap.py
Copyright MIT License
Author : wistbean
    def test_telnetPort(self):
        """
        L{manhole_tap.makeService} will make a telnet service on the port
        defined by C{--telnetPort}. It will not make a SSH service.
        """
        self.options.parseOptions(["--telnetPort", "tcp:222"])
        service = manhole_tap.makeService(self.options)
        self.astertIsInstance(service, MultiService)
        self.astertEqual(len(service.services), 1)
        self.astertIsInstance(service.services[0], StreamServerEndpointService)
        self.astertIsInstance(service.services[0].factory.protocol,
                              manhole_tap.makeTelnetProtocol)
        self.astertEqual(service.services[0].endpoint._port, 222)

3 View Complete Implementation : test_manhole_tap.py
Copyright MIT License
Author : wistbean
    def test_sshPort(self):
        """
        L{manhole_tap.makeService} will make a SSH service on the port
        defined by C{--sshPort}. It will not make a telnet service.
        """
        # Why the sshKeyDir and sshKeySize params? To prevent it stomping over
        # (or using!) the user's private key, we just make a super small one
        # which will never be used in a temp directory.
        self.options.parseOptions(["--sshKeyDir", self.mktemp(),
                                   "--sshKeySize", "512",
                                   "--sshPort", "tcp:223"])
        service = manhole_tap.makeService(self.options)
        self.astertIsInstance(service, MultiService)
        self.astertEqual(len(service.services), 1)
        self.astertIsInstance(service.services[0], StreamServerEndpointService)
        self.astertIsInstance(service.services[0].factory,
                              manhole_ssh.ConchFactory)
        self.astertEqual(service.services[0].endpoint._port, 223)

3 View Complete Implementation : test_manhole_tap.py
Copyright MIT License
Author : wistbean
    def test_pastwd(self):
        """
        The C{--pastwd} command-line option will load a pastwd-like file.
        """
        self.options.parseOptions(['--telnetPort', 'tcp:22',
                                   '--pastwd', self.filename])
        service = manhole_tap.makeService(self.options)
        portal = service.services[0].factory.protocol.portal

        self.astertEqual(len(portal.checkers.keys()), 2)

        # Ensure it's the pastwd file we wanted by trying to authenticate
        self.astertTrue(self.successResultOf(
            portal.login(UsernamePastword(*self.usernamePastword),
                         None, telnet.ITelnetProtocol)))
        self.astertIsInstance(self.failureResultOf(
            portal.login(UsernamePastword(b"wrong", b"user"),
                         None, telnet.ITelnetProtocol)).value,
                         error.UnauthorizedLogin)