__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
from __future__ import annotations
from twisted.cred import credentials, error
from twisted.cred.checkers import FilePasswordDB
from twisted.internet import defer
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) -> None:
"""
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) -> None:
"""
Close the dummy user database.
"""
self.file.close()
def test_hostname(self) -> None:
"""
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) -> None:
"""
Tests the --passwd command for backwards-compatibility.
"""
opt = tap.Options()
opt.parseOptions(["--passwd", self.file.name])
self._loginTest(opt)
def test_auth(self) -> None:
"""
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: tap.Options) -> defer.Deferred[None]:
"""
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: FilePasswordDB = opt["credCheckers"][0]
self.assertFailure(
checker.requestAvatarId(self.joeWrong), error.UnauthorizedLogin
)
def _gotAvatar(username: bytes | tuple[()]) -> None:
self.assertEqual(username, self.admin.username)
return checker.requestAvatarId(self.admin).addCallback(_gotAvatar)
| 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.93 KB | 0644 |
|
| test_domish.py | File | 18.94 KB | 0644 |
|
| test_irc.py | File | 103.25 KB | 0644 |
|
| test_irc_service.py | File | 9.81 KB | 0644 |
|
| test_ircsupport.py | File | 10.48 KB | 0644 |
|
| test_jabberclient.py | File | 16.16 KB | 0644 |
|
| test_jabbercomponent.py | File | 13.58 KB | 0644 |
|
| test_jabbererror.py | File | 11.26 KB | 0644 |
|
| test_jabberjid.py | File | 6.91 KB | 0644 |
|
| test_jabberjstrports.py | File | 945 B | 0644 |
|
| test_jabbersasl.py | File | 8.95 KB | 0644 |
|
| test_jabbersaslmechanisms.py | File | 5.92 KB | 0644 |
|
| test_jabberxmlstream.py | File | 44.04 KB | 0644 |
|
| test_jabberxmppstringprep.py | File | 5.36 KB | 0644 |
|
| test_service.py | File | 27.99 KB | 0644 |
|
| test_tap.py | File | 2.36 KB | 0644 |
|
| test_xishutil.py | File | 9.11 KB | 0644 |
|
| test_xmlstream.py | File | 5.92 KB | 0644 |
|
| test_xmpproutertap.py | File | 2.39 KB | 0644 |
|
| test_xpath.py | File | 10.56 KB | 0644 |
|