Revize e9b4e2a1
Přidáno uživatelem Stanislav Král před téměř 4 roky(ů)
src/services/certificate_service.py | ||
---|---|---|
56 | 56 |
:param subject: A subject to be verified |
57 | 57 |
:raises InvalidCertificateAttribute: When a subject with an invalid attribute is passed |
58 | 58 |
""" |
59 |
if subject.country is not None and len(subject.country) != 2: |
|
59 |
if subject.country is not None and subject.country != "" and len(subject.country) != 2:
|
|
60 | 60 |
raise InvalidSubjectAttribute("Country code", "Must consist of exactly 2 letters") |
61 | 61 |
|
62 | 62 |
# TODO usages present in method parameters but not in class diagram |
tests/integration_tests/rest_api/certificates_test.py | ||
---|---|---|
1302 | 1302 |
@pytest.mark.parametrize( |
1303 | 1303 |
"cc", |
1304 | 1304 |
[ |
1305 |
pytest.param(""), |
|
1306 | 1305 |
pytest.param("C"), |
1307 | 1306 |
pytest.param("CCZ"), |
1308 | 1307 |
], |
... | ... | |
1323 | 1322 |
@pytest.mark.parametrize( |
1324 | 1323 |
"cc", |
1325 | 1324 |
[ |
1326 |
pytest.param(""), |
|
1327 | 1325 |
pytest.param("C"), |
1328 | 1326 |
pytest.param("CCZ"), |
1329 | 1327 |
], |
1330 | 1328 |
) |
1331 |
def test_invalid_subject_country_code(server, cc): |
|
1329 |
def test_inter_ca_invalid_subject_country_code(server, cc):
|
|
1332 | 1330 |
root_ret = make_root_ca(server) |
1333 | 1331 |
ret = make_inter_ca(server, root_ret.json["data"], "Foo", cc) |
1334 | 1332 |
|
tests/integration_tests/services/certificate_service_test.py | ||
---|---|---|
517 | 517 |
"cc", |
518 | 518 |
[ |
519 | 519 |
pytest.param(None), |
520 |
pytest.param(""), |
|
520 | 521 |
pytest.param("CZ") |
521 | 522 |
], |
522 | 523 |
) |
... | ... | |
529 | 530 |
"cc", |
530 | 531 |
[ |
531 | 532 |
pytest.param(None), |
533 |
pytest.param(""), |
|
532 | 534 |
pytest.param("CZ"), |
533 | 535 |
], |
534 | 536 |
) |
... | ... | |
548 | 550 |
@pytest.mark.parametrize( |
549 | 551 |
"cc", |
550 | 552 |
[ |
551 |
pytest.param(""), |
|
552 | 553 |
pytest.param("C"), |
553 | 554 |
pytest.param("CCZ"), |
554 | 555 |
], |
... | ... | |
564 | 565 |
@pytest.mark.parametrize( |
565 | 566 |
"cc", |
566 | 567 |
[ |
567 |
pytest.param(""), |
|
568 | 568 |
pytest.param("C"), |
569 | 569 |
pytest.param("CCZ"), |
570 | 570 |
], |
tests/unit_tests/services/certificate/check_subject_is_valid_test.py | ||
---|---|---|
15 | 15 |
@pytest.mark.parametrize( |
16 | 16 |
"cc", |
17 | 17 |
[ |
18 |
pytest.param(""), |
|
19 | 18 |
pytest.param("C"), |
20 | 19 |
pytest.param("CCZ"), |
21 | 20 |
], |
Také k dispozici: Unified diff
Empty country code is now considered as a valid country code when creating a new certificate.
Changed tests accordingly.