Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
CTF
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grzegorz
CTF
Commits
f11fca4f
Commit
f11fca4f
authored
Mar 23, 2016
by
adam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working prototype
parent
ab44e677
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
5 deletions
+29
-5
example_scenario.json
tests/example_scenario.json
+1
-0
main.py
tests/main.py
+27
-4
login_page_up.json
tests/scenarios/login_page_up.json
+1
-1
No files found.
tests/example_scenario.json
View file @
f11fca4f
...
@@ -7,5 +7,6 @@
...
@@ -7,5 +7,6 @@
"login"
:,
"login"
:,
"password"
:,
"password"
:,
},
},
"payload"
:
{},
"expected_output"
:
{}
"expected_output"
:
{}
}
}
tests/main.py
View file @
f11fca4f
...
@@ -30,13 +30,36 @@ class Test:
...
@@ -30,13 +30,36 @@ class Test:
else
:
else
:
auth
=
None
auth
=
None
req
=
requests
.
get
(
scenario
[
"url"
],
auth
=
auth
)
try
:
res
=
requests
.
get
(
scenario
[
"url"
],
auth
=
auth
)
except
Exception
:
print
"Test {0} failed!"
.
format
(
scenario
[
"name"
])
return
if
req
.
status_code
==
200
:
if
res
.
status_code
==
200
:
print
"Test "
,
scenario
[
"name"
],
"OK"
if
scenario
.
get
(
"expected_output"
):
if
scenario
.
get
(
"expected_output"
)
==
res
.
json
():
print
"Test {0} OK!"
.
format
(
scenario
[
"name"
])
return
print
"Test {0}, expected {1} but got {2}!"
.
format
(
scenario
[
"name"
],
scenario
[
"expected_output"
],
res
.
json
())
def
send_post_request
(
self
,
scenario
):
def
send_post_request
(
self
,
scenario
):
pass
if
scenario
.
get
(
"user"
):
auth
=
(
scenario
[
"user"
][
"login"
],
scenario
[
"user"
][
"password"
])
else
:
auth
=
None
res
=
requests
.
path
(
scenario
[
"url"
],
auth
=
auth
,
data
=
scenario
.
get
(
"payload"
))
if
res
.
status_code
==
200
:
if
scenario
.
get
(
"expected_output"
):
if
scenario
.
get
(
"expected_output"
)
==
res
.
json
():
print
"Test {0} OK!"
.
format
(
scenario
[
"name"
])
return
print
"Test {0}, expected {1} but got {2}!"
.
format
(
scenario
[
"name"
],
scenario
[
"expected_output"
],
res
.
json
())
print
"Test {0} failed!"
.
format
(
scenario
[
"name"
])
test
=
Test
()
test
=
Test
()
...
...
tests/scenarios/login_page_up.json
View file @
f11fca4f
...
@@ -2,5 +2,5 @@
...
@@ -2,5 +2,5 @@
"name"
:
"Login_page_up"
,
"name"
:
"Login_page_up"
,
"description"
:
"Checks if login page is up"
,
"description"
:
"Checks if login page is up"
,
"method"
:
"GET"
,
"method"
:
"GET"
,
"url"
:
"http://
google.com
"
"url"
:
"http://
localhost:8080/
"
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment