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
2b20a970
Commit
2b20a970
authored
Mar 24, 2016
by
adam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds test for submiting flag
parent
5d812cb4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
1 deletion
+62
-1
check_submiting_flag.py
tests/check_submiting_flag.py
+61
-0
submit_flag.json
tests/scenarios/submit_flag.json
+1
-1
No files found.
tests/check_submiting_flag.py
0 → 100644
View file @
2b20a970
import
requests
USER
=
"rosiu1"
PASSWORD
=
"rosiu321"
VALID_FLAG
=
"3a74741626bd19f32b5fc02e875932ff"
SERVER
=
"localhost:8080"
class
FlagSubmitterTest
:
def
__init__
(
self
):
pass
def
test_submit_flag_and_check_if_is_in_solutions
(
self
):
# get solutions
solutions_url
=
"http://{0}/api/v1/solutions/my"
.
format
(
SERVER
)
try
:
res
=
requests
.
get
(
solutions_url
,
auth
=
(
USER
,
PASSWORD
))
except
Exception
:
print
(
"Check if server is up! Exiting"
)
return
if
res
.
status_code
!=
200
:
print
(
"Got {} status code, something is wrong with the server of configuration. Exiting"
.
format
(
res
.
status_code
)
)
return
solutions_before_submiting
=
res
.
json
()
# send flag request
submit_url
=
"http://{0}/api/v1/solutions/3"
.
format
(
SERVER
)
res
=
requests
.
post
(
submit_url
,
auth
=
(
USER
,
PASSWORD
),
data
=
VALID_FLAG
)
if
res
.
status_code
!=
200
:
print
(
"Got {} status code, are you trying to upload the same flag twice? Exiting"
.
format
(
res
.
status_code
))
return
# get solution v2 and check if there is a additional flag
res
=
requests
.
get
(
solutions_url
,
auth
=
(
USER
,
PASSWORD
))
if
res
.
status_code
!=
200
:
print
(
"Got {} status code, something is wrong with the server of configuration. Exiting"
.
format
(
res
.
status_code
))
return
solutions_after_submiting
=
res
.
json
()
for
task
in
solutions_before_submiting
:
diff
=
set
(
solutions_after_submiting
[
task
])
-
set
(
solutions_before_submiting
[
task
])
if
len
(
diff
)
>=
1
:
print
(
"Test 'Flag submiting' was successful!"
)
return
print
(
"Test 'Flag submiting' failed!"
)
def
run
(
self
):
self
.
test_submit_flag_and_check_if_is_in_solutions
()
test
=
FlagSubmitterTest
()
test
.
run
()
tests/scenarios/submit_flag.json
View file @
2b20a970
{
{
"name"
:
"'Submit flag'"
,
"name"
:
"'Submit flag'"
,
"description"
:
"Submits flag, if test wil be ran 2 times without p
ru
ging database it will fail (one flag cannot be submited more that once)"
,
"description"
:
"Submits flag, if test wil be ran 2 times without p
ur
ging database it will fail (one flag cannot be submited more that once)"
,
"url"
:
"http://localhost:8080/api/v1/solutions/1/"
,
"url"
:
"http://localhost:8080/api/v1/solutions/1/"
,
"method"
:
"POST"
,
"method"
:
"POST"
,
"user"
:
{
"user"
:
{
...
...
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