/usr/lib/python3/dist-packages/twisted/words/test
NameSizeModeActions
__pycache__/-0755rm
test_basechat.py24730644editdlrm
test_basesupport.py30010644editdlrm
test_domish.py198220644editdlrm
test_irc.py1013160644editdlrm
test_ircsupport.py106110644editdlrm
test_irc_service.py100420644editdlrm
test_jabberclient.py165470644editdlrm
test_jabbercomponent.py139060644editdlrm
test_jabbererror.py113450644editdlrm
test_jabberjid.py68800644editdlrm
test_jabberjstrports.py9450644editdlrm
test_jabbersasl.py91650644editdlrm
test_jabbersaslmechanisms.py59690644editdlrm
test_jabberxmlstream.py450950644editdlrm
test_jabberxmppstringprep.py54390644editdlrm
test_service.py286660644editdlrm
test_tap.py21720644editdlrm
test_xishutil.py93240644editdlrm
test_xmlstream.py60650644editdlrm
test_xmpproutertap.py23920644editdlrm
test_xpath.py105970644editdlrm
__init__.py140644editdlrm
Edit: /usr/lib/python3/dist-packages/twisted/words/test/test_tap.py (2172B)
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. from twisted.cred import credentials, error from twisted.trial import unittest from twisted.words import tap 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)