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/documentation] Docs for federation package #198

Merged
merged 31 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c49bdfb
Merge pull request #104 from italia/dev
Sep 9, 2023
c6a81ca
Merge pull request #134 from italia/dev
Oct 9, 2023
70f50fa
Merge branch 'main' of https://github.com/italia/eudi-wallet-it-satos…
PascalDR Oct 16, 2023
46ff77f
Merge branch 'dev' of https://github.com/italia/eudi-wallet-it-satosa…
PascalDR Nov 22, 2023
56feaa5
feat: added policy apply on metadata
PascalDR Nov 23, 2023
1ea7bac
test: added intial tests for TrustEvaluationHelper
PascalDR Nov 23, 2023
47fd884
fix: fixed validation issues
PascalDR Nov 23, 2023
bd36786
feat: implemented method add_trust_attestation_metadata
PascalDR Nov 23, 2023
aa0133f
test: added test for add_trust_attestation_metadata
PascalDR Nov 23, 2023
4e44ecf
Merge branch 'dev' of https://github.com/italia/eudi-wallet-it-satosa…
PascalDR Nov 23, 2023
f512f59
Merge branch 'dev' of https://github.com/italia/eudi-wallet-it-satosa…
PascalDR Nov 27, 2023
1d3fa1b
fix: added metadata association by metadata_type field
PascalDR Nov 27, 2023
d90974c
fix: minor fix to test for add_trust_attestation_metadata's data type
PascalDR Nov 27, 2023
850d432
chore: renamed test file
PascalDR Nov 27, 2023
c062b35
chore: Removed comment
PascalDR Nov 27, 2023
bf3843c
fix: fixed x509 verification exception handling
PascalDR Nov 27, 2023
5a74ea0
chore: fix typo
PascalDR Nov 27, 2023
daeb343
fix: merged federation and metadata policy implementation
PascalDR Nov 29, 2023
f94b063
test: adapted tests
PascalDR Nov 29, 2023
67a4d12
feat: added final_metadata property
PascalDR Nov 29, 2023
059e94b
feat: added chain discovery plus refactoring
PascalDR Nov 29, 2023
5782f15
Merge branch 'dev' of https://github.com/italia/eudi-wallet-it-satosa…
PascalDR Nov 29, 2023
b807998
docs: documented file class and functions
PascalDR Dec 4, 2023
62edae6
fix: fixed trust_anchor_entity_conf handling
PascalDR Dec 4, 2023
9243e61
docs: documented trust_chain_builder.py
PascalDR Dec 4, 2023
24a8782
fix: moved implementation of get_http_url in utils.py
PascalDR Dec 5, 2023
29a876e
fix: fixed response handling
PascalDR Dec 5, 2023
1de5916
docs: documented file class and function plus refactoring
PascalDR Dec 5, 2023
7d5a273
docs: documented file __init__.py
PascalDR Dec 6, 2023
baaede8
docs: added docs for http_client.py
PascalDR Dec 6, 2023
d5758bd
Merge branch 'dev' of https://github.com/italia/eudi-wallet-it-satosa…
PascalDR Dec 6, 2023
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
20 changes: 20 additions & 0 deletions pyeudiw/federation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
from pyeudiw.federation.schemas.entity_configuration import EntityStatementPayload, EntityConfigurationPayload

def is_es(payload: dict) -> bool:
"""
Determines if payload dict is an Entity Statement
:param payload: the object to determine if is an Entity Statement
:type payload: dict
:returns: True if is an Entity Statement and False otherwise
:rtype: bool
"""

try:
EntityStatementPayload(**payload)
if payload["iss"] != payload["sub"]:
Expand All @@ -10,6 +20,16 @@ def is_es(payload: dict) -> bool:


def is_ec(payload: dict) -> bool:
"""
Determines if payload dict is an Entity Configuration
:param payload: the object to determine if is an Entity Configuration
:type payload: dict
:returns: True if is an Entity Configuration and False otherwise
:rtype: bool
"""

try:
EntityConfigurationPayload(**payload)
return True
Expand Down
44 changes: 42 additions & 2 deletions pyeudiw/federation/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,43 @@
import requests


async def fetch(session, url, httpc_params: dict):
async def fetch(session: dict, url: str, httpc_params: dict) -> str:
"""
Fetches the content of a URL.
:param session: a dict representing the current session
:type session: dict
:param url: the url where fetch the content
:type url: str
:param httpc_params: parameters to perform http requests.
:type httpc_params: dict
:returns: the response in string format
:rtype: str
"""

async with session.get(url, **httpc_params.get("connection", {})) as response:
if response.status != 200: # pragma: no cover
# response.raise_for_status()
return ""
return await response.text()


async def fetch_all(session, urls, httpc_params: dict):
async def fetch_all(session: dict, urls: list[str], httpc_params: dict) -> list[str]:
"""
Fetches the content of a list of URL.
:param session: a dict representing the current session
:type session: dict
:param urls: the url list where fetch the content
:type urls: list[str]
:param httpc_params: parameters to perform http requests.
:type httpc_params: dict
:returns: the list of responses in string format
:rtype: list[str]
"""

tasks = []
for url in urls:
task = asyncio.create_task(fetch(session, url, httpc_params))
Expand All @@ -21,7 +49,19 @@ async def fetch_all(session, urls, httpc_params: dict):


async def http_get(urls, httpc_params: dict, sync=True):
"""
Perform a GET http call.
:param session: a dict representing the current session
:type session: dict
:param urls: the url list where fetch the content
:type urls: list[str]
:param httpc_params: parameters to perform http requests.
:type httpc_params: dict
:returns: the list of responses in string format
:rtype: list[str]
"""
if sync:
_conf = {
'verify': httpc_params['connection']['ssl'],
Expand Down
Loading
Loading