Revize d53c2fdc
Přidáno uživatelem Michal Seják před více než 3 roky(ů)
tests/unit_tests/rest_api/certificates.py | ||
---|---|---|
151 | 151 |
assert not d["success"] |
152 | 152 |
|
153 | 153 |
|
154 |
def test_root_inter_ca(server):
|
|
154 |
def test_create_chain(server):
|
|
155 | 155 |
ret = server.post("/api/certificates", content_type="application/json", json={ |
156 | 156 |
"subject": { |
157 | 157 |
"C": "CZ", |
... | ... | |
209 | 209 |
assert "success" in d |
210 | 210 |
assert d["success"] |
211 | 211 |
|
212 |
ret = server.post("/api/certificates", content_type="application/json", json={ |
|
213 |
"CA": 3, |
|
214 |
"subject": { |
|
215 |
"C": "CZ", |
|
216 |
"CN": "Legit end certificate s.r.o.", |
|
217 |
"L": "Pilsen", |
|
218 |
"O": "I swear s.r.o.", |
|
219 |
"OU": "IT department", |
|
220 |
"ST": "Pilsen Region", |
|
221 |
"emailAddress": "end@ca.com" |
|
222 |
}, |
|
223 |
"usage": { |
|
224 |
"CA": True, |
|
225 |
"SSL": True, |
|
226 |
"authentication": True, |
|
227 |
"digitalSignature": True |
|
228 |
}, |
|
229 |
"validityDays": 30 |
|
230 |
}) |
|
231 |
|
|
232 |
assert ret.status_code == 201 |
|
233 |
|
|
234 |
d = ret.json |
|
235 |
|
|
236 |
assert "data" in d |
|
237 |
assert d["data"] == 4 |
|
238 |
assert "success" in d |
|
239 |
assert d["success"] |
|
240 |
|
|
212 | 241 |
|
213 | 242 |
def test_list_of_certificates(server): |
214 | 243 |
ret = server.get("/api/certificates") |
... | ... | |
270 | 299 |
d = ret.json |
271 | 300 |
|
272 | 301 |
assert "data" in d |
273 |
assert d["data"] == 4
|
|
302 |
assert d["data"] == 5
|
|
274 | 303 |
assert "success" in d |
275 | 304 |
assert d["success"] |
276 | 305 |
|
277 | 306 |
ret = server.post("/api/certificates", content_type="application/json", json={ |
278 |
"CA": 2,
|
|
307 |
"CA": 5,
|
|
279 | 308 |
"subject": { |
280 | 309 |
"C": "CZ", |
281 | 310 |
"CN": "End certificate signed by end certificate s.r.o.", |
... | ... | |
300 | 329 |
d = ret.json |
301 | 330 |
|
302 | 331 |
assert "data" in d |
303 |
assert d["data"] == 5
|
|
332 |
assert d["data"] == 6
|
|
304 | 333 |
assert "success" in d |
305 | 334 |
assert d["success"] |
306 | 335 |
|
... | ... | |
370 | 399 |
assert "data" in ret.json |
371 | 400 |
assert "success" in ret.json |
372 | 401 |
assert not ret.json["success"] |
373 |
assert ret.json["data"] == "No certificates found."
|
|
402 |
assert ret.json["data"] == "No such certificate found."
|
|
374 | 403 |
|
375 | 404 |
|
376 | 405 |
def test_get_detes(server): |
... | ... | |
403 | 432 |
|
404 | 433 |
d = ret.json |
405 | 434 |
|
406 |
assert d["data"] == 6
|
|
435 |
assert d["data"] == 7
|
|
407 | 436 |
|
408 | 437 |
id = d["data"] |
409 | 438 |
|
... | ... | |
421 | 450 |
|
422 | 451 |
assert original["CA"] == new["CA"] |
423 | 452 |
assert original["subject"] == new["subject"] |
424 |
assert original["usage"] == new["usage"] |
|
453 |
assert original["usage"] == new["usage"] |
|
454 |
|
|
455 |
|
|
456 |
def test_get_root(server): |
|
457 |
ret = server.get("/api/certificates/2") |
|
458 |
|
|
459 |
assert ret.status_code == 200 |
|
460 |
|
|
461 |
assert "data" in ret.json |
|
462 |
assert "success" in ret.json |
|
463 |
assert ret.json["success"] |
|
464 |
|
|
465 |
original = ret.json["data"] |
|
466 |
|
|
467 |
ret = server.get("/api/certificates/4/root") |
|
468 |
|
|
469 |
assert ret.status_code == 200 |
|
470 |
|
|
471 |
assert "data" in ret.json |
|
472 |
assert "success" in ret.json |
|
473 |
assert ret.json["success"] |
|
474 |
|
|
475 |
new = ret.json["data"] |
|
476 |
|
|
477 |
assert original == new |
|
478 |
|
|
479 |
|
|
480 |
def test_get_root_invalid(server): |
|
481 |
ret = server.get("/api/certificates/805/root") |
|
482 |
|
|
483 |
assert ret.status_code == 205 |
|
484 |
assert "data" in ret.json |
|
485 |
assert "success" in ret.json |
|
486 |
assert not ret.json["success"] |
|
487 |
assert ret.json["data"] == "No such certificate found." |
|
488 |
|
Také k dispozici: Unified diff
Re #8476 - Implemented and tested `get_cert_root(id)`.