Skip to content

Commit

Permalink
Fix #11: Add testcase for decoding base64 disclosure and decoding cre…
Browse files Browse the repository at this point in the history
…dential subject from sdjwt
  • Loading branch information
albinpa authored and georgepadayatti committed Oct 22, 2024
1 parent 4428246 commit 5e2a728
Showing 1 changed file with 200 additions and 0 deletions.
200 changes: 200 additions & 0 deletions sdjwt/tests/test_sdjwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
get_current_datetime_in_epoch_seconds_and_iso8601_format,
create_flat_sd_jwt,
create_w3c_vc_sd_jwt,
get_all_disclosures_with_sd_from_token,
decode_credential_sd_to_credential_subject,
)
import jwt
import json
Expand Down Expand Up @@ -190,6 +192,204 @@ async def test_create_w3c_vc_sd_jwt_for_passport(self):
condition6 = len(decoded_claims["vc"]["credentialSubject"]["_sd"]) == 4
self.assert_(condition6, "VC doesn't contain all of the digest of disclosures")

async def test_decode_credential_sd_to_credential_subject(self):
# Case 1
token_1 = "eyJhbGciOiJFUzI1NiIsImtpZCI6ImRpZDprZXk6ejJkbXpEODFjZ1B4OFZraTdKYnV1TW1GWXJXUGdZb3l0eWtVWjNleXFodDFqOUticUhZTU12UU5VRnBVeGtKRTlTd051djNRcFhQZ1BlYmljS1FjOGQ0RDFvdHNNc2d0YVhCTndKNHpZOFNRUFpiY0FIeGJHd2trYk50bUh5ZnVUZGs4bkNxVlNlcGVXWGhoM1NqcnUyWDVmVEhucGdyOEZUeXczZTFXamJ4UUhoc0c5MiN6MmRtekQ4MWNnUHg4VmtpN0pidXVNbUZZcldQZ1lveXR5a1VaM2V5cWh0MWo5S2JxSFlNTXZRTlVGcFV4a0pFOVN3TnV2M1FwWFBnUGViaWNLUWM4ZDREMW90c01zZ3RhWEJOd0o0elk4U1FQWmJjQUh4Ykd3a2tiTnRtSHlmdVRkazhuQ3FWU2VwZVdYaGgzU2pydTJYNWZUSG5wZ3I4RlR5dzNlMVdqYnhRSGhzRzkyIiwidHlwIjoiSldUIn0.eyJleHAiOjE3MTU3NzA4Mj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ZkMjA0MWYwYzczNmYxYzk0ZDE5MWUyYmQ5NzY2ZjFkMTFiNGI2NDNkYTkxNjVjZDM3NjBiNDk5Mjg5IiwiaWRlbnRpZmllciIsIjEyMzQwMC03ODk5Il0~WyIwNzEzMDRiMWU5OWEyMDRmZGMzMzUyMmQ5OTEyNTcyNjkwOWMxMTgzZjFlMTM4N2UyNWE1NzMwM2RhMzgyNmIxIiwibGVnYWxOYW1lIiwiQnlnZyBBQiJd"
sd_credential_subject_1 = {
"_sd": [
"NVUlaajIRdHClgrjko1Fy1bMD3jXK92OY0GTaOR4SX8",
"ipRnl63PV9TVXaFXYIX9P6VUk0QyL8_m6zutGTHnstg",
],
"id": "did:key:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9Kbowo1MYpCJwNfzfFggXuWxdPAdAWhkp9XskU2cir7r21AxqN2TMvMTUS1FmaNWLm2esa8FLwZ35i5mRzUygDQdZRS1gC42Am9Doyh68Hp1Ksap9e9xzebDYFhhLgXTksgnG",
}
expected_credential_subject_1 = {
"id": "did:key:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9Kbowo1MYpCJwNfzfFggXuWxdPAdAWhkp9XskU2cir7r21AxqN2TMvMTUS1FmaNWLm2esa8FLwZ35i5mRzUygDQdZRS1gC42Am9Doyh68Hp1Ksap9e9xzebDYFhhLgXTksgnG",
"identifier": "123400-7899",
"legalName": "Bygg AB",
}
# Case 2
token_2 = "eyJhbGciOiJFUzI1NiIsImtpZCI6ImRpZDprZXk6ejJkbXpEODFjZ1B4OFZraTdKYnV1TW1GWXJXUGdZb3l0eWtVWjNleXFodDFqOUticUhZTU12UU5VRnBVeGtKRTlTd051djNRcFhQZ1BlYmljS1FjOGQ0RDFvdHNNc2d0YVhCTndKNHpZOFNRUFpiY0FIeGJHd2trYk50bUh5ZnVUZGs4bkNxVlNlcGVXWGhoM1NqcnUyWDVmVEhucGdyOEZUeXczZTFXamJ4UUhoc0c5MiN6M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otte",
"nationalities": ["SE"],
"personalIdentificationNumber": "19681229-1412",
"placeBirth": {
"countryCode": "SE",
"region": "Stockholm",
"town": "Stockholm",
},
"sex": "Female",
"stateOfResidenceAddress": {
"countryCode": "SE",
"postCode": "418 78",
"streetNo": "Gunnar Engellaus vag 8, 91 1B",
"town": "Stockholm",
},
"stateOfStayAddress": {
"countryCode": "SE",
"postCode": "418 78",
"streetNo": "Gunnar Engellaus vag 8, 91 1B",
"town": "Stockholm",
},
"surname": "Anderson",
"surnameAtBirth": "Anderson",
},
}
expected_credential_subject_2 = {
"id": "did:key:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9Kbowo1MYpCJwNfzfFggXuWxdPAdAWhkp9XskU2cir7r21AxqN2TMvMTUS1FmaNWLm2esa8FLwZ35i5mRzUygDQdZRS1gC42Am9Doyh68Hp1Ksap9e9xzebDYFhhLgXTksgnG",
"section1": {
"forenames": "Charlotte",
"nationalities": ["SE"],
"personalIdentificationNumber": "19681229-1412",
"placeBirth": {
"countryCode": "SE",
"region": "Stockholm",
"town": "Stockholm",
},
"sex": "Female",
"stateOfResidenceAddress": {
"countryCode": "SE",
"postCode": "418 78",
"streetNo": "Gunnar Engellaus vag 8, 91 1B",
"town": "Stockholm",
},
"stateOfStayAddress": {
"countryCode": "SE",
"postCode": "418 78",
"streetNo": "Gunnar Engellaus vag 8, 91 1B",
"town": "Stockholm",
},
"surname": "Anderson",
"surnameAtBirth": "Anderson",
"dateBirth": "1968-12-29",
},
"section4": {
"employee": False,
"employerSelfEmployedActivityCodes": ["1889113244"],
"nameBusinessName": "Volvo",
"registeredAddress": {
"countryCode": "SE",
"postCode": "418 78",
"streetNo": "Gunnar Engellaus vu00e4g 8, 164 A",
"town": "Goteborg",
},
"selfEmployedActivity": True,
},
"section3": {
"civilAndEmployedSelfEmployed": False,
"civilServant": False,
"contractStaff": False,
"employedAndSelfEmployed": False,
"employedTwoOrMoreStates": False,
"exception": False,
"exceptionDescription": "",
"flightCrewMember": False,
"mariner": False,
"postedEmployedPerson": False,
"postedSelfEmployedPerson": False,
"selfEmployedTwoOrMoreStates": False,
"workingInStateUnder21": False,
},
"section2": {
"certificateForDurationActivity": True,
"determinationProvisional": False,
"endingDate": "2024-07-03",
"memberStateWhichLegislationApplies": "IT",
"startingDate": "2023-09-21",
"transitionRulesApplyAsEC8832004": False,
},
"section5": {
"noFixedAddress": False,
"workPlaceAddresses": [
{
"address": {
"countryCode": "IT",
"postCode": "34132",
"streetNo": "Piazza Duca degli Abruzzi 2, 440",
"town": "Trieste",
},
"seqno": 1,
}
],
"workPlaceNames": [
{
"companyNameVesselName": "Assicurazioni Generali S.p.A",
"seqno": 1,
}
],
},
"section6": {
"address": {
"countryCode": "BE",
"postCode": "1000",
"streetNo": "Main Street 1",
"town": "Brussels",
},
"date": "2023-09-07",
"email": "[email protected]",
"institutionID": "NSSI-BE-01",
"name": "National Social Security Office",
"officeFaxNo": "0800 98765",
"officePhoneNo": "0800 12345",
"signature": "Official signature",
},
}
# Test for case 1
disclosure_mapping = get_all_disclosures_with_sd_from_token(token=token_1)
credential_subject_1 = decode_credential_sd_to_credential_subject(
disclosure_mapping=disclosure_mapping,
credential_subject=sd_credential_subject_1,
)
condition_1 = (
credential_subject_1["identifier"]
== expected_credential_subject_1["identifier"]
)
self.assert_(
condition_1,
"Expected credential subject attribute `identifier` doesn't match with result",
)
condition_2 = (
credential_subject_1["legalName"]
== expected_credential_subject_1["legalName"]
)
self.assert_(
condition_2,
"Expected credential subject attribute `legalName` doesn't match with result",
)

# Test for case 2
disclosure_mapping = get_all_disclosures_with_sd_from_token(token=token_2)
credential_subject_2 = decode_credential_sd_to_credential_subject(
disclosure_mapping=disclosure_mapping,
credential_subject=sd_credential_subject_2,
)
condition_1 = (
credential_subject_2["section1"]["dateBirth"]
== expected_credential_subject_2["section1"]["dateBirth"]
)
self.assert_(
condition_1,
"Expected credential subject attribute `dateBirth` doesn't match with result",
)
condition_2 = (
credential_subject_2["section6"]
== expected_credential_subject_2["section6"]
)
self.assert_(
condition_2,
"Expected credential subject attribute `section6` doesn't match with result",
)


if __name__ == "__main__":
unittest.main()

0 comments on commit 5e2a728

Please sign in to comment.