
Security News
Static vs. Runtime Reachability: Insights from Latio’s On the Record Podcast
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
An extension of WebTest with useful extras, including requests-style authentication.
.. image:: https://badge.fury.io/py/webtest-plus.png :target: http://badge.fury.io/py/webtest-plus
.. image:: https://travis-ci.org/sloria/webtest-plus.png?branch=master :target: https://travis-ci.org/sloria/webtest-plus
An extension of WebTest <http://webtest.pythonpaste.org/en/latest/>
_ with useful extras, including requests <http://docs.python-requests.org/en/latest/>
_-style authentication.
.. code-block:: bash
$ pip install -U webtest-plus
.. code-block:: python
import unittest
from myapp import app
from webtest_plus import TestApp
class TestMyApp(unittest.TestCase):
def setUp(self):
self.app = TestApp(app)
def test_protected_endpoint(self):
response = self.app.get("/secret/", expect_errors=True)
assert response.status_code == 401
# Requests-style authentication
response = self.app.get("/secret/", auth=("admin", "passw0rd"))
assert response.status_code == 200
def test_more_secrets(self):
# Another way to authenticate
self.app.authenticate(username="admin", password="passw0rd")
assert self.app.get("/secret/").status_code == 200
self.app.deauthenticate()
assert self.app.get("/secret/", expect_errors=True).status_code == 401
def test_posting_json(self):
# Testing json requests and responses
response = self.app.post_json("/postsecret/", {"secret": "myprecious"},
auth=("admin", "passw0rd"))
assert response.request.content_type == "application/json"
def test_clicking(self):
response = self.app.get("/")
response = response.click("Protected link", auth=("admin", "passw0rd"))
assert response.status_code == 200
def test_token_auth(self):
response = self.app.get('/secret-requires-token/', expect_errors=True)
assert response.status_code == 401
# Authenticate with JWT
response = self.app.get('/secret-requires-token',
auth='yourlongtokenhere', auth_type='jwt')
assert response.status_code == 200
JSON Web Token <https://openid.net/specs/draft-jones-json-web-token-07.html>
_ authenticationMIT licensed. See the bundled LICENSE <https://github.com/sloria/webtest-plus/blob/master/LICENSE>
_ file for more details.
1.0.0 (2017-05-17) ++++++++++++++++++
auth
(#3). Thanks @biern for the catch and patch.0.3.3 (2015-03-17) ++++++++++++++++++
TestApp.head
.0.3.2 (2014-06-04) ++++++++++++++++++
UnboundLocalError
.0.3.1 (2014-05-31) ++++++++++++++++++
0.3.0 (2014-05-31) ++++++++++++++++++
0.2.1 (2013-11-24) ++++++++++++++++++
TestResponse.click
and TestResponse.clickbutton
.0.2.0 (2013-10-15) ++++++++++++++++++
app.post_json
, etc.)0.1.0 (2013-10-06) ++++++++++++++++++
FAQs
An extension of WebTest with useful extras, including requests-style authentication.
We found that webtest-plus demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.