Skip to content

Commit

Permalink
+signature tests (fix)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
  • Loading branch information
bigcat88 committed Jul 23, 2023
1 parent a2f7029 commit e53a7ea
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions tests/_app_security_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def sign_request(url: str, req_headers: dict, time: int = 0):
assert result.status_code == 401 # Missing headers
headers.update(
{
"AE-VERSION": "1.0.0",
"EX-APP-ID": "nc_py_api",
"EX-APP-VERSION": "1.0.0",
"AE-VERSION": environ.get("AE_VERSION", "1.0.0"),
"EX-APP-ID": environ.get("APP_ID", "nc_py_api"),
"EX-APP-VERSION": environ.get("APP_VERSION", "1.0.0"),
}
)
sign_request("/sec_check?value=1", headers)
Expand All @@ -56,16 +56,8 @@ def sign_request(url: str, req_headers: dict, time: int = 0):
result = requests.put(request_url, headers=headers)
assert result.status_code == 200
# Invalid AE-DATA-HASH
_ = xxh64()
_.update(b"some_data")
headers["AE-DATA-HASH"] = _.hexdigest()
result = requests.put(request_url, headers=headers)
result = requests.put(request_url, headers=headers, data=b"some_data")
assert result.status_code == 401
_ = xxh64()
_.update(b"")
headers["AE-DATA-HASH"] = _.hexdigest()
result = requests.put(request_url, headers=headers)
assert result.status_code == 200
# Sign time
sign_request("/sec_check?value=0", headers, time=int(datetime.now(timezone.utc).timestamp()))
result = requests.put(request_url, headers=headers)
Expand Down

0 comments on commit e53a7ea

Please sign in to comment.