-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/feat/crl'
- Loading branch information
Showing
4 changed files
with
99 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
from tests.setup import run_all | ||
|
||
|
||
def pytest_sessionstart(session): | ||
pass | ||
run_all() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from . import service | ||
import pook | ||
|
||
|
||
@pook.on | ||
def run_all(): | ||
service.run_setup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import pook | ||
from tests.service.utils import open_json | ||
from verificac19 import service | ||
from verificac19.service._settings import ( | ||
DSC_URL, | ||
STATUS_URL, | ||
SETTINGS_URL, | ||
CHECK_CRL_URL, | ||
DOWNLOAD_CRL_URL, | ||
) | ||
|
||
|
||
def _setup_mock_for_settings(): | ||
settings_data = open_json("settings.json") | ||
pook.get(SETTINGS_URL, reply=200, response_json=settings_data) | ||
|
||
|
||
def _setup_mock_for_dsc_certificates(): | ||
FINISHED = "finished" | ||
pook.get(STATUS_URL, reply=200, response_json=open_json("dsc_whitelist.json")) | ||
dsc_validation: list = open_json("dsc_validation.json") | ||
dsc_validation.append(FINISHED) | ||
for index, dsc in enumerate(dsc_validation): | ||
kwargs = {} | ||
headers = {"content-type": "text/plain"} | ||
kwargs["reply"] = 200 | ||
if 0 < index: | ||
headers["X-RESUME-TOKEN"] = str(index) | ||
kwargs["headers"] = headers | ||
if dsc == FINISHED: | ||
kwargs["reply"] = 204 | ||
pook.get(DSC_URL, **kwargs) | ||
continue | ||
|
||
kwargs["response_body"] = dsc["raw_data"] | ||
kwargs["response_headers"] = { | ||
"X-KID": dsc["kid"], | ||
"X-RESUME-TOKEN": str(index + 1), | ||
} | ||
pook.get(DSC_URL, **kwargs) | ||
|
||
|
||
def _setup_mock_for_crl(): | ||
pook.get(CHECK_CRL_URL, reply=200, response_json=open_json("CRL-check-v1.json")) | ||
pook.get( | ||
f"{DOWNLOAD_CRL_URL}?chunk=1", | ||
reply=200, | ||
response_json=open_json("CRL-v1-c1.json"), | ||
) | ||
pook.get( | ||
f"{DOWNLOAD_CRL_URL}?chunk=2", | ||
reply=200, | ||
response_json=open_json("CRL-v1-c2.json"), | ||
) | ||
|
||
|
||
def run_setup(): | ||
_setup_mock_for_settings() | ||
_setup_mock_for_dsc_certificates() | ||
_setup_mock_for_crl() | ||
service.clear_all_cache() | ||
service.update_all() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters