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
b812fb1f
Commit
b812fb1f
authored
Mar 23, 2016
by
adam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds basic get test
parent
ca6f5650
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
0 deletions
+62
-0
example_scenario.json
tests/example_scenario.json
+11
-0
main.py
tests/main.py
+45
-0
login_page_up.json
tests/scenarios/login_page_up.json
+6
-0
No files found.
tests/example_scenario.json
0 → 100644
View file @
b812fb1f
{
"name"
:
"Example scenario"
,
"description"
:
"This is an example scenario."
,
"url"
:
"http://google.com/"
,
"method"
:
"GET"
,
"user"
:
{
"login"
:,
"password"
:,
},
"expected_output"
:
{}
}
tests/main.py
0 → 100644
View file @
b812fb1f
import
requests
import
json
import
os
SCENARIOS_PATH
=
"./scenarios/"
;
class
Test
:
def
__init__
(
self
):
self
.
scenarios
=
[]
def
run
(
self
):
for
scenario
in
self
.
scenarios
:
if
scenario
.
get
(
"method"
)
==
"GET"
:
self
.
send_get_request
(
scenario
)
elif
scenario
.
get
(
"method"
)
==
"POST"
:
self
.
send_post_request
else
:
print
"Skipping "
,
scenario
[
"name"
],
" please specify request method."
def
load_test_scenarios
(
self
,
scenarios_path
):
scenario_names
=
[
scenario_file
for
scenario_file
in
os
.
listdir
(
scenarios_path
)
if
scenario_file
.
endswith
(
'.json'
)]
for
scenario_name
in
scenario_names
:
with
open
(
os
.
path
.
join
(
scenarios_path
,
scenario_name
))
as
scenario_file
:
self
.
scenarios
.
append
(
json
.
load
(
scenario_file
))
def
send_get_request
(
self
,
scenario
):
if
scenario
.
get
(
"user"
):
auth
=
(
scenario
[
"user"
][
"login"
],
scenario
[
"user"
][
"password"
])
else
:
auth
=
None
req
=
requests
.
get
(
scenario
[
"url"
],
auth
=
auth
)
if
req
.
status_code
==
200
:
print
"Test "
,
scenario
[
"name"
],
"OK"
def
send_post_request
(
self
,
scenario
):
pass
test
=
Test
()
test
.
load_test_scenarios
(
SCENARIOS_PATH
)
test
.
run
()
tests/scenarios/login_page_up.json
0 → 100644
View file @
b812fb1f
{
"name"
:
"Login_page_up"
,
"description"
:
"Checks if login page is up"
,
"method"
:
"GET"
,
"url"
:
"http://google.com"
}
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