-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add #25 Add bdd test for issue_616.feature
- Loading branch information
1 parent
c4a3d25
commit 25b55ab
Showing
9 changed files
with
964 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import json | ||
|
||
from jwcrypto import jwk, jwt | ||
|
||
|
||
|
||
def generate_secp256r1_jwk(): | ||
# Generate EC key pair for secp256r1 curve | ||
key = jwk.JWK.generate(kty="EC", crv="P-256") | ||
return key | ||
|
||
|
||
def sign_jws(payload, private_key): | ||
# Generate JSON web signature | ||
key = jwk.JWK(**private_key) | ||
token = jwt.JWT(header={"alg": "ES256"}, claims=payload) | ||
token.make_signed_token(key) | ||
return token.serialize() | ||
|
||
private_key = generate_secp256r1_jwk() | ||
|
||
payload = "{\"schemaName\":\"ConsentRecord\",\"objectId\":\"2\",\"signedWithoutObjectId\":false,\"timestamp\":\"2024-01-17T10:15:07Z\",\"authorizedByIndividualId\":\"1\",\"authorizedByOtherId\":\"\",\"objectData\":\"{\\\"id\\\":\\\"2\\\",\\\"dataAgreementId\\\":\\\"2\\\",\\\"dataAgreementRevisionId\\\":\\\"659fd68befcb8216c24c2695\\\",\\\"dataAgreementRevisionHash\\\":\\\"3f0f5aef5e79afb50428ed835ad628db449c4504\\\",\\\"individualId\\\":\\\"1\\\",\\\"optIn\\\":true,\\\"state\\\":\\\"signed\\\",\\\"signatureId\\\":\\\"1\\\"}\"}" | ||
|
||
jws_token = sign_jws(payload, private_key.export(as_dict=True)) | ||
|
||
print( | ||
f"Public key JWK:\n{json.dumps(private_key.export(private_key=False, as_dict=False), indent=2)}\n" | ||
) | ||
print(f"JWS:\n{jws_token}") | ||
|
||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Oops, something went wrong.