Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
RESPX - Mock HTTPX with awesome request patterns and response side effects.
Full documentation is available at lundberg.github.io/respx
RESPX is a simple, yet powerful, utility for mocking out the HTTPX, and HTTP Core, libraries.
Start by patching HTTPX
, using
respx.mock
, then add request
routes to mock
responses.
import httpx
import respx
from httpx import Response
@respx.mock
def test_example():
my_route = respx.get("https://example.org/").mock(return_value=Response(204))
response = httpx.get("https://example.org/")
assert my_route.called
assert response.status_code == 204
Read the User Guide for a complete walk-through.
For a neater pytest
experience, RESPX includes a respx_mock
fixture for easy
HTTPX
mocking, along with an optional respx
marker to fine-tune the mock
settings.
import httpx
import pytest
def test_default(respx_mock):
respx_mock.get("https://foo.bar/").mock(return_value=httpx.Response(204))
response = httpx.get("https://foo.bar/")
assert response.status_code == 204
@pytest.mark.respx(base_url="https://foo.bar")
def test_with_marker(respx_mock):
respx_mock.get("/baz/").mock(return_value=httpx.Response(204))
response = httpx.get("https://foo.bar/baz/")
assert response.status_code == 204
Install with pip:
$ pip install respx
Requires Python 3.7+ and HTTPX 0.21+. See Changelog for older HTTPX compatibility.
FAQs
A utility for mocking out the Python HTTPX and HTTP Core libraries.
We found that respx 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.