Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Łukasz Nowak
slapos.toolbox
Commits
efcc40ee
Commit
efcc40ee
authored
Feb 23, 2023
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check_surykatka_json: flake8ize
parent
6b4f9dfb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
14 deletions
+21
-14
slapos/promise/plugin/check_surykatka_json.py
slapos/promise/plugin/check_surykatka_json.py
+1
-3
slapos/test/promise/plugin/test_check_surykatka_json.py
slapos/test/promise/plugin/test_check_surykatka_json.py
+20
-11
No files found.
slapos/promise/plugin/check_surykatka_json.py
View file @
efcc40ee
...
...
@@ -71,7 +71,6 @@ class RunPromise(GenericPromise):
return
timetuple
=
email
.
utils
.
parsedate
(
bot_status
[
'date'
])
last_bot_datetime
=
datetime
.
datetime
.
fromtimestamp
(
time
.
mktime
(
timetuple
))
last_bot_datetime_string
=
email
.
utils
.
formatdate
(
time
.
mktime
(
timetuple
))
delta
=
self
.
utcnow
-
last_bot_datetime
# sanity check
if
delta
<
datetime
.
timedelta
(
minutes
=
0
):
...
...
@@ -181,8 +180,7 @@ class RunPromise(GenericPromise):
appendError
(
'HTTP Header dict was %s instead of %s'
%
(
json
.
dumps
(
entry
[
'http_header_dict'
],
sort_keys
=
True
),
json
.
dumps
(
http_header_dict
,
sort_keys
=
True
),
))
json
.
dumps
(
http_header_dict
,
sort_keys
=
True
),))
error
=
True
db_ip_list
=
[
q
[
'ip'
]
for
q
in
entry_list
]
if
len
(
ip_list
):
...
...
slapos/test/promise/plugin/test_check_surykatka_json.py
View file @
efcc40ee
...
...
@@ -512,8 +512,8 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
self
.
launcher
.
run
()
self
.
assertPassedMessage
(
self
.
getPromiseResult
(
self
.
promise_name
),
"http://www.erp5.com/ : http_query: OK with status code 302 on IPs
127.0.0.1
"
"127.0.0.2"
"http://www.erp5.com/ : http_query: OK with status code 302 on IPs "
"127.0.0.
1 127.0.0.
2"
)
def
test_http_with_header_dict
(
self
):
...
...
@@ -523,16 +523,19 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'json-file'
:
self
.
json_file
,
'url'
:
'http://www.erp5.com/'
,
'status-code'
:
'200'
,
'http-header-dict'
:
'{"Vary": "Accept-Encoding", "Cache-Control": "max-age=300, public"}'
,
'http-header-dict'
:
'{"Vary": "Accept-Encoding", "Cache-Control": '
'"max-age=300, public"}'
,
'test-utcnow'
:
'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self
.
writeSurykatkaJson
(
"""{
self
.
writeSurykatkaJson
(
"""{
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
"ip": "176.31.129.213",
"http_header_dict": {"Vary": "Accept-Encoding", "Cache-Control": "max-age=300, public"},
"http_header_dict": {"Vary": "Accept-Encoding", """
""""Cache-Control": "max-age=300, public"},
"status_code": 200,
"url": "http://www.erp5.com/"
}
...
...
@@ -546,7 +549,8 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
self
.
assertPassedMessage
(
self
.
getPromiseResult
(
self
.
promise_name
),
"http://www.erp5.com/ : http_query: OK with status code 200 "
"and HTTP Header dict {
\
"
Cache-Control
\
"
:
\
"
max-age=300, public
\
"
,
\
"
Vary
\
"
:
\
"
Accept-Encoding
\
"
}"
"and HTTP Header dict {
\
"
Cache-Control
\
"
:
\
"
max-age=300, public
\
"
, "
"
\
"
Vary
\
"
:
\
"
Accept-Encoding
\
"
}"
)
def
test_http_with_bad_header_dict
(
self
):
...
...
@@ -556,16 +560,19 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'json-file'
:
self
.
json_file
,
'url'
:
'http://www.erp5.com/'
,
'status-code'
:
'200'
,
'http-header-dict'
:
'{"Vary": "Accept-Encoding", "Cache-Control": "max-age=300, public"}'
,
'http-header-dict'
:
'{"Vary": "Accept-Encoding", "Cache-Control": '
'"max-age=300, public"}'
,
'test-utcnow'
:
'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self
.
writeSurykatkaJson
(
"""{
self
.
writeSurykatkaJson
(
"""{
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
"ip": "176.31.129.213",
"http_header_dict": {"Vary": "Accept-Encoding,Cookie", "Cache-Control": "max-age=300, public"},
"http_header_dict": {"Vary": "Accept-Encoding,Cookie", """
""""Cache-Control": "max-age=300, public"},
"status_code": 200,
"url": "http://www.erp5.com/"
}
...
...
@@ -580,8 +587,10 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
self
.
assertFailedMessage
(
self
.
getPromiseResult
(
self
.
promise_name
),
"http://www.erp5.com/ : http_query: ERROR HTTP Header dict was "
"{
\
"
Cache-Control
\
"
:
\
"
max-age=300, public
\
"
,
\
"
Vary
\
"
:
\
"
Accept-Encoding,Cookie
\
"
} "
"instead of {
\
"
Cache-Control
\
"
:
\
"
max-age=300, public
\
"
,
\
"
Vary
\
"
:
\
"
Accept-Encoding
\
"
}"
"{
\
"
Cache-Control
\
"
:
\
"
max-age=300, public
\
"
,
\
"
Vary
\
"
: "
"
\
"
Accept-Encoding,Cookie
\
"
} "
"instead of {
\
"
Cache-Control
\
"
:
\
"
max-age=300, public
\
"
,
\
"
Vary
\
"
: "
"
\
"
Accept-Encoding
\
"
}"
)
def
test_no_ip_list
(
self
):
...
...
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