Revize eff25d7c
Přidáno uživatelem Michal Seják před asi 4 roky(ů)
swagger_server/controllers/certificates_controller.py | ||
---|---|---|
6 | 6 |
from src.services.certificate_service import CertificateService |
7 | 7 |
from src.dao.certificate_repository import CertificateRepository # TODO not the Controller's responsibility. 1 |
8 | 8 |
from src.services.cryptography import CryptographyService # TODO not the Controller's responsibility. 2 |
9 |
from sqlite3 import Connection, Cursor # TODO not the Controller's responsibility. 3 |
|
10 |
from src.constants import DATABASE_FILE, DICT_USAGES, CA_ID # TODO DATABASE_FILE - not the Controller's |
|
9 |
from sqlite3 import Connection # TODO not the Controller's responsibility. 3 |
|
10 |
from src.constants import DICT_USAGES, CA_ID, \ |
|
11 |
DATABASE_FILE_LOCATION # TODO DATABASE_FILE - not the Controller's |
|
11 | 12 |
# responsibility. 4 |
12 | 13 |
from src.services.key_service import KeyService |
13 | 14 |
from swagger_server.models import CertificateRequest |
... | ... | |
23 | 24 |
from swagger_server import util |
24 | 25 |
|
25 | 26 |
|
26 |
_ = Connection("../" + DATABASE_FILE) # TODO not the Controller's responsibility. 5
|
|
27 |
# _ = Connection("../" + DATABASE_FILE) # TODO not the Controller's responsibility. 5
|
|
27 | 28 |
# cursor = _.cursor() # TODO responsibility of the |
28 | 29 |
# CertificateRepository. It makes no sense to |
29 | 30 |
# supply a different cursor than precisely |
... | ... | |
32 | 33 |
# connection instance. |
33 | 34 |
|
34 | 35 |
__ = CryptographyService() # TODO not the Controller's responsibility. 6 |
35 |
CERTIFICATE_SERVICE = CertificateService(__, CertificateRepository(_, _.cursor()))
|
|
36 |
CERTIFICATE_SERVICE = CertificateService(__, CertificateRepository(None, None))
|
|
36 | 37 |
# TODO open for discussion. Expected: |
37 | 38 |
# CS = CertificateService.get_instance() |
38 | 39 |
# or something like that. |
39 | 40 |
|
40 |
KEY_SERVICE = KeyService(__, PrivateKeyRepository(_, _.cursor())) # TODO as above |
|
41 |
KEY_SERVICE = KeyService(__, PrivateKeyRepository(None, None)) # TODO as above |
|
42 |
|
|
41 | 43 |
|
42 | 44 |
|
43 | 45 |
def setup(): |
... | ... | |
45 | 47 |
SQLite3 thread issue hack. |
46 | 48 |
:return: |
47 | 49 |
""" |
48 |
_ = Connection("../" + DATABASE_FILE)
|
|
50 |
_ = Connection(DATABASE_FILE_LOCATION.shortest_relative_path())
|
|
49 | 51 |
CERTIFICATE_SERVICE.certificate_repository.connection = _ |
50 | 52 |
CERTIFICATE_SERVICE.certificate_repository.cursor = _.cursor() |
51 | 53 |
KEY_SERVICE.private_key_repository.connection = _ |
... | ... | |
62 | 64 |
|
63 | 65 |
:rtype: CreatedResponse |
64 | 66 |
""" |
65 |
setup() |
|
67 |
setup() # TODO remove after issue fixed
|
|
66 | 68 |
|
67 | 69 |
if connexion.request.is_json: |
68 | 70 |
body = CertificateRequest.from_dict(connexion.request.get_json()) # noqa: E501 |
... | ... | |
171 | 173 |
|
172 | 174 |
:rtype: CertificateListResponse |
173 | 175 |
""" |
176 |
setup() # TODO remove after issue fixed |
|
177 |
|
|
174 | 178 |
if connexion.request.is_json: |
179 |
return 400 |
|
175 | 180 |
filtering = Filtering.from_dict(connexion.request.get_json()) # noqa: E501 |
176 |
return 'do some magic! XD' |
|
181 |
else: |
|
182 |
return 400 |
|
177 | 183 |
|
178 | 184 |
|
179 | 185 |
def get_certificate_root_by_id(id): # noqa: E501 |
Také k dispozici: Unified diff
Re #8476 - Database FileAnchor utilization.