Commit c601126c authored by Vojtech Myslivec's avatar Vojtech Myslivec 🚀

tests: Add test for old request

parent 3205cdda
Pipeline #59483 passed with stages
in 2 minutes and 11 seconds
......@@ -3,10 +3,11 @@ Test CA raction to errors end bad requests
"""
import json
import time
import pytest
from sentinel_ca.__main__ import process
from sentinel_ca.__main__ import process, VALID_REQUEST_THRESHOLD
from sentinel_ca.exceptions import CAError
from ...helpers import dict_to_bytes, bytes_to_dict
......@@ -30,6 +31,25 @@ def test_process_cacert_expire_soon(redis_mock, good_socket_mock, ca_expire_soon
assert not ca_expire_soon.get_valid_cert_matching_csr(req["sn"], csr)
def test_process_old_timestamp(redis_mock, good_socket_mock, ca, good_request):
# prepare env
req = good_request
req["ts"] = int(time.time()) - VALID_REQUEST_THRESHOLD - 1
redis_mock.brpop.return_value = (1, dict_to_bytes(req))
# test
process(redis_mock, good_socket_mock, ca)
# Check SN interaction
assert not good_socket_mock.send_multipart.called
# Check redis interaction
assert redis_mock.set.call_count == 1
# auth_state
auth_state = bytes_to_dict(redis_mock.set.call_args_list[0][0][1])
assert auth_state["status"] == "error"
def test_process_bad_request_invalid_csr(redis_mock, good_socket_mock, ca, bad_request_invalid_csr):
# prepare env
req = bad_request_invalid_csr
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment