diff --git a/ci_cd_test/Dockerfile b/ci_cd_test/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..465cc1f3ae449fe95c212fbdd06b34fb58011389 --- /dev/null +++ b/ci_cd_test/Dockerfile @@ -0,0 +1,28 @@ +FROM labs.etsi.org:5050/ocf/capif/python:3-slim-bullseye + +RUN apt update +RUN apt update && apt install -y git nano && \ + rm -rf /var/lib/apt/lists/* + +ARG BRANCH=main + +RUN echo "Cloning branch: ${BRANCH}" && \ + git clone -b ${BRANCH} https://labs.etsi.org/rep/ocf/sdk.git + +WORKDIR /sdk + +RUN python -m pip install --upgrade pip +RUN pip install -r installation/requirements.txt +RUN pip install . + +# Ejecutar provider y luego invoker al iniciar el contenedor +ENTRYPOINT sh -c "\ + cd ci_cd_test/testing_samples/testing_provider_sample && \ + echo '🚀 Ejecutando provider...' && \ + python network_app_provider.py && \ + echo '✅ Provider finalizado.' && \ + cd ../testing_invoker_sample && \ + echo '🚀 Ejecutando invoker...' && \ + python network_app_invoker.py && \ + echo '✅ Invoker finalizado. Contenedor quedará activo.' && \ + tail -f /dev/null" \ No newline at end of file diff --git a/ci_cd_test/testing_samples/testing_invoker_sample/capif_sdk_config_sample.json b/ci_cd_test/testing_samples/testing_invoker_sample/capif_sdk_config_sample.json new file mode 100644 index 0000000000000000000000000000000000000000..9c3618afda77c7b73eb4b6a0757afbf7d1bb6cb2 --- /dev/null +++ b/ci_cd_test/testing_samples/testing_invoker_sample/capif_sdk_config_sample.json @@ -0,0 +1,42 @@ +{ + "capif_host": "capifcore", + "register_host": "services-register-1", + "capif_https_port": "443", + "capif_register_port": "8080", + "capif_username": "custom_user", + "capif_password": "user_pass", + "debug_mode": "True", + "invoker": { + "invoker_folder": "/sdk/testing_samples/testing_invoker_sample/test_invoker_certificate_folder", + "capif_callback_url": "http://localhost:5000", + "supported_features": "0", + "check_authentication_data": { + "ip": "", + "port": "" + }, + "cert_generation": { + "csr_common_name": "sdk-capif-demo", + "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" + }, + "discover_filter": { + "api-name": "", + "api-version": "", + "comm-type": "", + "protocol": "", + "aef-id": "", + "data-format": "", + "api-cat": "", + "preferred-aef-loc": "", + "req-api-prov-name": "", + "supported-features": "", + "api-supported-features": "", + "ue-ip-addr": "", + "service-kpis": "" + } + } +} diff --git a/ci_cd_test/testing_samples/testing_invoker_sample/network_app_invoker.py b/ci_cd_test/testing_samples/testing_invoker_sample/network_app_invoker.py new file mode 100644 index 0000000000000000000000000000000000000000..3ef611825717cd65aa36d61718fc718370437a87 --- /dev/null +++ b/ci_cd_test/testing_samples/testing_invoker_sample/network_app_invoker.py @@ -0,0 +1,32 @@ +import json +import time +import requests +from opencapif_sdk import capif_invoker_connector, service_discoverer +import logging + + +# Path to the OpenCAPIF SDK configuration file +capif_sdk_config_path = "./capif_sdk_config_sample.json" + +import requests +import json + +if __name__ == "__main__": + logging.basicConfig(level=logging.INFO) + + # Onboard the Invoker (creates keys, registers, obtains certs) + capif_connector = capif_invoker_connector(config_file=capif_sdk_config_path) + capif_connector.onboard_invoker() + print("✅ INVOKER ONBOARDING COMPLETED") + + # Discover APIs and obtain JWT token + discoverer = service_discoverer(config_file=capif_sdk_config_path) + discoverer.discover() + discoverer.get_tokens() + + # Show the token + print("✅ ACCESS TOKEN:") + print(discoverer.token) + + # End + print("🎉 Script finished successfully.") diff --git a/ci_cd_test/testing_samples/testing_provider_sample/capif_sdk_config_sample.json b/ci_cd_test/testing_samples/testing_provider_sample/capif_sdk_config_sample.json new file mode 100644 index 0000000000000000000000000000000000000000..67e6b90fe116c6c377139178c96602fa74871665 --- /dev/null +++ b/ci_cd_test/testing_samples/testing_provider_sample/capif_sdk_config_sample.json @@ -0,0 +1,75 @@ +{ + "capif_host": "", + "register_host": "", + "capif_https_port": "", + "capif_register_port": "", + "capif_username": "", + "capif_password": "", + "debug_mode": "", + "invoker": { + "invoker_folder": "", + "capif_callback_url": "", + "supported_features":"", + "check_authentication_data":{ + "ip":"", + "port":"" + }, + "cert_generation": { + "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": "", + "api-version": "", + "comm-type": "", + "protocol": "", + "aef-id": "", + "data-format": "", + "api-cat": "", + "preferred-aef-loc": "", + "req-api-prov-name": "", + "supported-features": "", + "api-supported-features": "", + "ue-ip-addr": "", + "service-kpis": "" + } + }, + "provider": { + "provider_folder": "", + "supported_features": "", + "apfs": "2", + "aefs": "3", + "publish_req": { + "service_api_id": "", + "publisher_apf_id": "", + "publisher_aefs_ids": [ + "", + "" + ] + }, + "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": "", + "log":{ + "apiName": "", + "apiVersion": "", + "resourceName": "", + "uri": "", + "protocol": "", + "operation": "", + "result": "" + } + } +} diff --git a/ci_cd_test/testing_samples/testing_provider_sample/nef_upf_vendor_1.json b/ci_cd_test/testing_samples/testing_provider_sample/nef_upf_vendor_1.json new file mode 100755 index 0000000000000000000000000000000000000000..4ccc39c9004fc3e54e4e0cd7243f86799b63667b --- /dev/null +++ b/ci_cd_test/testing_samples/testing_provider_sample/nef_upf_vendor_1.json @@ -0,0 +1,330 @@ +{ + "apiName": "6G-resilience", + "aefProfiles": [ + { + "aefId": "AEF6fc1d116574bcc797ecd74b8902b35", + "versions": [ + { + "apiVersion": "6G_Resilience_v1", + "expiry": "2100-11-30T10:32:02.004Z", + "resources": [ + { + "resourceName": "RESILIENCE_MANAGEMENT", + "commType": "SUBSCRIBE_NOTIFY", + "uri": "/resilience", + "custOpName": "http_post", + "operations": [ + "GET", + "POST" + ], + "description": "Endpoint to manage resilience functionalities in 6G networks" + }, + { + "resourceName": "RESILIENCE_SINGLE", + "commType": "SUBSCRIBE_NOTIFY", + "uri": "/resilience/{profileId}", + "custOpName": "http_get", + "operations": [ + "GET", + "PUT", + "DELETE" + ], + "description": "Endpoint to manage a single resilience profile" + } + ], + "custOperations": [ + { + "commType": "REQUEST_RESPONSE", + "custOpName": "string", + "operations": [ + "POST" + ], + "description": "Custom operation for managing 6G resilience parameters" + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "check-authentication", + "operations": [ + "POST" + ], + "description": "Check authentication request." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "revoke-authentication", + "operations": [ + "POST" + ], + "description": "Revoke authorization for service APIs." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "check-authentication", + "operations": [ + "POST" + ], + "description": "Check authentication request." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "revoke-authentication", + "operations": [ + "POST" + ], + "description": "Revoke authorization for service APIs." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "check-authentication", + "operations": [ + "POST" + ], + "description": "Check authentication request." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "revoke-authentication", + "operations": [ + "POST" + ], + "description": "Revoke authorization for service APIs." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "check-authentication", + "operations": [ + "POST" + ], + "description": "Check authentication request." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "revoke-authentication", + "operations": [ + "POST" + ], + "description": "Revoke authorization for service APIs." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "check-authentication", + "operations": [ + "POST" + ], + "description": "Check authentication request." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "revoke-authentication", + "operations": [ + "POST" + ], + "description": "Revoke authorization for service APIs." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "check-authentication", + "operations": [ + "POST" + ], + "description": "Check authentication request." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "revoke-authentication", + "operations": [ + "POST" + ], + "description": "Revoke authorization for service APIs." + } + ] + } + ], + "protocol": "HTTP_1_1", + "dataFormat": "JSON", + "securityMethods": [ + "OAUTH" + ], + "interfaceDescriptions": [ + { + "ipv4Addr": "localhost", + "port": 8088, + "securityMethods": [ + "OAUTH" + ] + } + ] + }, + { + "aefId": "AEFa8e49e01d179c79e6a4750a8363f1d", + "versions": [ + { + "apiVersion": "6G_Resilience_v1", + "expiry": "2100-11-30T10:32:02.004Z", + "resources": [ + { + "resourceName": "SLICE_RESILIENCE", + "commType": "SUBSCRIBE_NOTIFY", + "uri": "/slice/resilience", + "custOpName": "http_post", + "operations": [ + "GET", + "POST" + ], + "description": "Endpoint for managing resilience in network slices" + }, + { + "resourceName": "SLICE_SINGLE_RESILIENCE", + "commType": "SUBSCRIBE_NOTIFY", + "uri": "/slice/{sliceId}/resilience", + "custOpName": "http_get", + "operations": [ + "GET", + "PUT", + "DELETE" + ], + "description": "Endpoint for managing a single slice's resilience" + } + ], + "custOperations": [ + { + "commType": "REQUEST_RESPONSE", + "custOpName": "string", + "operations": [ + "POST" + ], + "description": "Custom operation for configuring resilience in network slices" + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "check-authentication", + "operations": [ + "POST" + ], + "description": "Check authentication request." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "revoke-authentication", + "operations": [ + "POST" + ], + "description": "Revoke authorization for service APIs." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "check-authentication", + "operations": [ + "POST" + ], + "description": "Check authentication request." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "revoke-authentication", + "operations": [ + "POST" + ], + "description": "Revoke authorization for service APIs." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "check-authentication", + "operations": [ + "POST" + ], + "description": "Check authentication request." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "revoke-authentication", + "operations": [ + "POST" + ], + "description": "Revoke authorization for service APIs." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "check-authentication", + "operations": [ + "POST" + ], + "description": "Check authentication request." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "revoke-authentication", + "operations": [ + "POST" + ], + "description": "Revoke authorization for service APIs." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "check-authentication", + "operations": [ + "POST" + ], + "description": "Check authentication request." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "revoke-authentication", + "operations": [ + "POST" + ], + "description": "Revoke authorization for service APIs." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "check-authentication", + "operations": [ + "POST" + ], + "description": "Check authentication request." + }, + { + "commType": "REQUEST_RESPONSE", + "custOpName": "revoke-authentication", + "operations": [ + "POST" + ], + "description": "Revoke authorization for service APIs." + } + ] + } + ], + "protocol": "HTTP_1_1", + "dataFormat": "JSON", + "securityMethods": [ + "OAUTH", + "PSK" + ], + "interfaceDescriptions": [ + { + "ipv4Addr": "localhost", + "port": 8088, + "securityMethods": [ + "OAUTH" + ] + } + ] + } + ], + "description": "API of dummy Network-App to test", + "supportedFeatures": "0", + "shareableInfo": { + "isShareable": true, + "capifProvDoms": [ + "string" + ] + }, + "serviceAPICategory": "string", + "apiSuppFeats": "0", + "pubApiPath": { + "ccfIds": [ + "string" + ] + }, + "ccfId": "string" +} \ No newline at end of file diff --git a/ci_cd_test/testing_samples/testing_provider_sample/network_app_provider.py b/ci_cd_test/testing_samples/testing_provider_sample/network_app_provider.py new file mode 100644 index 0000000000000000000000000000000000000000..80b87efa1dd5a4b1177689f71d3ebb094791e252 --- /dev/null +++ b/ci_cd_test/testing_samples/testing_provider_sample/network_app_provider.py @@ -0,0 +1,36 @@ +from opencapif_sdk import capif_provider_connector +import json + + +capif_sdk_config_path = "./testing_CICD_capif_sdk_config_sample.json" + +if __name__ == "__main__": + try: + # Initialize the connector + capif_connector = capif_provider_connector(config_file=capif_sdk_config_path) + print("PROVIDER ONBOARDING COMPLETED") + capif_connector.onboard_provider() + + capif_connector.api_description_path = "./nef_upf_vendor_1.json" + + api6g = capif_connector.provider_capif_ids["APF-1"] + api5g = capif_connector.provider_capif_ids["APF-2"] + + Peñuelas = capif_connector.provider_capif_ids["AEF-1"] + Distrito = capif_connector.provider_capif_ids["AEF-2"] + Valladolid = capif_connector.provider_capif_ids["AEF-3"] + + capif_connector.publish_req['publisher_apf_id'] = api6g + + capif_connector.publish_req['publisher_aefs_ids'] = [Peñuelas, Distrito] + + capif_connector.publish_services() + + print("API PUBLISHED") + + except FileNotFoundError as e: + print(f"Error: {e}") + except json.JSONDecodeError as e: + print(f"Error reading the JSON file: {e}") + except Exception as e: + print(f"Unexpected error: {e}") diff --git a/ci_cd_test/testing_samples/testing_provider_sample/testing_CICD_capif_sdk_config_sample.json b/ci_cd_test/testing_samples/testing_provider_sample/testing_CICD_capif_sdk_config_sample.json new file mode 100644 index 0000000000000000000000000000000000000000..f5464b3a650da19f109a118edc3057b52a09bc0b --- /dev/null +++ b/ci_cd_test/testing_samples/testing_provider_sample/testing_CICD_capif_sdk_config_sample.json @@ -0,0 +1,54 @@ +{ + "capif_host": "capifcore", + "register_host": "services-register-1", + "capif_https_port": "443", + "capif_register_port": "8080", + "capif_username": "custom_user", + "capif_password": "user_pass", + "debug_mode": "True", + "provider": { + "provider_folder": "/sdk/testingsamples/testing_provider_sample/test_provider_certificate_folder", + "supported_features": "0", + "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" + }, + "apfs": "2", + "aefs": "3", + "publish_req": { + "service_api_id": "", + "publisher_apf_id": "", + "publisher_aefs_ids": ["", ""] + }, + "api_description_path": "", + "events": { + "description": ["SERVICE_API_AVAILABLE"], + "eventFilters": [ + { + "apiIds": [""], + "apiInvokerIds": [""], + "aefIds": [""] + } + ], + "notificationDestination" : "http://localhost:5000", + "websockNotifConfig": { + "websocketUri" : "http://localhost:5000", + "requestWebsocketUri": true + } + }, + "log": { + "apiName": "test1", + "apiVersion": "v1", + "resourceName": "MONITORING_SUBSCRIPTIONS", + "uri": "/{scsAsId}/subscriptions", + "protocol": "HTTP_2", + "operation": "GET", + "result": "200" + } + } +} \ No newline at end of file diff --git a/clean_test_sdk.sh b/clean_test_sdk.sh new file mode 100755 index 0000000000000000000000000000000000000000..382dbbb1d6a14679e9fe4a7e81f28748887999e7 --- /dev/null +++ b/clean_test_sdk.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Nombre del contenedor e imagen +CONTAINER_NAME=capif-sdk-runner +IMAGE_NAME=opencapif_sdk + +echo "🧹 Stopping and removing container: $CONTAINER_NAME..." +docker stop $CONTAINER_NAME 2>/dev/null +docker rm $CONTAINER_NAME 2>/dev/null + +echo "🗑️ Removing image: $IMAGE_NAME..." +docker rmi $IMAGE_NAME + +echo "✅ Cleanup complete." + diff --git a/integration_tests/Dockerfile b/integration_tests/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..310f78145e991efd142ab458557b75312a3e0735 --- /dev/null +++ b/integration_tests/Dockerfile @@ -0,0 +1,14 @@ +FROM labs.etsi.org:5050/ocf/capif/python:3-slim-bullseye + +RUN apt update +RUN apt install -y git + +RUN git clone https://labs.etsi.org/rep/ocf/sdk.git + +WORKDIR /sdk + +RUN python -m pip install --upgrade pip +RUN pip install -r installation/requirements.txt +RUN pip install . + +ENTRYPOINT ["tail", "-f", "/dev/null"] diff --git a/integration_tests/Dockerfile2 b/integration_tests/Dockerfile2 new file mode 100644 index 0000000000000000000000000000000000000000..2441f78484bda6fb5666a075ad04fd7ea712dcda --- /dev/null +++ b/integration_tests/Dockerfile2 @@ -0,0 +1,8 @@ +FROM labs.etsi.org:5050/ocf/capif/python:3-slim-bullseye + +RUN apt update +RUN apt install -y git + +COPY setup.sh . + +ENTRYPOINT ["bash", "setup.sh"] diff --git a/integration_tests/setup.sh b/integration_tests/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..7ca30c9a164784e8f58953f168e0a698e492746f --- /dev/null +++ b/integration_tests/setup.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -euo pipefail + +SDK_DIR="/sdk" +SDK_REPO="https://labs.etsi.org/rep/ocf/sdk.git" +SDK_JUST_INSTALLED="true" + +if [[ -d "$SDK_DIR/.git" ]]; then + echo "OpenCAPIF SDK repository exists. Updating..." + git -C "$SDK_DIR" pull + SDK_JUST_INSTALLED="false" +else + echo "OpenCAPIF SDK repository not found. Cloning..." + git clone "$SDK_REPO" "$SDK_DIR" +fi + +### !!! +# python -m build + +echo "Installing OpenCAPIF SDK dependencies..." + +python -m pip install -r "$SDK_DIR/installation/requirements.txt" +python -m pip install "$SDK_DIR" + +[[ "$SDK_JUST_INSTALLED" == "true" ]] && action_text="installation completed" || action_text="updated" +echo "OpenCAPIF SDK $action_text successfully." + +tail -f /dev/null # TODO: Replace with actual entrypoint command (tests) 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 f76613236f6d5319187c3be9b169a79127ae7846..78c7f40105e1a459cd8d4cf0d69e2396a4521f17 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 @@ -1,27 +1,27 @@ { - "capif_host": "", - "register_host": "", - "capif_https_port": "", - "capif_register_port": "", - "capif_username": "", - "capif_password": "", - "debug_mode": "", + "capif_host": "capifcore", + "register_host": "localhost", + "capif_https_port": "443", + "capif_register_port": "8084", + "capif_username": "sdk-capif-demo", + "capif_password": "sdk-capif-demo-pass", + "debug_mode": "True", "invoker": { - "invoker_folder": "", - "capif_callback_url": "", - "supported_features":"", - "check_authentication_data":{ - "ip":"", - "port":"" + "invoker_folder": "/Users/HI03132/Workdir/OpenCapif/pesp_capif_sdk/network_app_samples/network_app_invoker_sample/test_invoker_certificate_folder", + "capif_callback_url": "http://localhost:5000", + "supported_features": "0", + "check_authentication_data": { + "ip": "", + "port": "" }, "cert_generation": { - "csr_common_name": "", - "csr_organizational_unit": "", - "csr_organization": "", - "csr_locality": "", - "csr_state_or_province_name": "", - "csr_country_name": "", - "csr_email_address": "" + "csr_common_name": "sdk-capif-demo", + "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" }, "discover_filter": { "api-name": "", @@ -38,38 +38,5 @@ "ue-ip-addr": "", "service-kpis": "" } - }, - "provider": { - "provider_folder": "", - "supported_features": "", - "apfs": "", - "aefs": "", - "publish_req": { - "service_api_id": "", - "publisher_apf_id": "", - "publisher_aefs_ids": [ - "", - "" - ] - }, - "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": "", - "log":{ - "apiName": "", - "apiVersion": "", - "resourceName": "", - "uri": "", - "protocol": "", - "operation": "", - "result": "" - } - } + } } diff --git a/network_app_samples/network_app_invoker_sample/capif_sdk_config_sample_template.json b/network_app_samples/network_app_invoker_sample/capif_sdk_config_sample_template.json new file mode 100644 index 0000000000000000000000000000000000000000..879354bd2f7fc1a5ae807a0b4dae001e659bb0aa --- /dev/null +++ b/network_app_samples/network_app_invoker_sample/capif_sdk_config_sample_template.json @@ -0,0 +1,42 @@ +{ + "capif_host": "", + "register_host": "", + "capif_https_port": "", + "capif_register_port": "", + "capif_username": "", + "capif_password": "", + "debug_mode": "", + "invoker": { + "invoker_folder": "", + "capif_callback_url": "", + "supported_features": "", + "check_authentication_data": { + "ip": "", + "port": "" + }, + "cert_generation": { + "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": "", + "api-version": "", + "comm-type": "", + "protocol": "", + "aef-id": "", + "data-format": "", + "api-cat": "", + "preferred-aef-loc": "", + "req-api-prov-name": "", + "supported-features": "", + "api-supported-features": "", + "ue-ip-addr": "", + "service-kpis": "" + } + } +} diff --git a/network_app_samples/network_app_invoker_sample/network_app_invoker.py b/network_app_samples/network_app_invoker_sample/network_app_invoker.py index 865bd2db0c09bf47b3f89787aa86d60a8f1ea094..3440170c0f25f69a01e1c2622bf0f913ea65faeb 100644 --- a/network_app_samples/network_app_invoker_sample/network_app_invoker.py +++ b/network_app_samples/network_app_invoker_sample/network_app_invoker.py @@ -14,10 +14,10 @@ def update_token(access_token): Update the Postman environment with the new access token. """ # Your Postman API Key - postman_api_key = "PMAK-66fd117ac0a4eb0001e7881b-ecf2b89675a6a1bfd0856838e3b1aa552a" + postman_api_key = "PMAK-6821ff2a82876e0001608764-939092a2284d70f32ec1762601045eb39b" # Postman Environment ID - environment_id = "36540500-bfaa8442-180f-4247-892d-b0605581b6a6" + environment_id = "30047011-32a5f4e3-6b64-482f-8612-ed3e9a42fde5" # Postman API URL to modify environments url = f"https://api.getpostman.com/environments/{environment_id}" 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 67e6b90fe116c6c377139178c96602fa74871665..40be876644e983d2e52ca24a6d07dd8e492940b1 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 @@ -1,75 +1,54 @@ { - "capif_host": "", - "register_host": "", - "capif_https_port": "", - "capif_register_port": "", - "capif_username": "", - "capif_password": "", - "debug_mode": "", - "invoker": { - "invoker_folder": "", - "capif_callback_url": "", - "supported_features":"", - "check_authentication_data":{ - "ip":"", - "port":"" - }, + "capif_host": "capifcore", + "register_host": "localhost", + "capif_https_port": "443", + "capif_register_port": "8084", + "capif_username": "custom_user", + "capif_password": "user_pass", + "debug_mode": "True", + "provider": { + "provider_folder": "/Users/HI03132/Workdir/OpenCapif/pesp_capif_sdk/network_app_samples/network_app_provider_sample/test_provider_certificate_folder", + "supported_features": "0", "cert_generation": { - "csr_common_name": "", - "csr_organizational_unit": "", - "csr_organization": "", - "csr_locality": "", - "csr_state_or_province_name": "", - "csr_country_name": "", - "csr_email_address": "" + "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" }, - "discover_filter": { - "api-name": "", - "api-version": "", - "comm-type": "", - "protocol": "", - "aef-id": "", - "data-format": "", - "api-cat": "", - "preferred-aef-loc": "", - "req-api-prov-name": "", - "supported-features": "", - "api-supported-features": "", - "ue-ip-addr": "", - "service-kpis": "" - } - }, - "provider": { - "provider_folder": "", - "supported_features": "", "apfs": "2", "aefs": "3", "publish_req": { "service_api_id": "", "publisher_apf_id": "", - "publisher_aefs_ids": [ - "", - "" - ] - }, - "cert_generation": { - "csr_common_name": "", - "csr_organizational_unit": "", - "csr_organization": "", - "csr_locality": "", - "csr_state_or_province_name": "", - "csr_country_name": "", - "csr_email_address": "" + "publisher_aefs_ids": ["", ""] }, "api_description_path": "", - "log":{ - "apiName": "", - "apiVersion": "", - "resourceName": "", - "uri": "", - "protocol": "", - "operation": "", - "result": "" + "events": { + "description": ["SERVICE_API_AVAILABLE"], + "eventFilters": [ + { + "apiIds": [""], + "apiInvokerIds": [""], + "aefIds": [""] + } + ], + "notificationDestination" : "http://localhost:5000", + "websockNotifConfig": { + "websocketUri" : "http://localhost:5000", + "requestWebsocketUri": true + } + }, + "log": { + "apiName": "test1", + "apiVersion": "v1", + "resourceName": "MONITORING_SUBSCRIPTIONS", + "uri": "/{scsAsId}/subscriptions", + "protocol": "HTTP_2", + "operation": "GET", + "result": "200" } - } -} + } +} \ No newline at end of file diff --git a/network_app_samples/network_app_provider_sample/capif_sdk_config_sample_template.json b/network_app_samples/network_app_provider_sample/capif_sdk_config_sample_template.json new file mode 100644 index 0000000000000000000000000000000000000000..c25194ce013aa66f1e225455d32ed1ce9f657535 --- /dev/null +++ b/network_app_samples/network_app_provider_sample/capif_sdk_config_sample_template.json @@ -0,0 +1,75 @@ +{ + "capif_host": "", + "register_host": "", + "capif_https_port": "", + "capif_register_port": "", + "capif_username": "", + "capif_password": "", + "debug_mode": "", + "invoker": { + "invoker_folder": "", + "capif_callback_url": "", + "supported_features": "", + "check_authentication_data": { + "ip": "", + "port": "" + }, + "cert_generation": { + "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": "", + "api-version": "", + "comm-type": "", + "protocol": "", + "aef-id": "", + "data-format": "", + "api-cat": "", + "preferred-aef-loc": "", + "req-api-prov-name": "", + "supported-features": "", + "api-supported-features": "", + "ue-ip-addr": "", + "service-kpis": "" + } + }, + "provider": { + "provider_folder": "", + "supported_features": "", + "apfs": "", + "aefs": "", + "publish_req": { + "service_api_id": "", + "publisher_apf_id": "", + "publisher_aefs_ids": [ + "", + "" + ] + }, + "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": "", + "log": { + "apiName": "", + "apiVersion": "", + "resourceName": "", + "uri": "", + "protocol": "", + "operation": "", + "result": "" + } + } +} \ No newline at end of file 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 58ceb6fa03cecf99c22e18707da49c53534c7173..c1f9f79b5b9184768a623d14aac39d85fdd225f5 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 @@ -2,7 +2,7 @@ "apiName": "6G-resilience", "aefProfiles": [ { - "aefId": "AEF6fc1d116574bcc797ecd74b8902b35", + "aefId": "AEFaa6701d0f5fc5e10eba065f1d68ff6", "versions": [ { "apiVersion": "6G_Resilience_v1", @@ -156,7 +156,7 @@ ] }, { - "aefId": "AEFa8e49e01d179c79e6a4750a8363f1d", + "aefId": "AEF3a9f414ffa756d2583aece0b615dfe", "versions": [ { "apiVersion": "6G_Resilience_v1", @@ -312,7 +312,7 @@ } ], "description": "API of dummy Network-App to test", - "supportedFeatures": "fffff", + "supportedFeatures": "0", "shareableInfo": { "isShareable": true, "capifProvDoms": [ 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 5930f5c4a7b6c8638c90b67a4642cf70328f4587..0cacc75119fb8456ac78b4628f7e7f75b2c40d5d 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 @@ -2,7 +2,7 @@ "apiName": "5G-Network-App-API", "aefProfiles": [ { - "aefId": "AEF6fc1d116574bcc797ecd74b8902b35", + "aefId": "AEFaa6701d0f5fc5e10eba065f1d68ff6", "versions": [ { "apiVersion": "QoS_v1", @@ -141,7 +141,7 @@ ] }, { - "aefId": "AEFa8e49e01d179c79e6a4750a8363f1d", + "aefId": "AEF3a9f414ffa756d2583aece0b615dfe", "versions": [ { "apiVersion": "TSN_v1", @@ -296,7 +296,7 @@ ] }, { - "aefId": "AEFc1a1d48f93449af79b5289cc3b1ae1", + "aefId": "AEF13d316f648ec6252276422de4bef08", "versions": [ { "apiVersion": "NetworkSlicing_v1", @@ -436,7 +436,7 @@ } ], "description": "API of dummy Network-App to test", - "supportedFeatures": "fffff", + "supportedFeatures": "0", "shareableInfo": { "isShareable": true, "capifProvDoms": [ diff --git a/network_app_samples/network_app_provider_sample/network_app_provider.py b/network_app_samples/network_app_provider_sample/network_app_provider.py index 3750e497c8f7fd5ee98481c3a4639dac0dea95d3..b147241b28bc72f91a12013f282a0d91ce36c63b 100644 --- a/network_app_samples/network_app_provider_sample/network_app_provider.py +++ b/network_app_samples/network_app_provider_sample/network_app_provider.py @@ -19,7 +19,7 @@ def config_resilience(): resilience_app.config['JWT_ALGORITHM'] = 'RS256' resilience_app.config['JWT_PUBLIC_KEY'] = "YourPublicKeyHere" - with open("/Users/IDB0128/Documents/OpenCapif/test_provider_certificate_folder/echeva_0/capif_cert_server.pem", "rb") as cert_file: + with open("/Users/HI03132/Workdir/OpenCapif/pesp_capif_sdk/network_app_samples/network_app_provider_sample/test_provider_certificate_folder/sdk-capif-demo/capif_cert_server.pem", "rb") as cert_file: cert = cert_file.read() crtObj = crypto.load_certificate(crypto.FILETYPE_PEM, cert) @@ -133,7 +133,7 @@ jwt_flask = JWTManager(Network_app) def config_network(): - with open("/Users/IDB0128/Documents/OpenCapif/test_provider_certificate_folder/echeva_0/capif_cert_server.pem", "rb") as cert_file: + with open("/Users/HI03132/Workdir/OpenCapif/pesp_capif_sdk/network_app_samples/network_app_provider_sample/test_provider_certificate_folder/sdk-capif-demo/capif_cert_server.pem", "rb") as cert_file: cert = cert_file.read() crtObj = crypto.load_certificate(crypto.FILETYPE_PEM, cert) @@ -313,9 +313,11 @@ if __name__ == "__main__": capif_connector.api_description_path = "./nef_upf_vendor_1.json" + # 2 APF IDs api6g = capif_connector.provider_capif_ids["APF-1"] api5g = capif_connector.provider_capif_ids["APF-2"] + # 3 AEF IDs Peñuelas = capif_connector.provider_capif_ids["AEF-1"] Distrito = capif_connector.provider_capif_ids["AEF-2"] Valladolid = capif_connector.provider_capif_ids["AEF-3"] @@ -344,6 +346,9 @@ if __name__ == "__main__": capif_connector.get_service() + + print("STARTING SERVER") + config_network() config_resilience() diff --git a/opencapif_sdk/capif_provider_connector.py b/opencapif_sdk/capif_provider_connector.py index a493ed331e35e867add1884ace722df4eb288ea5..ba7dd93a0a4002e1e3e78fee10a598f988c1657d 100644 --- a/opencapif_sdk/capif_provider_connector.py +++ b/opencapif_sdk/capif_provider_connector.py @@ -51,6 +51,7 @@ class capif_provider_connector: """ Initializes the CAPIFProvider connector with the parameters specified in the configuration file. """ + # Load configuration from file if necessary config_file = os.path.abspath(config_file) self.config_path = os.path.dirname(config_file)+"/" @@ -170,6 +171,8 @@ class capif_provider_connector: self.capif_register_url = f"https://{capif_register_host.strip()}:8084/" else: self.capif_register_url = f"https://{capif_register_host.strip()}:{capif_register_port.strip()}/" + + self.logger.debug(f"📡 CAPIF Register URL set to: {self.capif_register_url}getauth") events_config = provider_config.get('events', {}) self.events_description = os.getenv('PROVIDER_EVENTS_DESCRIPTION', events_config.get('description', '')) diff --git a/test_sdk.sh b/test_sdk.sh new file mode 100755 index 0000000000000000000000000000000000000000..cd8239bd2c9482b1be499f06a6f0bcaad2d69ebf --- /dev/null +++ b/test_sdk.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Nombre del contenedor e imagen +CONTAINER_NAME=capif-sdk-runner +IMAGE_NAME=opencapif_sdk +BRANCH_NAME=feat/dockerfiles +NETWORK_NAME=capif-network + +echo "🛠️ Building image: $IMAGE_NAME from branch: $BRANCH_NAME with no cache..." +docker build --no-cache . -t $IMAGE_NAME -f ci_cd_test/Dockerfile --build-arg BRANCH=$BRANCH_NAME + +echo "🚀 Running container: $CONTAINER_NAME in network: $NETWORK_NAME..." +docker run -d \ + --name $CONTAINER_NAME \ + --network $NETWORK_NAME \ + $IMAGE_NAME + +echo "🧑‍💻 Attaching to container shell..." +docker exec -it $CONTAINER_NAME sh +