Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IDS PSE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Daniel Yang
IDS PSE
Commits
3ef4d87b
Commit
3ef4d87b
authored
4 months ago
by
Daniel Yang
Browse files
Options
Downloads
Patches
Plain Diff
Added syn_flooding_detection test, do not know how to send 101 packets in 10 seconds tho
parent
5aa79a10
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
code/test/test_packet_capturing.py
+5
-3
5 additions, 3 deletions
code/test/test_packet_capturing.py
with
5 additions
and
3 deletions
code/test/test_packet_capturing.py
+
5
−
3
View file @
3ef4d87b
...
...
@@ -10,6 +10,7 @@ from src.packet_capturing import packet_handler, get_dict, dict_clear, syn_flood
class
TestPacketCapturing
(
unittest
.
TestCase
):
# This method is called before every test
def
setUp
(
self
):
dict_clear
()
...
...
@@ -66,16 +67,17 @@ class TestPacketCapturing(unittest.TestCase):
mock_print
.
assert_any_call
(
"
Illegal packet with source or destination port 0.
"
)
def
test_syn_flood_detection
(
self
):
repetitions
=
150
packet
=
(
IP
(
src
=
"
100.84.6.141
"
,
dst
=
"
192.168.1.1
"
)
/
TCP
(
dport
=
80
,
sport
=
123
,
flags
=
"
S
"
)
/
Ether
(
src
=
"
00:11:22:33:44:55
"
,
dst
=
"
ff:ff:ff:ff:ff:ff
"
))
with
patch
(
'
builtins.print
'
)
as
mock_print
:
for
i
in
range
(
101
):
for
i
in
range
(
repetitions
):
syn_flood_detection
(
packet
)
mock_print
.
assert_called
()
self
.
assertEqual
({
"
100.84.6.141
"
:
repetitions
},
get_dict
(),
f
"
Expected the packet
'
s IP to contain
{
repetitions
}
entries.
"
)
if
__name__
==
'
__main__
'
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
Daniel Yang
@ugmom
·
4 months ago
Owner
Either the syn_flood_detection does not work, or my test sucks.
Either the syn_flood_detection does not work, or my test sucks.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment