Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FoD
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
David Schmitz
FoD
Commits
f9d15e58
Commit
f9d15e58
authored
3 years ago
by
David Schmitz
Browse files
Options
Downloads
Patches
Plain Diff
more complex REST API testing
parent
457f5d36
Branches
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
flowspec/test_viewsets.py
+41
-12
41 additions, 12 deletions
flowspec/test_viewsets.py
with
41 additions
and
12 deletions
flowspec/test_viewsets.py
+
41
−
12
View file @
f9d15e58
...
...
@@ -7,7 +7,7 @@ from accounts.models import *
from
rest_framework.authtoken.models
import
Token
import
requests
from
time
import
sleep
#
import
list
@pytest.fixture
def
test_settings
(
settings
):
...
...
@@ -407,7 +407,32 @@ class TestRouteOuter:
assert
response
.
status_code
==
202
print
(
"
rule
"
+
str
(
route_id
)
+
"
deleted
"
)
def
test_add_outer
(
self
):
def
test_add_outer_single
(
self
):
ip1
=
"
10.0.0.1/32
"
#
endpoint_base
=
'
http://localhost:8000/api/routes/
'
print
(
"
endpoint_base=
"
+
str
(
endpoint_base
))
fod_api_headers
=
self
.
get_headers
()
comments
=
"
test route
"
protocol
=
[
"
tcp
"
]
#then = [ "https://fod.example.com/api/thenactions/3/" ]
#then = [ "discard" ]
then
=
[
"
rate-limit:10000k
"
]
#
route_id1
=
self
.
add_route
(
endpoint_base
,
name
=
"
testrule_1
"
,
comments
=
comments
,
source
=
"
0.0.0.0/0
"
,
sourceport
=
"
1000-2000
"
,
destination
=
ip1
,
destinationport
=
"
3000-4000,5000-6000
"
,
protocol
=
[
"
tcp
"
],
then
=
then
,
status
=
"
INACTIVE
"
)
print
(
"
created route: route_id1=
"
+
str
(
route_id1
))
self
.
delete_route
(
endpoint_base
,
route_id1
)
def
test_add_outer_multi
(
self
):
ip1
=
"
10.0.0.1/32
"
ip2
=
"
10.0.0.2/32
"
...
...
@@ -448,19 +473,23 @@ class TestRouteOuter:
print
(
"
\n
phase 1
"
)
route_id1
=
self
.
add_route
(
endpoint_base
,
name
=
"
testrule_1
"
,
comments
=
comments
,
source
=
"
0.0.0.0/0
"
,
sourceport
=
"
1000-2000
"
,
destination
=
ip1
,
destinationport
=
"
3000-4000,5000-6000
"
,
protocol
=
[
"
tcp
"
],
then
=
then
,
status
=
"
INACTIVE
"
)
print
(
"
created route: route_id1=
"
+
str
(
route_id1
))
self
.
delete_route
(
endpoint_base
,
route_id1
)
#
print
(
"
\n
phase 1a
"
)
data
=
{
"
status
"
:
"
ACTIVE
"
,
}
response
=
requests
.
patch
(
endpoint_base
+
str
(
route_id1
),
headers
=
fod_api_headers
,
data
=
json
.
dumps
(
data
))
print
(
"
response.content
"
+
str
(
response
.
content
))
assert
response
.
status_code
//
100
==
2
resp_data
=
json
.
loads
(
response
.
content
)
print
(
"
get.response.data=
"
+
str
(
resp_data
))
if
True
:
print
(
"
\n
phase 1a
"
)
data
=
{
"
status
"
:
"
ACTIVE
"
,
}
response
=
requests
.
patch
(
endpoint_base
+
str
(
route_id1
)
+
"
/
"
,
headers
=
fod_api_headers
,
data
=
json
.
dumps
(
data
))
print
(
"
response.content
"
+
str
(
response
.
content
))
assert
response
.
status_code
//
100
==
2
resp_data
=
json
.
loads
(
response
.
content
)
print
(
"
get.response.data=
"
+
str
(
resp_data
))
#
self
.
delete_route
(
endpoint_base
,
route_id1
)
#
...
...
This diff is collapsed.
Click to expand it.
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