404

[ Avaa Bypassed ]




Upload:

Command:

botdev@3.14.132.221: ~ $
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.

from twisted.cred import credentials, error
from twisted.words import tap
from twisted.trial import unittest



class WordsTapTests(unittest.TestCase):
    """
    Ensures that the twisted.words.tap API works.
    """

    PASSWD_TEXT = b"admin:admin\njoe:foo\n"
    admin = credentials.UsernamePassword(b'admin', b'admin')
    joeWrong = credentials.UsernamePassword(b'joe', b'bar')


    def setUp(self):
        """
        Create a file with two users.
        """
        self.filename = self.mktemp()
        self.file = open(self.filename, 'wb')
        self.file.write(self.PASSWD_TEXT)
        self.file.flush()


    def tearDown(self):
        """
        Close the dummy user database.
        """
        self.file.close()


    def test_hostname(self):
        """
        Tests that the --hostname parameter gets passed to Options.
        """
        opt = tap.Options()
        opt.parseOptions(['--hostname', 'myhost'])
        self.assertEqual(opt['hostname'], 'myhost')


    def test_passwd(self):
        """
        Tests the --passwd command for backwards-compatibility.
        """
        opt = tap.Options()
        opt.parseOptions(['--passwd', self.file.name])
        self._loginTest(opt)


    def test_auth(self):
        """
        Tests that the --auth command generates a checker.
        """
        opt = tap.Options()
        opt.parseOptions(['--auth', 'file:'+self.file.name])
        self._loginTest(opt)


    def _loginTest(self, opt):
        """
        This method executes both positive and negative authentication
        tests against whatever credentials checker has been stored in
        the Options class.

        @param opt: An instance of L{tap.Options}.
        """
        self.assertEqual(len(opt['credCheckers']), 1)
        checker = opt['credCheckers'][0]
        self.assertFailure(checker.requestAvatarId(self.joeWrong),
                           error.UnauthorizedLogin)
        def _gotAvatar(username):
            self.assertEqual(username, self.admin.username)
        return checker.requestAvatarId(self.admin).addCallback(_gotAvatar)

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
__init__.py File 14 B 0644
test_basechat.py File 2.45 KB 0644
test_basesupport.py File 2.99 KB 0644
test_domish.py File 19.7 KB 0644
test_irc.py File 100.97 KB 0644
test_irc_service.py File 9.41 KB 0644
test_ircsupport.py File 10.45 KB 0644
test_jabberclient.py File 16.47 KB 0644
test_jabbercomponent.py File 13.87 KB 0644
test_jabbererror.py File 11.25 KB 0644
test_jabberjid.py File 7.04 KB 0644
test_jabberjstrports.py File 996 B 0644
test_jabbersasl.py File 9.21 KB 0644
test_jabbersaslmechanisms.py File 5.62 KB 0644
test_jabberxmlstream.py File 44.65 KB 0644
test_jabberxmppstringprep.py File 5.42 KB 0644
test_service.py File 27.79 KB 0644
test_tap.py File 2.13 KB 0644
test_xishutil.py File 9.18 KB 0644
test_xmlstream.py File 6.13 KB 0644
test_xmpproutertap.py File 2.34 KB 0644
test_xpath.py File 10.74 KB 0644