Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat/tests] Unit tests #2

Merged
merged 21 commits into from
Feb 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: fixed key generation
PascalDR committed Jan 31, 2024
commit f1f2889f4104683097e97533a97ca91872dbab3d
11 changes: 2 additions & 9 deletions pymdoccbor/tests/test_02_mdoc_issuer.py
Original file line number Diff line number Diff line change
@@ -2,21 +2,14 @@
import os

from pycose.messages import Sign1Message

from pycose.keys import EC2Key
from pymdoccbor.mdoc.issuer import MdocCborIssuer
from pymdoccbor.mdoc.verifier import MdocCbor
from pymdoccbor.mso.issuer import MsoIssuer
from . pid_data import PID_DATA


PKEY = {
'KTY': 'EC2',
'CURVE': 'P_256',
'ALG': 'ES256',
'D': os.urandom(32),
'KID': b"demo-kid"
}

PKEY = EC2Key.generate_key(crv="P_256", optional_params={"ALG": "ES256"})

def test_mso_writer():
msoi = MsoIssuer(
10 changes: 2 additions & 8 deletions pymdoccbor/tests/test_03_mdoc_issuer.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import os
from pycose.keys import EC2Key
from pymdoccbor.mdoc.issuer import MdocCborIssuer
from pymdoccbor.tests.micov_data import MICOV_DATA
from pymdoccbor.tests.pid_data import PID_DATA


PKEY = {
'KTY': 'EC2',
'CURVE': 'P_256',
'ALG': 'ES256',
'D': os.urandom(32),
'KID': b"demo-kid"
}
PKEY = EC2Key.generate_key(crv="P_256", optional_params={"ALG": "ES256"})

mdoc = MdocCborIssuer(PKEY)

10 changes: 2 additions & 8 deletions pymdoccbor/tests/test_04_issuer_signed.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import os
from pycose.keys import EC2Key
from pymdoccbor.mdoc.issuersigned import IssuerSigned
from pymdoccbor.mdoc.issuer import MdocCborIssuer
from pymdoccbor.tests.micov_data import MICOV_DATA
from pymdoccbor.tests.test_03_mdoc_issuer import mdoc

PKEY = {
'KTY': 'EC2',
'CURVE': 'P_256',
'ALG': 'ES256',
'D': os.urandom(32),
'KID': b"demo-kid"
}
PKEY = EC2Key.generate_key(crv="P_256", optional_params={"ALG": "ES256"})

mdoc = MdocCborIssuer(PKEY)
mdoc.new(
12 changes: 3 additions & 9 deletions pymdoccbor/tests/test_05_mdoc_verifier.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import os
from pycose.keys import EC2Key
from pymdoccbor.mdoc.verifier import MobileDocument
from pymdoccbor.mdoc.issuer import MdocCborIssuer
from pymdoccbor.tests.micov_data import MICOV_DATA

PKEY = {
'KTY': 'EC2',
'CURVE': 'P_256',
'ALG': 'ES256',
'D': os.urandom(32),
'KID': b"demo-kid"
}
PKEY = EC2Key.generate_key(crv="P_256", optional_params={"ALG": "ES256"})

mdoc = MdocCborIssuer(PKEY)
mdoc.new(
@@ -59,4 +53,4 @@ def test_mobile_document_verify():
document = mdoc.signed["documents"][0]
doc = MobileDocument(**document)

#assert mdoc.verify() == True
assert doc.verify() == True
10 changes: 2 additions & 8 deletions pymdoccbor/tests/test_06_mso_issuer.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import os
from pycose.keys import EC2Key
from pycose.messages import CoseMessage
from pymdoccbor.mso.issuer import MsoIssuer
from pymdoccbor.tests.micov_data import MICOV_DATA

PKEY = {
'KTY': 'EC2',
'CURVE': 'P_256',
'ALG': 'ES256',
'D': os.urandom(32),
'KID': b"demo-kid"
}
PKEY = EC2Key.generate_key(crv="P_256", optional_params={"ALG": "ES256"})

def test_mso_issuer_fail():
try:
9 changes: 2 additions & 7 deletions pymdoccbor/tests/test_07_mso_verifier.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import os
from pycose.keys import CoseKey, EC2Key
from pymdoccbor.mso.verifier import MsoVerifier
from pymdoccbor.mdoc.issuer import MdocCborIssuer
from pymdoccbor.tests.micov_data import MICOV_DATA
from pycose.messages import CoseMessage

PKEY = {
'KTY': 'EC2',
'CURVE': 'P_256',
'ALG': 'ES256',
'D': os.urandom(32),
'KID': b"demo-kid"
}
PKEY = EC2Key.generate_key(crv="P_256", optional_params={"ALG": "ES256"})

mdoc = MdocCborIssuer(PKEY)
mdoc.new(