feat(detector): Enhance port detection and service fingerprinting with improved HTTP/HTTPS and SSH checks, update test scripts for verbose output, and revise documentation with new hints and a detailed improvement plan.
This commit is contained in:
30
test/test.ts
30
test/test.ts
@@ -10,12 +10,36 @@ tap.test('first test', async () => {
|
||||
|
||||
tap.test('should detect an closed port on a local domain', async () => {
|
||||
const result = await testDetector.isActive('http://localhost:3008');
|
||||
expect(result).toBeFalse();
|
||||
expect(result.isActive).toBeFalse();
|
||||
});
|
||||
|
||||
tap.test('should detect an open port on a remote domain', async () => {
|
||||
const result = await testDetector.isActive('https://lossless.com');
|
||||
expect(result).toBeTrue();
|
||||
expect(result.isActive).toBeTrue();
|
||||
});
|
||||
|
||||
tap.start();
|
||||
tap.test('should detect service type for HTTP', async () => {
|
||||
const result = await testDetector.isActive('http://example.com', { detectServiceType: true });
|
||||
expect(result.isActive).toBeTrue();
|
||||
expect(result.serviceType).toEqual(detector.ServiceType.HTTP);
|
||||
});
|
||||
|
||||
tap.test('should detect service type for HTTPS', async () => {
|
||||
const result = await testDetector.isActive('https://example.com', { detectServiceType: true });
|
||||
expect(result.isActive).toBeTrue();
|
||||
expect(result.serviceType).toEqual(detector.ServiceType.HTTPS);
|
||||
});
|
||||
|
||||
tap.test('should detect SSH service', async () => {
|
||||
const sshType = await testDetector.detectType('ssh://github.com:22');
|
||||
expect(sshType).toEqual(detector.ServiceType.SSH);
|
||||
});
|
||||
|
||||
tap.test('should return unknown for non-standard services', async () => {
|
||||
const result = await testDetector.isActive('http://localhost:9999', { detectServiceType: true });
|
||||
if (result.isActive) {
|
||||
expect(result.serviceType).toEqual(detector.ServiceType.UNKNOWN);
|
||||
}
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
|
||||
Reference in New Issue
Block a user