Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@loopback/http-caching-proxy
Advanced tools
A caching HTTP proxy for integration tests. NOT SUITABLE FOR PRODUCTION USE!
A caching HTTP proxy for integration tests.
NOT SUITABLE FOR PRODUCTION USE!
Testing applications connecting to backend REST/SOAP services can be difficult: The backend service may be slow, apply rate limiting, etc. Integration tests become too slow in such case, which makes test-first development impractical.
This can be addressed by setting up a snapshot-based mock server or using a caching HTTP client, but both of these solutions come with severe disadvantages:
When using a snapshot-based mock server, we must ensure that snapshots are up-to-date with the actual backend implementation.
Caching at HTTP-client side requires non-trivial changes of the application code.
A filesystem-backed caching HTTP proxy offers a neat solution that combines caching and snapshots:
npm install --save-dev @loopback/http-caching-proxy
Import the module at the top of your test file.
import {HttpCachingProxy} from '@loopback/http-caching-proxy';
Create a proxy instance during test-suite setup (typically in Mocha's before
hook):
const proxy = new HttpCachingProxy({
// directory where to store recorded snapshots - required
cachePath: path.resolve(__dirname, '.proxy-cache'),
// port where to listen - 0 by default
port: 0,
// how often to re-validate snapshots (in milliseconds) - one day by default
ttl: 24 * 60 * 60 * 1000,
});
await proxy.start();
In your tests, configure the client library to use the caching proxy. Below is an example configuration for request:
request = request.defaults({
proxy: proxy.url,
// Disable tunneling of HTTPS requests - this is required for HTTPS!
tunnel: false,
});
Finally, stop the proxy when the test suite is done (typically in Mocha's
after
hook):
await proxy.stop();
See the auto-generated documentation at loopback.io
Run npm test
from the root folder.
See all contributors.
MIT
FAQs
A caching HTTP proxy for integration tests. NOT SUITABLE FOR PRODUCTION USE!
The npm package @loopback/http-caching-proxy receives a total of 277 weekly downloads. As such, @loopback/http-caching-proxy popularity was classified as not popular.
We found that @loopback/http-caching-proxy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.