__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ 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.
#
"""Test SOAP support."""
from unittest import skipIf
from twisted.internet import defer, reactor
from twisted.trial.unittest import TestCase
from twisted.web import error, server
try:
import SOAPpy
from twisted.web import soap
from twisted.web.soap import SOAPPublisher
except ImportError:
SOAPpy = None
SOAPPublisher = object # type: ignore[misc,assignment]
class Test(SOAPPublisher):
def soap_add(self, a, b):
return a + b
def soap_kwargs(self, a=1, b=2):
return a + b
soap_kwargs.useKeywords = True # type: ignore[attr-defined]
def soap_triple(self, string, num):
return [string, num, None]
def soap_struct(self):
return SOAPpy.structType({"a": "c"})
def soap_defer(self, x):
return defer.succeed(x)
def soap_deferFail(self):
return defer.fail(ValueError())
def soap_fail(self):
raise RuntimeError
def soap_deferFault(self):
return defer.fail(ValueError())
def soap_complex(self):
return {"a": ["b", "c", 12, []], "D": "foo"}
def soap_dict(self, map, key):
return map[key]
@skipIf(not SOAPpy, "SOAPpy not installed")
class SOAPTests(TestCase):
def setUp(self):
self.publisher = Test()
self.p = reactor.listenTCP(
0, server.Site(self.publisher), interface="127.0.0.1"
)
self.port = self.p.getHost().port
def tearDown(self):
return self.p.stopListening()
def proxy(self):
return soap.Proxy("http://127.0.0.1:%d/" % self.port)
def testResults(self):
inputOutput = [
("add", (2, 3), 5),
("defer", ("a",), "a"),
("dict", ({"a": 1}, "a"), 1),
("triple", ("a", 1), ["a", 1, None]),
]
dl = []
for meth, args, outp in inputOutput:
d = self.proxy().callRemote(meth, *args)
d.addCallback(self.assertEqual, outp)
dl.append(d)
# SOAPpy kinda blows.
d = self.proxy().callRemote("complex")
d.addCallback(lambda result: result._asdict())
d.addCallback(self.assertEqual, {"a": ["b", "c", 12, []], "D": "foo"})
dl.append(d)
# We now return to our regularly scheduled program,
# already in progress.
return defer.DeferredList(dl, fireOnOneErrback=True)
def testMethodNotFound(self):
"""
Check that a non existing method return error 500.
"""
d = self.proxy().callRemote("doesntexist")
self.assertFailure(d, error.Error)
def cb(err):
self.assertEqual(int(err.status), 500)
d.addCallback(cb)
return d
def testLookupFunction(self):
"""
Test lookupFunction method on publisher, to see available remote
methods.
"""
self.assertTrue(self.publisher.lookupFunction("add"))
self.assertTrue(self.publisher.lookupFunction("fail"))
self.assertFalse(self.publisher.lookupFunction("foobar"))
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| __init__.py | File | 107 B | 0644 |
|
| _util.py | File | 3.26 KB | 0644 |
|
| injectionhelpers.py | File | 5.46 KB | 0644 |
|
| requesthelper.py | File | 15.07 KB | 0644 |
|
| test_agent.py | File | 119.75 KB | 0644 |
|
| test_cgi.py | File | 14.76 KB | 0644 |
|
| test_client.py | File | 1.52 KB | 0644 |
|
| test_distrib.py | File | 17.58 KB | 0644 |
|
| test_domhelpers.py | File | 11.18 KB | 0644 |
|
| test_error.py | File | 16.37 KB | 0644 |
|
| test_flatten.py | File | 25.67 KB | 0644 |
|
| test_html.py | File | 1.21 KB | 0644 |
|
| test_http.py | File | 153.63 KB | 0644 |
|
| test_http2.py | File | 105.17 KB | 0644 |
|
| test_http_headers.py | File | 24.38 KB | 0644 |
|
| test_httpauth.py | File | 23.23 KB | 0644 |
|
| test_newclient.py | File | 106.8 KB | 0644 |
|
| test_pages.py | File | 3.56 KB | 0644 |
|
| test_proxy.py | File | 19.57 KB | 0644 |
|
| test_resource.py | File | 10.37 KB | 0644 |
|
| test_script.py | File | 3.91 KB | 0644 |
|
| test_soap.py | File | 3.04 KB | 0644 |
|
| test_stan.py | File | 7.08 KB | 0644 |
|
| test_static.py | File | 66.6 KB | 0644 |
|
| test_tap.py | File | 11.86 KB | 0644 |
|
| test_template.py | File | 28.38 KB | 0644 |
|
| test_util.py | File | 14.76 KB | 0644 |
|
| test_vhost.py | File | 7.49 KB | 0644 |
|
| test_web.py | File | 67.52 KB | 0644 |
|
| test_web__responses.py | File | 837 B | 0644 |
|
| test_webclient.py | File | 11.52 KB | 0644 |
|
| test_wsgi.py | File | 73.83 KB | 0644 |
|
| test_xml.py | File | 42.28 KB | 0644 |
|
| test_xmlrpc.py | File | 29.85 KB | 0644 |
|