-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// intrusionDetection.test.js | ||
|
||
import IntrusionDetection from './intrusionDetection'; // Import the module to be tested | ||
|
||
describe('IntrusionDetection', () => { | ||
let intrusionDetection; | ||
|
||
beforeEach(() => { | ||
intrusionDetection = new IntrusionDetection(); | ||
}); | ||
|
||
test('should detect an intrusion attempt', () => { | ||
const result = intrusionDetection.detectIntrusion({ type: 'brute_force', source: '192.168.1.1' }); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
test('should not detect normal traffic as intrusion', () => { | ||
const result = intrusionDetection.detectIntrusion({ type: 'normal', source: '192.168.1.1' }); | ||
expect(result).toBe(false); | ||
}); | ||
|
||
test('should log intrusion attempts', () => { | ||
intrusionDetection.detectIntrusion({ type: 'brute_force', source: '192.168.1.1' }); | ||
const logs = intrusionDetection.getLogs(); | ||
expect(logs).toHaveLength(1); | ||
expect(logs[0]).toMatchObject({ type: 'brute_force', source: '192.168.1.1' }); | ||
}); | ||
}); |