-
Notifications
You must be signed in to change notification settings - Fork 2
/
conftest.py
184 lines (160 loc) · 8.42 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
import base64
import importlib
from contextlib import contextmanager
from pathlib import Path
import pytest
from django.test import override_settings
import pyasice
import esteid.settings
@pytest.fixture
def signed_doc_dict():
return {
"dataFileInfo": [
{
"contentType": "HASHCODE",
"digestType": "sha256",
"digestValue": "Mmb3rosrMXMY86F4P+Pj0VQEQnpDquhEarJ00RelWXE=",
"filename": "something.pdf",
"id": "something.pdf",
"mimeType": "application/pdf",
"size": 27216,
}
],
"format": "BDOC",
"signature_info": [
{
"confirmation": {
"produced_at": "2016-10-03T11:00:05Z",
"responder_certificate": {
"issuer": "C=EE/O=AS Sertifitseerimiskeskus/CN=TEST of EE Certification Centre Root CA/"
"issuer_serial": "138983222239407220571566848351990841243",
"issuer_country": "EE",
"policies": [
{
"description": "Ainult testimiseks. Only for testing.",
"oid": "1.3.6.1.4.1.10015.3.1.1",
"url": "http://www.sk.ee/ajatempel/",
}
],
"subject": "C=EE/O=AS Sertifitseerimiskeskus/OU=OCSP/CN=TEST of SK OCSP RESPONDER 2011/"
"subject_country": "EE",
"valid_from": "2011-03-07T13:22:45Z",
"valid_to": "2024-09-07T12:22:45Z",
},
"responder_id": "C=EE/O=AS Sertifitseerimiskeskus/OU=OCSP/CN=TEST of SK OCSP RESPONDER 2011/"
},
"id": "S0",
"signature_production_place": None,
"signer": {
"certificate": {
"issuer": "C=EE/O=AS Sertifitseerimiskeskus/CN=TEST of ESTEID-SK 2011/[email protected]",
"issuer_serial": "61232248526689391803484677403602728985",
"issuer_country": "EE",
"policies": [
{
"description": "Ainult testimiseks. Only for testing.",
"oid": "1.3.6.1.4.1.10015.3.3.1",
"url": "http://www.sk.ee/cps/",
}
],
"subject": "C=EE/O=ESTEID (MOBIIL-ID)/OU=digital signature/CN=TESTNUMBER,SEITSMES,14212128025"
"/SN=TESTNUMBER/GN=SEITSMES/serialNumber=14212128025",
"subject_country": "EE",
"valid_from": "2015-04-06T09:45:41Z",
"valid_to": "2016-12-31T21:59:59Z",
},
"full_name": "Seitsmes Testnumber",
"id_code": "14212128025",
},
"signer_role": [{"certified": 0, "role": None}],
"signing_time": "2016-10-03T10:59:54Z",
"status": True,
}
],
"version": "2.1",
}
@pytest.fixture()
def static_random_text():
"""This is the text that was used to generate the signature below"""
return b"Hello SMART-ID"
@pytest.fixture()
def static_signature_algorithm():
return "sha512WithRSAEncryption"
@pytest.fixture()
def static_signature():
return base64.b64decode(
"Ooa9Jf4Wg+SrxaXbxFavk8gL6Bo/DIggk4NUxxzzzR5piVD6fNgNdo2bYXh3gWB9I9veyf3uqGotefvOlR8X7ndPJo"
"yqfUIdftx5GI301XLqJnIYEERFlwRDyEwIVOH149B9feLVEEzr+ArXWa12TyelxvcYv2TgLUjgokFk8j8aimdA4jY+"
"HR/nirvQO7gy8MkzjMoagvxOSAKoRFaOPUP5KT2qIPDC2wwHwShRctdQlWsAyto1G5Pdm82FHK3OYOLQPBNuhz8+CT"
"2iKxZY/Uqi6Xr+Mc1JKHK/IPo9MYUFDW+FvKFixF9efnDuRhOTSpj6scvvr00EQoBCAyZpPzlfd/aQddcVnyGvNxDQ"
"02OkksmdWLgzsYGwBLyJnAjGN1MOl++mXf508/ctkWHgyrJUP8r6PWOMriz1gP8VJPe6h7e0cmvexgoZmLFV9Xev23"
"iNyJ7VG0ovhjC2Bw84qQ6by3WebJzadmFznPbeLdxpwCJVw/aoc2pyASDATjAVWimUt2fJD4VY8f3XQz0bBIUG4TbP"
"wbX7wyDewQOXgU0UAPqKGh/2130f3Y7eV3Sjv2xFxk4ih4RIMoruEQfOK/b92UGg6RsS9+ctHH1LftLZO3HdF8sfDQ"
"hvWDPvbzmFa2gD3RaKR6QguGfauxbtE78ARZiAnrtkcHHOjYc/p0k="
)
@pytest.fixture()
def static_certificate():
"""
The certificate is issued to this subject:
"country": "EE",
"id_code": "11702020200",
"given_name": "HELLO",
"surname": "SMART-ID",
"""
return base64.b64decode(
b"MIIHojCCBYqgAwIBAgIQV054KJa3Z/ZYkvh96o3PtzANBgkqhkiG9w0BAQsFADBnMQswCQYDVQQGEwJFRTEiMCAGA"
b"1UECgwZQVMgU2VydGlmaXRzZWVyaW1pc2tlc2t1czEXMBUGA1UEYQwOTlRSRUUtMTA3NDcwMTMxGzAZBgNVBAMMEl"
b"RFU1Qgb2YgTlEtU0sgMjAxNjAeFw0xNzAyMDIwOTE0MzdaFw0yMjAyMDEyMTU5NTlaMIG0MQswCQYDVQQGEwJFRTE"
b"iMCAGA1UECgwZQVMgU2VydGlmaXRzZWVyaW1pc2tlc2t1czEXMBUGA1UECwwOYXV0aGVudGljYXRpb24xKTAnBgNV"
b"BAMMIFNNQVJULUlELEhFTExPLFBOT0VFLTExNzAyMDIwMjAwMREwDwYDVQQEDAhTTUFSVC1JRDEOMAwGA1UEKgwFS"
b"EVMTE8xGjAYBgNVBAUTEVBOT0VFLTExNzAyMDIwMjAwMIICITANBgkqhkiG9w0BAQEFAAOCAg4AMIICCQKCAgBnO0"
b"Xm9670tbqRd8744SD+zVltpmKSOAP7/mx1uvjTLBZ2ZiCKR0Obhnl4fjwZtDr5HBk5MbzQsgtB0effkgImm2pJBhb"
b"qhZKBwrEPaxqDIQjlq15MtrGIkVAwAw5ZMEoODZRSGW6c8qG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AjB2BggrBgEFBQcBAQR"
b"qMGgwIwYIKwYBBQUHMAGGF2h0dHA6Ly9haWEuc2suZWUvbnEyMDE2MEEGCCsGAQUFBzAChjVodHRwczovL3NrLmVl"
b"L3VwbG9hZC9maWxlcy9URVNUX29mX05RLVNLXzIwMTYuZGVyLmNydDAxBgNVHREEKjAopCYwJDEiMCAGA1UEAwwZU"
b"E5PRUUtMTE3MDIwMjAyMDAtMDVOWC1OUTANBgkqhkiG9w0BAQsFAAOCAgEAkolGIm7+tLHXHxYVCz78m7GoUkXD/u"
b"8lYbQyAujo9ZoyVrgPmLXbsCxTqXjUOD7nIjVSNfwEPYFmrkG34to2+JLvt0H/nGUO345VOnsRtvDau58RxU5jeT1"
b"nFnkCZSdYxpFkr4D276d7qyfATYhEeW4h3F5gjgYslBeLRFHPQwaIyTZmtWJ5RLNzJsqpJgQCeFXu2XLSOwCbG9RT"
b"CGoaYPv4qiD4kUTSpXQPm+QyOzMidOsVBBOxqdtGCFBp0l8omW7pwQv1nA0dlg7jELh2QaJn7/L6mFyrZGL9Nvi6l"
b"UrGhz+0p1xPDl9iW99a+UokcWUA5DsoXKr5ogJlqDluYMk+8Jwpq4sB8mGyYrhqJjDz4c33CU5nfzVrYJDhU0TMFJ"
b"qqFyLZYriIOYxzXrZ8nNlEQiYRwR4ESUvVXSjppjLGW6oDG63Xr6ktfaMwfucpbzE3rv+c6iJVkBeBk6C//ATClZG"
b"DNt3oYjydFgkAccjyiOsojmO3JM3ymi17ueXC8B14vyMGkX9z3ZyOW04kAdeyYT1XIQUeeBu0OrTC+D6kuFk/dAYT"
b"6mfSuVBFivkmzUHVMS3mFUSBCInDv29gul5PSd3kWybhvVvxTD0E/WzuGRg5iJmKsbpCgS6WcP/A3I0W/zvUTcAii"
b"mN3NoztEEMV6tiHeDB/zjIiNcOaQQE="
)
@pytest.fixture()
def signed_container_path():
return Path(__file__).parent / "esteid" / "tests" / "files" / "signed-test-mobileid-ee.asice"
@pytest.fixture()
def signed_container_file(signed_container_path):
"""A real container signed via the Demo MobileID service with a test account"""
with open(signed_container_path, "rb") as f:
yield f
@pytest.fixture()
def signed_container(signed_container_file):
"""A handle to the signed container"""
with pyasice.Container(signed_container_file) as f:
yield f
@pytest.fixture()
def override_esteid_settings():
@contextmanager
def wrapped(**kwargs):
with override_settings(**kwargs):
importlib.reload(esteid.settings)
yield
importlib.reload(esteid.settings)
return wrapped