1.0.0 • Published 9 months ago
test-my-server v1.0.0
TestMyServer
TestMyServer testing library for Node.js applications. It provides a set of tools to test your application for common vulnerabilities, including stress testing, XSS injection, and data encryption..
Installation
npm install test-my-server
Usage
- With Express.js example
const express = require('express');
const { VulnProbe, StressTest, XSSInjectionTest, DataEncryptionTest } = require('vulnprobe');
const app = express();
const port = 3000;
app.get('/', (req, res) => {
res.send('Hello World!');
});
app.listen(port, () => {
console.log(`Server running at http://localhost:${port}`);
// Run vulnerability tests
const probe = new VulnProbe();
probe.registerTest('stress', () => StressTest.test(`http://localhost:${port}`, 10, 5000));
probe.registerTest('xss', () => XSSInjectionTest.test(`http://localhost:${port}/submit`));
probe.registerTest('encryption', () => DataEncryptionTest.test(`http://localhost:${port}`));
probe.runAllTests().then((results) => {
for (const [name, result] of results) {
console.log(`${name}: ${result.passed ? 'PASSED' : 'FAILED'} - ${result.message}`);
}
});
});
- With Fastify example
const fastify = require('fastify')({ logger: true });
const { VulnProbe, StressTest, XSSInjectionTest, DataEncryptionTest } = require('vulnprobe');
fastify.get('/', async (request, reply) => {
return { hello: 'world' };
});
const start = async () => {
try {
await fastify.listen(3000);
// Run vulnerability tests
const probe = new VulnProbe();
probe.registerTest('stress', () => StressTest.test('http://localhost:3000', 10, 5000));
probe.registerTest('xss', () => XSSInjectionTest.test('http://localhost:3000/submit'));
probe.registerTest('encryption', () => DataEncryptionTest.test('http://localhost:3000'));
const results = await probe.runAllTests();
for (const [name, result] of results) {
console.log(`${name}: ${result.passed ? 'PASSED' : 'FAILED'} - ${result.message}`);
}
} catch (err) {
fastify.log.error(err);
process.exit(1);
}
};
start();
💻 Built with
Technologies used in the project:
- Typescript
APIand Features
VulnProbe
registerTest(name: string, testFn: TestFunction): void
: Register a new testrunAllTests(): Promise<Map<string, TestResult>>
: Run all registered testsrunTest(name: string): Promise<TestResult | null>
: Run a specific test
StressTest
static test(url: string, concurrency: number, duration: number): Promise<TestResult>
: Run a stress test
XSSInjectionTest
static test(url: string): Promise<TestResult>
: Run an XSS injection test
DataEncryptionTest
static test(url: string): Promise<TestResult>
: Run a data encryption test
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
💻 Technologies used in the project:
🛡️ License:
MIT
1.0.0
9 months ago