From 2ad24419ef7b498cfd5c1627e880b445ed4c2e2d Mon Sep 17 00:00:00 2001 From: JorgeEcheva26 Date: Fri, 29 Nov 2024 12:43:15 +0100 Subject: [PATCH 01/24] ci/cd --- pyproject.toml | 51 ------------------------------------------------ setup.py | 53 +++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 56 deletions(-) delete mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 4434717..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,51 +0,0 @@ -[build-system] -requires = ["setuptools>=61.0"] -build-backend = "setuptools.build_meta" - -[project] -name = "opencapif_sdk" -version = "0.1.15" -authors = [ - { name="JorgeEcheva", email="jorge.echevarriauribarri.practicas@telefonica.com" }, - { name="dgs-cgm", email="daniel.garciasanchez@telefonica.com" } -] -description = "This repository develops a Python Software Development Kit(SDK) which focuses on connecting to OpenCAPIF (Common API Framework for 3GPP Northbound APIs) in a simple way, lowering integration complexity and allowing developers to focus on Network Applications (Network Apps) or services development." -readme = "./doc/README_pipy.md" -license = { file="LICENSE" } -requires-python = ">=3.9" -keywords = ["pesp_capif_sdk","capif","sdk capif","opencapif_sdk"] -dependencies = [ - "requests==2.32.3", - "PyYAML==6.0.1", - "cryptography==38.0.4", - "pyOpenSSL==22.1.0", - "urllib3==2.2.2", - "certifi==2024.7.4", - "idna==3.7", - "Flask==3.0.3", - "Flask-JWT-Extended==4.6.0", - "Jinja2==3.1.4", - "MarkupSafe==2.1.5", - "six==1.16.0", - "typing-extensions>=4.8.0", - "Werkzeug==3.0.4", - "pytest==8.3.2", - "flake8==3.9.2", - "coverage==4.5.4", - "mccabe==0.6.1", - "pycodestyle==2.7.0", - "pyflakes==2.3.1", - "python-dateutil==2.9.0.post0", - "jinja2-time==0.2.0", - "text-unidecode==1.3", - "binaryornot==0.4.4" -] - - -classifiers = [ - "Programming Language :: Python :: 3", - "Operating System :: OS Independent", -] - -[project.urls] -"Homepage" = "https://github.com/Telefonica/pesp_capif_sdk" diff --git a/setup.py b/setup.py index ace150b..92e13c6 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,52 @@ -"""The setup script.""" - from setuptools import setup, find_packages setup( - name='opencapif_sdk', - packages=find_packages(include=["opencapif_sdk"]), + name="opencapif_sdk", version="0.1.15", -) \ No newline at end of file + author="JorgeEcheva, dgs-cgm", + author_email="jorge.echevarriauribarri.practicas@telefonica.com, daniel.garciasanchez@telefonica.com", + description=( + "This repository develops a Python Software Development Kit(SDK) which focuses on " + "connecting to OpenCAPIF (Common API Framework for 3GPP Northbound APIs) in a simple way, " + "lowering integration complexity and allowing developers to focus on Network Applications (Network Apps) or services development." + ), + long_description=open("./doc/README_pipy.md").read(), + long_description_content_type="text/markdown", + license="LICENSE", + python_requires=">=3.9", + keywords=[ + "pesp_capif_sdk", "capif", "sdk capif", "opencapif_sdk" + ], + classifiers=[ + "Programming Language :: Python :: 3", + "Operating System :: OS Independent", + ], + packages=find_packages(), + install_requires=[ + "requests==2.32.3", + "PyYAML==6.0.1", + "cryptography==38.0.4", + "pyOpenSSL==22.1.0", + "urllib3==2.2.2", + "certifi==2024.7.4", + "idna==3.7", + "Flask==3.0.3", + "Flask-JWT-Extended==4.6.0", + "Jinja2==3.1.4", + "MarkupSafe==2.1.5", + "six==1.16.0", + "typing-extensions>=4.8.0", + "Werkzeug==3.0.4", + "pytest==8.3.2", + "flake8==3.9.2", + "coverage==4.5.4", + "mccabe==0.6.1", + "pycodestyle==2.7.0", + "pyflakes==2.3.1", + "python-dateutil==2.9.0.post0", + "jinja2-time==0.2.0", + "text-unidecode==1.3", + "binaryornot==0.4.4", + ], + url="https://github.com/Telefonica/pesp_capif_sdk", +) -- GitLab From 73d59cb3a434e6cedf5d791a379e450e14b0a656 Mon Sep 17 00:00:00 2001 From: Jorge Echevarria Uribarri Date: Fri, 29 Nov 2024 12:59:10 +0100 Subject: [PATCH 02/24] Create python-publish.yml --- .github/workflows/python-publish.yml | 70 ++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/workflows/python-publish.yml diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..85ce499 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,70 @@ +# This workflow will upload a Python Package to PyPI when a release is created +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Upload Python Package + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + release-build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Build release distributions + run: | + # NOTE: put your own distribution build steps here. + python -m pip install build + python -m build + + - name: Upload distributions + uses: actions/upload-artifact@v4 + with: + name: release-dists + path: dist/ + + pypi-publish: + runs-on: ubuntu-latest + needs: + - release-build + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + + # Dedicated environments with protections for publishing are strongly recommended. + # For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules + environment: + name: pypi + # OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status: + # url: https://pypi.org/p/YOURPROJECT + # + # ALTERNATIVE: if your GitHub Release name is the PyPI project version string + # ALTERNATIVE: exactly, uncomment the following line instead: + url: https://pypi.org/project/opencapif-sdk/${{ github.event.release.name }} + + steps: + - name: Retrieve release distributions + uses: actions/download-artifact@v4 + with: + name: release-dists + path: dist/ + + - name: Publish release distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: dist/ -- GitLab From 67df8bd5dbb37b27b3a54a9542db5039627f21d6 Mon Sep 17 00:00:00 2001 From: JorgeEcheva26 Date: Fri, 29 Nov 2024 13:00:22 +0100 Subject: [PATCH 03/24] CI/CD test --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 92e13c6..d66f113 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="opencapif_sdk", - version="0.1.15", + version="0.1.16", author="JorgeEcheva, dgs-cgm", author_email="jorge.echevarriauribarri.practicas@telefonica.com, daniel.garciasanchez@telefonica.com", description=( -- GitLab From 9def63df96a6c02749d8a023f2c55b7386ed6535 Mon Sep 17 00:00:00 2001 From: JorgeEcheva26 Date: Fri, 29 Nov 2024 13:03:47 +0100 Subject: [PATCH 04/24] modified: .github/workflows/python-publish.yml --- .github/workflows/python-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 85ce499..c96f81f 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -51,7 +51,7 @@ jobs: environment: name: pypi # OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status: - # url: https://pypi.org/p/YOURPROJECT + # # ALTERNATIVE: if your GitHub Release name is the PyPI project version string # ALTERNATIVE: exactly, uncomment the following line instead: -- GitLab From 649c333d0b5b425420aa5daec64d73639bd4ddab Mon Sep 17 00:00:00 2001 From: JorgeEcheva26 Date: Fri, 29 Nov 2024 13:15:08 +0100 Subject: [PATCH 05/24] CI/CD test --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d66f113..4f8fe95 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( "connecting to OpenCAPIF (Common API Framework for 3GPP Northbound APIs) in a simple way, " "lowering integration complexity and allowing developers to focus on Network Applications (Network Apps) or services development." ), - long_description=open("./doc/README_pipy.md").read(), + long_description=open("doc/README_pipy.md").read(), long_description_content_type="text/markdown", license="LICENSE", python_requires=">=3.9", -- GitLab From 1198b535e477edbb4b792af07fb893845fa159a1 Mon Sep 17 00:00:00 2001 From: JorgeEcheva26 Date: Fri, 29 Nov 2024 13:19:59 +0100 Subject: [PATCH 06/24] Move readme_pip --- doc/README_pipy.md => README_pipy.md | 0 setup.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename doc/README_pipy.md => README_pipy.md (100%) diff --git a/doc/README_pipy.md b/README_pipy.md similarity index 100% rename from doc/README_pipy.md rename to README_pipy.md diff --git a/setup.py b/setup.py index 4f8fe95..8dc1db4 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( "connecting to OpenCAPIF (Common API Framework for 3GPP Northbound APIs) in a simple way, " "lowering integration complexity and allowing developers to focus on Network Applications (Network Apps) or services development." ), - long_description=open("doc/README_pipy.md").read(), + long_description=open("README_pipy.md").read(), long_description_content_type="text/markdown", license="LICENSE", python_requires=">=3.9", -- GitLab From f8e6e15a26ef84c35c44e7ade52ec3b2aa2fd25f Mon Sep 17 00:00:00 2001 From: JorgeEcheva26 Date: Fri, 29 Nov 2024 13:35:35 +0100 Subject: [PATCH 07/24] manifest --- MANIFEST.in | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..245e6aa --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +include README_pipy.md +include LICENSE \ No newline at end of file -- GitLab From 0cc3b7c1130f3730746ecc4cc15ea82a1ef451eb Mon Sep 17 00:00:00 2001 From: JorgeEcheva26 Date: Fri, 29 Nov 2024 13:42:26 +0100 Subject: [PATCH 08/24] setup --- setup.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 8dc1db4..6877edc 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,9 @@ from setuptools import setup, find_packages +import os + +this_directory = os.path.abspath(os.path.dirname(__file__)) +with open(os.path.join(this_directory, "README_pipy.md"), encoding="utf-8") as f: + long_description = f.read() setup( name="opencapif_sdk", @@ -10,7 +15,7 @@ setup( "connecting to OpenCAPIF (Common API Framework for 3GPP Northbound APIs) in a simple way, " "lowering integration complexity and allowing developers to focus on Network Applications (Network Apps) or services development." ), - long_description=open("README_pipy.md").read(), + long_description=long_description, long_description_content_type="text/markdown", license="LICENSE", python_requires=">=3.9", @@ -21,7 +26,7 @@ setup( "Programming Language :: Python :: 3", "Operating System :: OS Independent", ], - packages=find_packages(), + packages=find_packages(include=["opencapif_sdk", "opencapif_sdk.*"]), # Ajusta según tus necesidades install_requires=[ "requests==2.32.3", "PyYAML==6.0.1", -- GitLab From e25b521cff4ae9073d2d1d0959fc489e48063c57 Mon Sep 17 00:00:00 2001 From: Jorge Echevarria Uribarri Date: Mon, 2 Dec 2024 10:12:16 +0100 Subject: [PATCH 09/24] Create gitlab.yml --- .github/workflows/gitlab.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/gitlab.yml diff --git a/.github/workflows/gitlab.yml b/.github/workflows/gitlab.yml new file mode 100644 index 0000000..8b8fa51 --- /dev/null +++ b/.github/workflows/gitlab.yml @@ -0,0 +1,30 @@ +name: Sync GitHub to GitLab + +on: + push: + branches: + - develop # Se activa cuando hay cambios en la rama develop + +jobs: + sync: + runs-on: ubuntu-latest + + steps: + # 1. Checkout del código desde GitHub + - name: Checkout GitHub repository + uses: actions/checkout@v4 + + # 2. Configurar Git para empujar a GitLab + - name: Push to GitLab main + env: + GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }} + run: | + # Configurar Git + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + # Agregar el repositorio remoto de GitLab + git remote add gitlab https://oauth2:${GITLAB_TOKEN}@labs.etsi.org/rep/ocf/sdk.git + + # Forzar el push de la rama develop a main en GitLab + git push -u gitlab develop:main --force -- GitLab From ba9a07c8faf17f7990f0a54ae7488f301af448bf Mon Sep 17 00:00:00 2001 From: JorgeEcheva26 Date: Mon, 2 Dec 2024 10:16:18 +0100 Subject: [PATCH 10/24] empty configuration --- test/capif_sdk_config_sample_test.json | 54 +++++++++++++------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/test/capif_sdk_config_sample_test.json b/test/capif_sdk_config_sample_test.json index 49502a9..f91920e 100644 --- a/test/capif_sdk_config_sample_test.json +++ b/test/capif_sdk_config_sample_test.json @@ -1,27 +1,27 @@ { - "capif_host": "capif-prev.mobilesandbox.cloud", - "register_host": "registercapif-prev.mobilesandbox.cloud", - "capif_https_port": "36212", - "capif_register_port": "36211", - "capif_username": "echeva_0", - "capif_password": "echevapass", - "debug_mode": "True", + "capif_host": "", + "register_host": "", + "capif_https_port": "", + "capif_register_port": "", + "capif_username": "", + "capif_password": "", + "debug_mode": "", "invoker":{ - "invoker_folder": "/Users/IDB0128/Documents/OpenCapif/test_invoker_certificate_folder", - "capif_callback_url": "http://localhost:5000", - "supported_features":"fffffff", + "invoker_folder": "", + "capif_callback_url": "", + "supported_features":"", "check_authorization":{ "ip":"", "port":"" }, "cert_generation":{ - "csr_common_name": "Echeva", - "csr_organizational_unit": "discovery", - "csr_organization": "telefonica", - "csr_locality": "madrid", - "csr_state_or_province_name": "madrid", - "csr_country_name": "ES", - "csr_email_address": "adios@gmail.com" + "csr_common_name": "", + "csr_organizational_unit": "", + "csr_organization": "", + "csr_locality": "", + "csr_state_or_province_name": "", + "csr_country_name": "", + "csr_email_address": "" }, "discover_filter": { "api-name": "", @@ -40,18 +40,18 @@ } }, "provider":{ - "provider_folder": "/Users/IDB0128/Documents/OpenCapif/test_provider_certificate_folder", + "provider_folder": "", "cert_generation":{ - "csr_common_name": "provider", - "csr_organizational_unit": "discovery", - "csr_organization": "telefonica", - "csr_locality": "madrid", - "csr_state_or_province_name": "madrid", - "csr_country_name": "ES", - "csr_email_address": "hola@gmail.com" + "csr_common_name": "", + "csr_organizational_unit": "", + "csr_organization": "", + "csr_locality": "", + "csr_state_or_province_name": "", + "csr_country_name": "", + "csr_email_address": "" }, - "apfs": "2", - "aefs": "3", + "apfs": "", + "aefs": "", "publish_req": { "service_api_id": "", "publisher_apf_id": "", -- GitLab From ce660b078544e579c6a26b62c79644971f2dc5b7 Mon Sep 17 00:00:00 2001 From: Jorge Echevarria Uribarri Date: Mon, 2 Dec 2024 10:29:32 +0100 Subject: [PATCH 11/24] Update gitlab.yml --- .github/workflows/gitlab.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gitlab.yml b/.github/workflows/gitlab.yml index 8b8fa51..faa718a 100644 --- a/.github/workflows/gitlab.yml +++ b/.github/workflows/gitlab.yml @@ -27,4 +27,4 @@ jobs: git remote add gitlab https://oauth2:${GITLAB_TOKEN}@labs.etsi.org/rep/ocf/sdk.git # Forzar el push de la rama develop a main en GitLab - git push -u gitlab develop:main --force + git push -u gitlab develop:main -- GitLab From 6b9094c2e34cba95c8f63625ed57db7ef2ac3dbd Mon Sep 17 00:00:00 2001 From: Jorge Echevarria Uribarri Date: Mon, 2 Dec 2024 10:36:28 +0100 Subject: [PATCH 12/24] Update gitlab.yml --- .github/workflows/gitlab.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/gitlab.yml b/.github/workflows/gitlab.yml index faa718a..9ffac42 100644 --- a/.github/workflows/gitlab.yml +++ b/.github/workflows/gitlab.yml @@ -26,5 +26,11 @@ jobs: # Agregar el repositorio remoto de GitLab git remote add gitlab https://oauth2:${GITLAB_TOKEN}@labs.etsi.org/rep/ocf/sdk.git - # Forzar el push de la rama develop a main en GitLab + # Traer la última versión de main desde GitLab + git fetch gitlab main + + # Fusionar los cambios de main en develop (si es necesario) + git merge gitlab/main + + # Empujar los cambios de develop a main en GitLab git push -u gitlab develop:main -- GitLab From 4d56660e556a026c4f53871afb492cbad823f616 Mon Sep 17 00:00:00 2001 From: Jorge Echevarria Uribarri Date: Mon, 2 Dec 2024 10:44:52 +0100 Subject: [PATCH 13/24] Update gitlab.yml --- .github/workflows/gitlab.yml | 39 +++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/.github/workflows/gitlab.yml b/.github/workflows/gitlab.yml index 9ffac42..68ca39a 100644 --- a/.github/workflows/gitlab.yml +++ b/.github/workflows/gitlab.yml @@ -6,7 +6,7 @@ on: - develop # Se activa cuando hay cambios en la rama develop jobs: - sync: + create-merge-request: runs-on: ubuntu-latest steps: @@ -14,23 +14,26 @@ jobs: - name: Checkout GitHub repository uses: actions/checkout@v4 - # 2. Configurar Git para empujar a GitLab - - name: Push to GitLab main + # 2. Crear un Merge Request en GitLab + - name: Create Merge Request in GitLab env: GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }} run: | - # Configurar Git - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - - # Agregar el repositorio remoto de GitLab - git remote add gitlab https://oauth2:${GITLAB_TOKEN}@labs.etsi.org/rep/ocf/sdk.git - - # Traer la última versión de main desde GitLab - git fetch gitlab main - - # Fusionar los cambios de main en develop (si es necesario) - git merge gitlab/main - - # Empujar los cambios de develop a main en GitLab - git push -u gitlab develop:main + # Información del MR + PROJECT_ID="335" # Reemplaza con el ID del proyecto de GitLab + SOURCE_BRANCH="develop" + TARGET_BRANCH="main" + + # Crear el Merge Request usando la API de GitLab + curl -X POST \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $GITLAB_TOKEN" \ + -d '{ + "id": "'"${PROJECT_ID}"'", + "source_branch": "'"${SOURCE_BRANCH}"'", + "target_branch": "'"${TARGET_BRANCH}"'", + "title": "Sync develop to main", + "remove_source_branch": false, + "squash": false + }' \ + https://labs.etsi.org/api/v4/projects/${PROJECT_ID}/merge_requests -- GitLab From 2216a4e98b38e7c40ae4ec33c18db4d3bcdbbe67 Mon Sep 17 00:00:00 2001 From: JorgeEcheva26 Date: Mon, 2 Dec 2024 12:32:02 +0100 Subject: [PATCH 14/24] Supported features modification --- README.md | 1 + config/capif_sdk_config.json | 7 +++-- doc/sdk_configuration.md | 2 ++ .../capif_sdk_config_sample.json | 11 +++---- .../capif_sdk_config_sample.json | 28 +++++++++--------- opencapif_sdk/capif_invoker_connector.py | 2 +- opencapif_sdk/capif_provider_connector.py | 10 +++++-- samples/config_sample.json | 6 ++-- test/capif_sdk_config_sample_test.json | 29 ++++++++++--------- 9 files changed, 55 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 8406887..c1020b0 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,7 @@ Now, it is described in 4 simple steps how a Provider can be developed in just s provider.publish_req['publisher_apf_id'] = APF provider.publish_req['publisher_aefs_ids'] = [AEF1, AEF2] + provider.supported_features ="4" provider.publish_services() ``` diff --git a/config/capif_sdk_config.json b/config/capif_sdk_config.json index 34844f5..7096619 100644 --- a/config/capif_sdk_config.json +++ b/config/capif_sdk_config.json @@ -10,7 +10,7 @@ "invoker_folder": "", "capif_callback_url": "", "supported_features":"", - "check_authentication":{ + "check_authentication_data":{ "ip":"", "port":"" }, @@ -18,7 +18,7 @@ "csr_common_name": "", "csr_organizational_unit": "", "csr_organization": "", - "crs_locality": "", + "csr_locality": "", "csr_state_or_province_name": "", "csr_country_name": "", "csr_email_address": "" @@ -41,6 +41,7 @@ }, "provider": { "provider_folder": "", + "supported_features": "", "apfs": "", "aefs": "", "publish_req": { @@ -55,7 +56,7 @@ "csr_common_name": "", "csr_organizational_unit": "", "csr_organization": "", - "crs_locality": "", + "csr_locality": "", "csr_state_or_province_name": "", "csr_country_name": "", "csr_email_address": "" diff --git a/doc/sdk_configuration.md b/doc/sdk_configuration.md index d9193cb..97a3daf 100644 --- a/doc/sdk_configuration.md +++ b/doc/sdk_configuration.md @@ -43,6 +43,7 @@ When configuring the SDK as a **Network App Invoker**, the following fields must For SDK configuration as a **Network App Provider**, the following fields are required: - `provider_folder` +- `supported_features` - `cert_generation` (fields such as `csr_common_name`, `csr_country_name`, etc.) - `APFs` - `AEFs` @@ -80,6 +81,7 @@ This file can also be populated using [environment variables](../samples/envirom - `invoker_folder`: The path (relative or absolute) where invoker information (certificates, keys, etc.) is stored. - `provider_folder`: The path (relative or absolute) where provider information is stored. +- `supported_features`: A string used to indicate the features supported by an API. The string shall contain a bitmask indicating supported features in hexadecimal representation Each character in the string shall take a value of "0" to "9", "a" to "f" or "A" to "F". [More information](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29571_CommonData.yaml) - `capif_host`: The domain name of the CAPIF host. - `register_host`: The domain name of the register host. - `capif_https_port`: The CAPIF host port number. diff --git a/network_app_samples/network_app_invoker_sample/capif_sdk_config_sample.json b/network_app_samples/network_app_invoker_sample/capif_sdk_config_sample.json index c68a7ac..7096619 100644 --- a/network_app_samples/network_app_invoker_sample/capif_sdk_config_sample.json +++ b/network_app_samples/network_app_invoker_sample/capif_sdk_config_sample.json @@ -6,7 +6,7 @@ "capif_username": "", "capif_password": "", "debug_mode": "", - "invoker":{ + "invoker": { "invoker_folder": "", "capif_callback_url": "", "supported_features":"", @@ -14,7 +14,7 @@ "ip":"", "port":"" }, - "cert_generation":{ + "cert_generation": { "csr_common_name": "", "csr_organizational_unit": "", "csr_organization": "", @@ -39,8 +39,9 @@ "service-kpis": "" } }, - "provider":{ + "provider": { "provider_folder": "", + "supported_features": "", "apfs": "", "aefs": "", "publish_req": { @@ -51,7 +52,7 @@ "" ] }, - "cert_generation":{ + "cert_generation": { "csr_common_name": "", "csr_organizational_unit": "", "csr_organization": "", @@ -61,5 +62,5 @@ "csr_email_address": "" }, "api_description_path": "" - } + } } diff --git a/network_app_samples/network_app_provider_sample/capif_sdk_config_sample.json b/network_app_samples/network_app_provider_sample/capif_sdk_config_sample.json index f2c2c79..e6127a9 100644 --- a/network_app_samples/network_app_provider_sample/capif_sdk_config_sample.json +++ b/network_app_samples/network_app_provider_sample/capif_sdk_config_sample.json @@ -6,14 +6,15 @@ "capif_username": "", "capif_password": "", "debug_mode": "", - "invoker":{ + "invoker": { "invoker_folder": "", "capif_callback_url": "", + "supported_features":"", "check_authentication_data":{ "ip":"", "port":"" }, - "cert_generation":{ + "cert_generation": { "csr_common_name": "", "csr_organizational_unit": "", "csr_organization": "", @@ -38,17 +39,9 @@ "service-kpis": "" } }, - "provider":{ + "provider": { "provider_folder": "", - "cert_generation":{ - "csr_common_name": "", - "csr_organizational_unit": "", - "csr_organization": "", - "csr_locality": "", - "csr_state_or_province_name": "", - "csr_country_name": "", - "csr_email_address": "" - }, + "supported_features": "", "apfs": "2", "aefs": "3", "publish_req": { @@ -59,6 +52,15 @@ "" ] }, + "cert_generation": { + "csr_common_name": "", + "csr_organizational_unit": "", + "csr_organization": "", + "csr_locality": "", + "csr_state_or_province_name": "", + "csr_country_name": "", + "csr_email_address": "" + }, "api_description_path": "" - } + } } diff --git a/opencapif_sdk/capif_invoker_connector.py b/opencapif_sdk/capif_invoker_connector.py index 528fb75..3e4e78f 100644 --- a/opencapif_sdk/capif_invoker_connector.py +++ b/opencapif_sdk/capif_invoker_connector.py @@ -82,7 +82,7 @@ class capif_invoker_connector: capif_invoker_password = os.getenv('CAPIF_PASSWORD', config.get('capif_password', '')).strip() capif_callback_url = os.getenv('INVOKER_CAPIF_CALLBACK_URL', invoker_config.get('capif_callback_url', '')).strip() - supported_features = os.getenv('INVOKER_FOLDER', invoker_config.get('supported_features', '')).strip() + supported_features = os.getenv('INVOKER_SUPPORTED_FEATURES', invoker_config.get('supported_features', '')).strip() check_authentication_data = invoker_config.get('check_authentication_data', {}) self.check_authentication = { "ip": os.getenv('INVOKER_CHECK_AUTHENTICATION_DATA_IP', check_authentication_data.get('ip', '')).strip(), diff --git a/opencapif_sdk/capif_provider_connector.py b/opencapif_sdk/capif_provider_connector.py index c96578e..9ea6a5b 100644 --- a/opencapif_sdk/capif_provider_connector.py +++ b/opencapif_sdk/capif_provider_connector.py @@ -99,6 +99,10 @@ class capif_provider_connector: csr_email_address = os.getenv('PROVIDER_CSR_EMAIL_ADDRESS', cert_generation.get('csr_email_address', '')).strip() # Retrieve provider specific values (APFs, AEFs) + supported_features = os.getenv('PROVIDER_SUPPORTED_FEATURES', provider_config.get('supported_features', '')).strip() + if not supported_features: + supported_features = "0" + apfs = os.getenv('PROVIDER_APFS', provider_config.get('apfs', '')).strip() aefs = os.getenv('PROVIDER_AEFS', provider_config.get('aefs', '')).strip() api_description_path = os.path.abspath(os.getenv('PROVIDER_API_DESCRIPTION_PATH', provider_config.get('api_description_path', '')).strip()) @@ -127,6 +131,7 @@ class capif_provider_connector: self.csr_state_or_province_name = csr_state_or_province_name self.csr_country_name = csr_country_name self.csr_email_address = csr_email_address + self.supported_features = supported_features self.aefs = int(aefs) self.apfs = int(apfs) @@ -276,7 +281,7 @@ class capif_provider_connector: for role in roles ], "apiProvDomInfo": "This is provider", - "suppFeat": "fff", + "suppFeat": self.supported_features, "failReason": "string", "regSec": access_token, } @@ -452,6 +457,7 @@ class capif_provider_connector: with open(service_api_description_json_full_path, "r") as service_file: data = json.load(service_file) + data["supportedFeatures"] = self.supported_features # Verifying that the number of AEFs is equal to the aefProfiles if len(AEFs_list) != len(data.get("aefProfiles", [])): self.logger.error( @@ -1262,7 +1268,7 @@ class capif_provider_connector: for role in roles ], "apiProvDomInfo": "This is provider", - "suppFeat": "fff", + "suppFeat": self.supported_features, "failReason": "string", "regSec": access_token, } diff --git a/samples/config_sample.json b/samples/config_sample.json index 1a75d7d..7096619 100644 --- a/samples/config_sample.json +++ b/samples/config_sample.json @@ -39,9 +39,9 @@ "service-kpis": "" } }, - "provider": { "provider_folder": "", + "supported_features": "", "apfs": "", "aefs": "", "publish_req": { @@ -52,7 +52,7 @@ "" ] }, - "cert_generation":{ + "cert_generation": { "csr_common_name": "", "csr_organizational_unit": "", "csr_organization": "", @@ -62,5 +62,5 @@ "csr_email_address": "" }, "api_description_path": "" - } + } } diff --git a/test/capif_sdk_config_sample_test.json b/test/capif_sdk_config_sample_test.json index f91920e..7096619 100644 --- a/test/capif_sdk_config_sample_test.json +++ b/test/capif_sdk_config_sample_test.json @@ -6,15 +6,15 @@ "capif_username": "", "capif_password": "", "debug_mode": "", - "invoker":{ + "invoker": { "invoker_folder": "", "capif_callback_url": "", "supported_features":"", - "check_authorization":{ + "check_authentication_data":{ "ip":"", "port":"" }, - "cert_generation":{ + "cert_generation": { "csr_common_name": "", "csr_organizational_unit": "", "csr_organization": "", @@ -39,17 +39,9 @@ "service-kpis": "" } }, - "provider":{ + "provider": { "provider_folder": "", - "cert_generation":{ - "csr_common_name": "", - "csr_organizational_unit": "", - "csr_organization": "", - "csr_locality": "", - "csr_state_or_province_name": "", - "csr_country_name": "", - "csr_email_address": "" - }, + "supported_features": "", "apfs": "", "aefs": "", "publish_req": { @@ -60,6 +52,15 @@ "" ] }, + "cert_generation": { + "csr_common_name": "", + "csr_organizational_unit": "", + "csr_organization": "", + "csr_locality": "", + "csr_state_or_province_name": "", + "csr_country_name": "", + "csr_email_address": "" + }, "api_description_path": "" - } + } } -- GitLab From bb8b23d591b4a923fa739e339ec66b216c168f52 Mon Sep 17 00:00:00 2001 From: JorgeEcheva26 Date: Mon, 2 Dec 2024 12:54:01 +0100 Subject: [PATCH 15/24] pip readme --- README_pipy.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README_pipy.md b/README_pipy.md index 57eacbc..908a9e2 100644 --- a/README_pipy.md +++ b/README_pipy.md @@ -101,6 +101,7 @@ When configuring the SDK as a **Network App Invoker**, the following fields must For SDK configuration as a **Network App Provider**, the following fields are required: - `provider_folder` +- `suported_features` - `cert_generation` (fields such as `csr_common_name`, `csr_country_name`, etc.) - `APFs` - `AEFs` @@ -133,10 +134,9 @@ If the `publisher_aefs_ids` do not match the `aefProfiles` in the API descriptio ## Descriptions of `capif_sdk_config` Fields -This file can also be populated using [environment variables](../samples/enviroment_variables_sample.txt). - - `invoker_folder`: The path (relative or absolute) where invoker information (certificates, keys, etc.) is stored. - `provider_folder`: The path (relative or absolute) where provider information is stored. +- `supported_features`: A string used to indicate the features supported by an API. The string shall contain a bitmask indicating supported features in hexadecimal representation Each character in the string shall take a value of "0" to "9", "a" to "f" or "A" to "F". [More information](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29571_CommonData.yaml) - `capif_host`: The domain name of the CAPIF host. - `register_host`: The domain name of the register host. - `capif_https_port`: The CAPIF host port number. @@ -148,8 +148,8 @@ This file can also be populated using [environment variables](../samples/envirom - `apfs`: The number of APFs to be onboarded as a provider (e.g., `5`). - `aefs`: The number of AEFs to be onboarded as a provider (e.g., `2`). - `debug_mode`: A boolean value to enable or disable SDK logs (e.g., `True` or `False`). -- `discover_filter`: Fields for configuring invoker service discovery. -- `publish_req`: Fields required for API publishing. +- [`discover_filter`](#configuration-of-discover_filter): Fields for configuring invoker service discovery. +- [`publish_req`](#configuration-of-publish_req): Fields required for API publishing. - `api_description_path`: The path to the [ServiceAPIDescription](https://github.com/jdegre/5GC_APIs/blob/Rel-18/TS29222_CAPIF_Publish_Service_API.yaml) JSON file. - `check_authentication_data`: The `ip` and `port` of the target Provider's AEF to get their supported features from. -- GitLab From 073d85174e70808971fe0da26d5d7f8748391f13 Mon Sep 17 00:00:00 2001 From: JorgeEcheva26 Date: Mon, 2 Dec 2024 13:01:04 +0100 Subject: [PATCH 16/24] version 0.1.17 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6877edc..ece18da 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with open(os.path.join(this_directory, "README_pipy.md"), encoding="utf-8") as f setup( name="opencapif_sdk", - version="0.1.16", + version="0.1.17", author="JorgeEcheva, dgs-cgm", author_email="jorge.echevarriauribarri.practicas@telefonica.com, daniel.garciasanchez@telefonica.com", description=( -- GitLab From 99e3b4fbeebd59aedd66846e7b1c82621157929a Mon Sep 17 00:00:00 2001 From: JorgeEcheva26 Date: Tue, 3 Dec 2024 09:22:33 +0100 Subject: [PATCH 17/24] Interface description and support features --- opencapif_sdk/capif_invoker_connector.py | 4 ++-- opencapif_sdk/capif_provider_connector.py | 2 +- opencapif_sdk/service_discoverer.py | 16 +++++++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/opencapif_sdk/capif_invoker_connector.py b/opencapif_sdk/capif_invoker_connector.py index 3e4e78f..6a159f1 100644 --- a/opencapif_sdk/capif_invoker_connector.py +++ b/opencapif_sdk/capif_invoker_connector.py @@ -325,7 +325,7 @@ class capif_invoker_connector: url = self.capif_https_url + capif_onboarding_url payload_dict = { "notificationDestination": self.capif_callback_url, - "supportedFeatures": self.supported_features, + "supportedFeatures": f"{self.supported_features}", "apiInvokerInformation": self.csr_common_name, "websockNotifConfig": { "requestWebsocketUri": True, @@ -429,7 +429,7 @@ class capif_invoker_connector: url = self.capif_https_url + capif_onboarding_url + "/" + invokerid payload_dict = { "notificationDestination": self.capif_callback_url, - "supportedFeatures": self.supported_features, + "supportedFeatures": f"{self.supported_features}", "apiInvokerInformation": self.csr_common_name, "websockNotifConfig": { "requestWebsocketUri": True, diff --git a/opencapif_sdk/capif_provider_connector.py b/opencapif_sdk/capif_provider_connector.py index 9ea6a5b..e7d6576 100644 --- a/opencapif_sdk/capif_provider_connector.py +++ b/opencapif_sdk/capif_provider_connector.py @@ -457,7 +457,7 @@ class capif_provider_connector: with open(service_api_description_json_full_path, "r") as service_file: data = json.load(service_file) - data["supportedFeatures"] = self.supported_features + data["supportedFeatures"] = f"{self.supported_features}" # Verifying that the number of AEFs is equal to the aefProfiles if len(AEFs_list) != len(data.get("aefProfiles", [])): self.logger.error( diff --git a/opencapif_sdk/service_discoverer.py b/opencapif_sdk/service_discoverer.py index 9f079a1..6b1c8eb 100644 --- a/opencapif_sdk/service_discoverer.py +++ b/opencapif_sdk/service_discoverer.py @@ -213,7 +213,7 @@ class service_discoverer: "websocketUri": "string", "requestWebsocketUri": True }, - "supportedFeatures": "fff" + "supportedFeatures": f"{self.supported_features}" } number_of_apis = len( @@ -225,8 +225,18 @@ class service_discoverer: api_id = self.invoker_capif_details["registered_security_contexes"][i]['api_id'] for n in range(0, len(aef_profiles)): aef_id = self.invoker_capif_details["registered_security_contexes"][i]['aef_profiles'][n]['aef_id'] - + ip = self.invoker_capif_details["registered_security_contexes"][i]['aef_profiles'][n]['ip'] + port = self.invoker_capif_details["registered_security_contexes"][i]['aef_profiles'][n]['port'] security_info = { + "interfaceDescriptions": [ + { + "ipv4Addr": ip, + "port": port, + "securityMethods": [ + "Oauth" + ] + } + ], "prefSecurityMethods": ["Oauth"], "authenticationInfo": "string", "authorizationInfo": "string", @@ -274,7 +284,7 @@ class service_discoverer: "websocketUri": "string", "requestWebsocketUri": True }, - "supportedFeatures": "fff" + "supportedFeatures": f"{self.supported_features}" } number_of_apis = len( -- GitLab From 4da4e12c22f0e57ff1ce1a83e282a7b33c2360ce Mon Sep 17 00:00:00 2001 From: JorgeEcheva26 Date: Tue, 3 Dec 2024 09:26:49 +0100 Subject: [PATCH 18/24] version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ece18da..b3a2a98 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with open(os.path.join(this_directory, "README_pipy.md"), encoding="utf-8") as f setup( name="opencapif_sdk", - version="0.1.17", + version="0.1.17.1", author="JorgeEcheva, dgs-cgm", author_email="jorge.echevarriauribarri.practicas@telefonica.com, daniel.garciasanchez@telefonica.com", description=( -- GitLab From 950310d7fcb768d2e3955c3a016f95d6517b6f0c Mon Sep 17 00:00:00 2001 From: JorgeEcheva26 Date: Tue, 3 Dec 2024 09:37:24 +0100 Subject: [PATCH 19/24] interfaceDetails --- opencapif_sdk/service_discoverer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opencapif_sdk/service_discoverer.py b/opencapif_sdk/service_discoverer.py index 6b1c8eb..ed78986 100644 --- a/opencapif_sdk/service_discoverer.py +++ b/opencapif_sdk/service_discoverer.py @@ -228,7 +228,7 @@ class service_discoverer: ip = self.invoker_capif_details["registered_security_contexes"][i]['aef_profiles'][n]['ip'] port = self.invoker_capif_details["registered_security_contexes"][i]['aef_profiles'][n]['port'] security_info = { - "interfaceDescriptions": [ + "interfaceDetails": [ { "ipv4Addr": ip, "port": port, -- GitLab From 92f5102a23b6fd3b96fe3658d75746789571e5d3 Mon Sep 17 00:00:00 2001 From: JorgeEcheva26 Date: Tue, 3 Dec 2024 09:38:34 +0100 Subject: [PATCH 20/24] version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b3a2a98..d80ec6b 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with open(os.path.join(this_directory, "README_pipy.md"), encoding="utf-8") as f setup( name="opencapif_sdk", - version="0.1.17.1", + version="0.1.17.2", author="JorgeEcheva, dgs-cgm", author_email="jorge.echevarriauribarri.practicas@telefonica.com, daniel.garciasanchez@telefonica.com", description=( -- GitLab From a75462d49efaa3d4a8704714c99ffab5112ac662 Mon Sep 17 00:00:00 2001 From: JorgeEcheva26 Date: Tue, 3 Dec 2024 09:57:13 +0100 Subject: [PATCH 21/24] changes --- opencapif_sdk/service_discoverer.py | 2 ++ setup.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/opencapif_sdk/service_discoverer.py b/opencapif_sdk/service_discoverer.py index ed78986..d913189 100644 --- a/opencapif_sdk/service_discoverer.py +++ b/opencapif_sdk/service_discoverer.py @@ -231,6 +231,8 @@ class service_discoverer: "interfaceDetails": [ { "ipv4Addr": ip, + "ipv6Addr": "string", + "fqdn": "string", "port": port, "securityMethods": [ "Oauth" diff --git a/setup.py b/setup.py index d80ec6b..85a43dc 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with open(os.path.join(this_directory, "README_pipy.md"), encoding="utf-8") as f setup( name="opencapif_sdk", - version="0.1.17.2", + version="0.1.17.3", author="JorgeEcheva, dgs-cgm", author_email="jorge.echevarriauribarri.practicas@telefonica.com, daniel.garciasanchez@telefonica.com", description=( -- GitLab From 199d1aa8c163a5eb26c7c2cbb1ae51be573900a7 Mon Sep 17 00:00:00 2001 From: JorgeEcheva26 Date: Tue, 3 Dec 2024 13:07:41 +0100 Subject: [PATCH 22/24] OAUTH --- .../nef_upf_vendor_1.json | 8 +++---- .../nef_upf_vendor_2.json | 12 +++++----- opencapif_sdk/api_schema_translator.py | 4 ++-- opencapif_sdk/service_discoverer.py | 22 ++++--------------- samples/provider_api_description_sample.json | 8 +++---- test/network_app_provider_api_spec_2.json | 12 +++++----- test/network_app_provider_api_spec_3.json | 8 +++---- 7 files changed, 30 insertions(+), 44 deletions(-) diff --git a/network_app_samples/network_app_provider_sample/nef_upf_vendor_1.json b/network_app_samples/network_app_provider_sample/nef_upf_vendor_1.json index 8cc2fa4..58ceb6f 100755 --- a/network_app_samples/network_app_provider_sample/nef_upf_vendor_1.json +++ b/network_app_samples/network_app_provider_sample/nef_upf_vendor_1.json @@ -143,14 +143,14 @@ "protocol": "HTTP_1_1", "dataFormat": "JSON", "securityMethods": [ - "Oauth" + "OAUTH" ], "interfaceDescriptions": [ { "ipv4Addr": "localhost", "port": 8088, "securityMethods": [ - "Oauth" + "OAUTH" ] } ] @@ -297,7 +297,7 @@ "protocol": "HTTP_1_1", "dataFormat": "JSON", "securityMethods": [ - "Oauth", + "OAUTH", "PSK" ], "interfaceDescriptions": [ @@ -305,7 +305,7 @@ "ipv4Addr": "localhost", "port": 8088, "securityMethods": [ - "Oauth" + "OAUTH" ] } ] diff --git a/network_app_samples/network_app_provider_sample/nef_upf_vendor_2.json b/network_app_samples/network_app_provider_sample/nef_upf_vendor_2.json index 5feec72..5930f5c 100755 --- a/network_app_samples/network_app_provider_sample/nef_upf_vendor_2.json +++ b/network_app_samples/network_app_provider_sample/nef_upf_vendor_2.json @@ -127,7 +127,7 @@ "protocol": "HTTP_1_1", "dataFormat": "JSON", "securityMethods": [ - "Oauth", + "OAUTH", "PSK" ], "interfaceDescriptions": [ @@ -135,7 +135,7 @@ "ipv4Addr": "localhost", "port": 8888, "securityMethods": [ - "Oauth" + "OAUTH" ] } ] @@ -283,14 +283,14 @@ "protocol": "HTTP_1_1", "dataFormat": "JSON", "securityMethods": [ - "Oauth" + "OAUTH" ], "interfaceDescriptions": [ { "ipv4Addr": "localhost", "port": 8888, "securityMethods": [ - "Oauth" + "OAUTH" ] } ] @@ -421,7 +421,7 @@ "protocol": "HTTP_1_1", "dataFormat": "JSON", "securityMethods": [ - "Oauth", + "OAUTH", "PSK" ], "interfaceDescriptions": [ @@ -429,7 +429,7 @@ "ipv4Addr": "localhost", "port": 8888, "securityMethods": [ - "Oauth" + "OAUTH" ] } ] diff --git a/opencapif_sdk/api_schema_translator.py b/opencapif_sdk/api_schema_translator.py index 7e29a76..1251990 100644 --- a/opencapif_sdk/api_schema_translator.py +++ b/opencapif_sdk/api_schema_translator.py @@ -143,12 +143,12 @@ class api_schema_translator: ], "protocol": "HTTP_1_1", "dataFormat": "JSON", - "securityMethods": ["Oauth"], + "securityMethods": ["OAUTH"], "interfaceDescriptions": [ { "ipv4Addr": ip, "port": port, - "securityMethods": ["Oauth"] + "securityMethods": ["OAUTH"] } ] } diff --git a/opencapif_sdk/service_discoverer.py b/opencapif_sdk/service_discoverer.py index d913189..d3ccfd7 100644 --- a/opencapif_sdk/service_discoverer.py +++ b/opencapif_sdk/service_discoverer.py @@ -225,21 +225,9 @@ class service_discoverer: api_id = self.invoker_capif_details["registered_security_contexes"][i]['api_id'] for n in range(0, len(aef_profiles)): aef_id = self.invoker_capif_details["registered_security_contexes"][i]['aef_profiles'][n]['aef_id'] - ip = self.invoker_capif_details["registered_security_contexes"][i]['aef_profiles'][n]['ip'] - port = self.invoker_capif_details["registered_security_contexes"][i]['aef_profiles'][n]['port'] + security_info = { - "interfaceDetails": [ - { - "ipv4Addr": ip, - "ipv6Addr": "string", - "fqdn": "string", - "port": port, - "securityMethods": [ - "Oauth" - ] - } - ], - "prefSecurityMethods": ["Oauth"], + "prefSecurityMethods": ["OAUTH"], "authenticationInfo": "string", "authorizationInfo": "string", "aefId": aef_id, @@ -298,9 +286,8 @@ class service_discoverer: api_id = self.invoker_capif_details["registered_security_contexes"][i]['api_id'] for n in range(0, len(aef_profiles)): aef_id = self.invoker_capif_details["registered_security_contexes"][i]['aef_profiles'][n]['aef_id'] - security_info = { - "prefSecurityMethods": ["Oauth"], + "prefSecurityMethods": ["OAUTH"], "authenticationInfo": "string", "authorizationInfo": "string", "aefId": aef_id, @@ -308,9 +295,8 @@ class service_discoverer: } payload["securityInfo"].append(security_info) - payload["securityInfo"].append(security_info) - try: + print(payload) response = requests.put(url, json=payload, cert=(self.signed_key_crt_path, diff --git a/samples/provider_api_description_sample.json b/samples/provider_api_description_sample.json index 02d872f..9544269 100755 --- a/samples/provider_api_description_sample.json +++ b/samples/provider_api_description_sample.json @@ -47,14 +47,14 @@ "protocol": "HTTP_1_1", "dataFormat": "JSON", "securityMethods": [ - "Oauth" + "OAUTH" ], "interfaceDescriptions": [ { "ipv4Addr": "127.0.0.1", "port": 8888, "securityMethods": [ - "Oauth" + "OAUTH" ] } ] @@ -122,14 +122,14 @@ "protocol": "HTTP_1_1", "dataFormat": "JSON", "securityMethods": [ - "Oauth" + "OAUTH" ], "interfaceDescriptions": [ { "ipv4Addr": "127.0.0.1", "port": 8899, "securityMethods": [ - "Oauth" + "OAUTH" ] } ] diff --git a/test/network_app_provider_api_spec_2.json b/test/network_app_provider_api_spec_2.json index 0d54904..94175bd 100755 --- a/test/network_app_provider_api_spec_2.json +++ b/test/network_app_provider_api_spec_2.json @@ -47,7 +47,7 @@ "protocol": "HTTP_1_1", "dataFormat": "JSON", "securityMethods": [ - "Oauth", + "OAUTH", "PSK" ], "interfaceDescriptions": [ @@ -55,7 +55,7 @@ "ipv4Addr": "127.0.0.1", "port": 8888, "securityMethods": [ - "Oauth" + "OAUTH" ] } ] @@ -123,14 +123,14 @@ "protocol": "HTTP_1_1", "dataFormat": "JSON", "securityMethods": [ - "Oauth" + "OAUTH" ], "interfaceDescriptions": [ { "ipv4Addr": "127.0.0.1", "port": 8899, "securityMethods": [ - "Oauth" + "OAUTH" ] } ] @@ -181,7 +181,7 @@ "protocol": "HTTP_1_1", "dataFormat": "JSON", "securityMethods": [ - "Oauth", + "OAUTH", "PSK" ], "interfaceDescriptions": [ @@ -189,7 +189,7 @@ "ipv4Addr": "127.0.0.1", "port": 8888, "securityMethods": [ - "Oauth" + "OAUTH" ] } ] diff --git a/test/network_app_provider_api_spec_3.json b/test/network_app_provider_api_spec_3.json index 548b740..7b9fbe4 100755 --- a/test/network_app_provider_api_spec_3.json +++ b/test/network_app_provider_api_spec_3.json @@ -47,7 +47,7 @@ "protocol": "HTTP_1_1", "dataFormat": "JSON", "securityMethods": [ - "Oauth", + "OAUTH", "PSK" ], "interfaceDescriptions": [ @@ -55,7 +55,7 @@ "ipv4Addr": "127.0.0.1", "port": 8888, "securityMethods": [ - "Oauth" + "OAUTH" ] } ] @@ -123,14 +123,14 @@ "protocol": "HTTP_1_1", "dataFormat": "JSON", "securityMethods": [ - "Oauth" + "OAUTH" ], "interfaceDescriptions": [ { "ipv4Addr": "127.0.0.1", "port": 8899, "securityMethods": [ - "Oauth" + "OAUTH" ] } ] -- GitLab From f087990b44c750aa5432b8c073735f290d50bb8a Mon Sep 17 00:00:00 2001 From: JorgeEcheva26 Date: Wed, 4 Dec 2024 11:10:57 +0100 Subject: [PATCH 23/24] Fix error related to check-authentication and revoke-authenticacion. Little modifications in OAUTH configuration --- opencapif_sdk/capif_provider_connector.py | 102 ++++++++++++---------- opencapif_sdk/service_discoverer.py | 4 - test/network_app_provider_api_spec.json | 8 +- test/test.py | 2 + 4 files changed, 62 insertions(+), 54 deletions(-) diff --git a/opencapif_sdk/capif_provider_connector.py b/opencapif_sdk/capif_provider_connector.py index e7d6576..a875bd8 100644 --- a/opencapif_sdk/capif_provider_connector.py +++ b/opencapif_sdk/capif_provider_connector.py @@ -466,41 +466,45 @@ class capif_provider_connector: "Mismatch between number of AEFs and profiles") # Assigning each AEF + for profile, aef_id in zip(data.get("aefProfiles", []), AEFs_list): - profile["aefId"] = aef_id - for versions in profile["versions"]: - check = True - revoke = True - for custom in versions["custOperations"]: - if custom["custOpName"] == "check-authentication": - check = False - if custom["custOpName"] == "revoke-authentication": - revoke = False - # Si ambas condiciones ya son falsas, salir del bucle - if not check and not revoke: - break - # If 'check-authentication' custom operation doesn't exist, add it - if check: - versions["custOperations"].append({ + if not isinstance(profile, dict): # Verificar que profile sea un diccionario + raise TypeError(f"Expected profile to be a dict, got {type(profile).__name__}") + + profile["aefId"] = aef_id # Asignar el ID de AEF + + versions = profile.get("versions") # Obtener versions + + i = 1 + for version in versions: # Iterar sobre cada versión + if not isinstance(version, dict): # Verificar que cada versión sea un diccionario + raise TypeError(f"Expected each version to be a dict, got {type(version).__name__}") + + # Obtener nombres existentes de operaciones personalizadas + existing_operations = { + op["custOpName"].strip() + for op in version.get("custOperations", []) if isinstance(op, dict) + } + + # Verificar y agregar `check-authentication` si no existe + if "check-authentication" not in existing_operations and i == 1: + version.setdefault("custOperations", []).append({ "commType": "REQUEST_RESPONSE", "custOpName": "check-authentication", - "operations": [ - "POST" - ], + "operations": ["POST"], "description": "Check authentication request." }) - # If 'revoke-authentication' custom operation doesn't exist, add it - if revoke: - versions["custOperations"].append({ + # Verificar y agregar `revoke-authentication` si no existe + if "revoke-authentication" not in existing_operations and i == 1: + version.setdefault("custOperations", []).append({ "commType": "REQUEST_RESPONSE", "custOpName": "revoke-authentication", - "operations": [ - "POST" - ], + "operations": ["POST"], "description": "Revoke authorization for service APIs." }) - + i -= 1 + self.logger.info( "Service API description modified successfully") @@ -907,36 +911,42 @@ class capif_provider_connector: # Asing the chosen AEFs for profile, aef_id in zip(data.get("aefProfiles", []), AEFs_list): - profile["aefId"] = aef_id - for versions in profile["versions"]: - for custom in versions["custOperations"]: - check = True - revoke = True - if custom["custOpName"] == "check-authentication": - check = False - if custom["custOpName"] == "revoke-authentication ": - revoke = False - # If 'check-authentication' custom operation doesn't exist, add it - if check: - versions["custOperations"].append({ + if not isinstance(profile, dict): # Verificar que profile sea un diccionario + raise TypeError(f"Expected profile to be a dict, got {type(profile).__name__}") + + profile["aefId"] = aef_id # Asignar el ID de AEF + + versions = profile.get("versions") # Obtener versions + i = 1 + for version in versions: # Iterar sobre cada versión + if not isinstance(version, dict): # Verificar que cada versión sea un diccionario + raise TypeError(f"Expected each version to be a dict, got {type(version).__name__}") + + # Obtener nombres existentes de operaciones personalizadas + existing_operations = { + op["custOpName"].strip() + for op in version.get("custOperations", []) if isinstance(op, dict) + } + + # Verificar y agregar `check-authentication` si no existe + if "check-authentication" not in existing_operations and i == 1: + version.setdefault("custOperations", []).append({ "commType": "REQUEST_RESPONSE", "custOpName": "check-authentication", - "operations": [ - "POST" - ], + "operations": ["POST"], "description": "Check authentication request." }) - # If 'revoke-authentication' custom operation doesn't exist, add it - if revoke: - versions["custOperations"].append({ + # Verificar y agregar `revoke-authentication` si no existe + if "revoke-authentication" not in existing_operations and i == 1: + version.setdefault("custOperations", []).append({ "commType": "REQUEST_RESPONSE", "custOpName": "revoke-authentication", - "operations": [ - "POST" - ], + "operations": ["POST"], "description": "Revoke authorization for service APIs." }) + i -= 1 + self.logger.info( "Service API description modified successfully") diff --git a/opencapif_sdk/service_discoverer.py b/opencapif_sdk/service_discoverer.py index d3ccfd7..6272e94 100644 --- a/opencapif_sdk/service_discoverer.py +++ b/opencapif_sdk/service_discoverer.py @@ -296,7 +296,6 @@ class service_discoverer: payload["securityInfo"].append(security_info) try: - print(payload) response = requests.put(url, json=payload, cert=(self.signed_key_crt_path, @@ -507,7 +506,6 @@ class service_discoverer: raise def check_authentication(self): - print("hola") self.logger.info("Checking authentication") try: invoker_details = self.__load_provider_api_details() @@ -519,7 +517,6 @@ class service_discoverer: "apiInvokerId": f"{invoker_id}", "supportedFeatures": f"{self.supported_features}" } - print(self.supported_features) headers = { "Authorization": "Bearer {}".format(self.token), @@ -533,7 +530,6 @@ class service_discoverer: json=payload ) - print(response.text) response.raise_for_status() self.logger.info("Authentication of supported_features checked") diff --git a/test/network_app_provider_api_spec.json b/test/network_app_provider_api_spec.json index 9672934..5cf4065 100755 --- a/test/network_app_provider_api_spec.json +++ b/test/network_app_provider_api_spec.json @@ -47,7 +47,7 @@ "protocol": "HTTP_1_1", "dataFormat": "JSON", "securityMethods": [ - "Oauth", + "OAUTH", "PSK" ], "interfaceDescriptions": [ @@ -55,7 +55,7 @@ "ipv4Addr": "127.0.0.1", "port": 8888, "securityMethods": [ - "Oauth" + "OAUTH" ] } ] @@ -123,14 +123,14 @@ "protocol": "HTTP_1_1", "dataFormat": "JSON", "securityMethods": [ - "Oauth" + "OAUTH" ], "interfaceDescriptions": [ { "ipv4Addr": "127.0.0.1", "port": 8899, "securityMethods": [ - "Oauth" + "OAUTH" ] } ] diff --git a/test/test.py b/test/test.py index 143558a..7332dc6 100644 --- a/test/test.py +++ b/test/test.py @@ -119,6 +119,8 @@ if __name__ == "__main__": print("INVOKER ONBOARDING COMPLETED") discoverer = service_discoverer(config_file=capif_sdk_config_path) + + discoverer.discover_filter["api-name"]= "Testtrece" discoverer.discover() -- GitLab From 0ab27a296ad25e01be20cbd1fb52de2952c247a1 Mon Sep 17 00:00:00 2001 From: sattij Date: Mon, 9 Dec 2024 08:54:32 +0000 Subject: [PATCH 24/24] Update LICENSE to replace ETSI long-form name by acronym --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 8d4113a..9f55c85 100644 --- a/LICENSE +++ b/LICENSE @@ -189,7 +189,7 @@ Copyright (c) 2021, Stavros Kolometsos Copyright (c) 2022, Telefónica Innovación Digital Copyright (c) 2022, Fogus Innovations & Services P.C. - Copyright (c) 2024, European Telecommunications Standards Institute (ETSI) + Copyright (c) 2024, ETSI Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. -- GitLab