-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
subject and issuer are now structured data instead of an RFC string
- Loading branch information
1 parent
74c45e5
commit e58a82a
Showing
10 changed files
with
126 additions
and
29 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
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
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
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
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
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,43 @@ | ||
# This file is part of django-ca (https://github.com/mathiasertl/django-ca). | ||
# | ||
# django-ca is free software: you can redistribute it and/or modify it under the terms of the GNU General | ||
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your | ||
# option) any later version. | ||
# | ||
# django-ca is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | ||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
# for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with django-ca. If not, see | ||
# <http://www.gnu.org/licenses/>. | ||
|
||
"""Tests for pydantic schemas.""" | ||
|
||
import json | ||
|
||
from cryptography import x509 | ||
from cryptography.x509.oid import NameOID | ||
|
||
import pytest | ||
|
||
from django_ca.api.schemas import NameAttributeSchema | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"oid,value", | ||
[ | ||
(NameOID.COMMON_NAME, "example.com"), | ||
(NameOID.COUNTRY_NAME, "AT"), | ||
], | ||
) | ||
def test_name_attribute_schema(oid: x509.ObjectIdentifier, value: str) -> None: | ||
"""Test NameAttributeSchema.""" | ||
encoded = NameAttributeSchema(oid=oid.dotted_string, value=value).json() | ||
assert json.loads(encoded) == {"oid": oid.dotted_string, "value": value} | ||
|
||
|
||
@pytest.mark.xfail(reason="json_encoders doesn't work for Union[] attributes in pydantic 1.10.12.") | ||
def test_name_attribute_with_bytes() -> None: | ||
"""Test name attribute with bytes. This does not currently work.""" | ||
encoded = NameAttributeSchema(oid=NameOID.X500_UNIQUE_IDENTIFIER.dotted_string, value=b"\x00\x01").json() | ||
assert json.loads(encoded) == {"oid": NameOID.X500_UNIQUE_IDENTIFIER.dotted_string, "value": "AAE="} |
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
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
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
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