From 2a7e735e7289107941cc8a6fbf7300a0e0fa7fa6 Mon Sep 17 00:00:00 2001
From: JorgeEcheva26 <jorge.echevarriauribarri.practicas@telefonica.es>
Date: Tue, 5 Nov 2024 12:37:48 +0100
Subject: [PATCH] configuration data error

---
 doc/sdk_configuration.md                              |  4 ++--
 doc/sdk_full_documentation.md                         |  2 +-
 .../capif_sdk_config_sample.json                      |  4 ++--
 .../network_app_invoker_sample/network_app_invoker.py |  3 +--
 .../capif_sdk_config_sample.json                      |  2 +-
 samples/config_sample.json                            |  2 +-
 samples/enviroment_variables_sample.txt               |  4 ++--
 sdk/capif_invoker_connector.py                        |  6 +++---
 sdk/service_discoverer.py                             | 11 ++++++-----
 9 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/doc/sdk_configuration.md b/doc/sdk_configuration.md
index a9a0b21..f50ee86 100644
--- a/doc/sdk_configuration.md
+++ b/doc/sdk_configuration.md
@@ -36,7 +36,7 @@ When configuring the SDK as a **Network App Invoker**, the following fields must
 
 **Optional:**
 - `discover_filter`: useful to enable the discovery of specific APIs. Some fields under [`discover_filter`](#configuration-of-discover_filter) structure required to be configured when using discovery filters. Check devoted section below,
-- `check_authentication`: useful to use `check_authentication()` function to validate features from a target provider, it will be required to fill up the `ip` and `port` parameters within the `check_authentication` variable.
+- `check_authentication_data`: useful to use `check_authentication()` function to validate features from a target provider, it will be required to fill up the `ip` and `port` parameters within the `check_authentication_data` variable.
 
 ### Network App Provider
 
@@ -91,7 +91,7 @@ This file can also be populated using [environment variables](../samples/envirom
 - [`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`: The `ip` and `port` of the target Provider's AEF to get their supported features from.
+- `check_authentication_data`: The `ip` and `port` of the target Provider's AEF to get their supported features from.
 
 
 ## Configuration via `capif_sdk_register.json`
diff --git a/doc/sdk_full_documentation.md b/doc/sdk_full_documentation.md
index 6dc3c6d..7c201a7 100644
--- a/doc/sdk_full_documentation.md
+++ b/doc/sdk_full_documentation.md
@@ -214,7 +214,7 @@ The SDK allows the Network App Invoker to check the `supported_features` from th
 It is mandatory to have obtained the [JWT token](#obtain-jwt-tokens) previously. 
 
 **Required SDK inputs**:
-- check_authentication
+- check_authentication_data
 
 ![Invoker_check_authentication](./images/flows_invoker_check_authentication.jpg)
 
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 aa58c93..806d47d 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
@@ -5,12 +5,12 @@
   "capif_register_port": "36211",
   "capif_username": "echeva_0",
   "capif_password": "echevapass",
-  "debug_mode": "False",
+  "debug_mode": "True",
   "invoker":{
     "invoker_folder": "/Users/IDB0128/Documents/OpenCapif/test_invoker_certificate_folder",
     "capif_callback_url": "http://localhost:5000",
     "supported_features":"fffffff",
-    "check_authentication":{
+    "check_authentication_data":{
       "ip":"",
       "port":""
     },
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 e3c1e62..70ea86b 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
@@ -99,8 +99,7 @@ if __name__ == "__main__":
         lenght = len(details["registered_security_contexes"])
         ip = details["registered_security_contexes"][lenght-1]["aef_profiles"][0]["ip"]
         port = details["registered_security_contexes"][lenght-1]["aef_profiles"][0]["port"]
-        discoverer.check_authentication["ip"] = ip
-        discoverer.check_authentication["port"] = port
+        discoverer.check_authentication_data.update({"ip": ip, "port": port})
         discoverer.check_authentication()
 
         # Load API details from the JSON file
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 b93180a..2782ab0 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
@@ -9,7 +9,7 @@
   "invoker":{
     "invoker_folder": "",
     "capif_callback_url": "",
-    "check_authentication":{
+    "check_authentication_data":{
       "ip":"",
       "port":""
     },
diff --git a/samples/config_sample.json b/samples/config_sample.json
index a634241..7a1d6ae 100644
--- a/samples/config_sample.json
+++ b/samples/config_sample.json
@@ -10,7 +10,7 @@
     "invoker_folder": "",
     "capif_callback_url": "",
     "supported_features":"",
-    "check_authentication":{
+    "check_authentication_data":{
       "ip":"",
       "port":""
     },
diff --git a/samples/enviroment_variables_sample.txt b/samples/enviroment_variables_sample.txt
index 8e76ace..e7c4a06 100644
--- a/samples/enviroment_variables_sample.txt
+++ b/samples/enviroment_variables_sample.txt
@@ -20,8 +20,8 @@ export INVOKER_CSR_STATE_OR_PROVINCE_NAME=your_state_or_province
 export INVOKER_CSR_COUNTRY_NAME=your_country_name
 export INVOKER_CSR_EMAIL_ADDRESS=your_email_address
 
-export INVOKER_CHECK_AUTHENTICATION_IP =
-export INVOKER_CHECK_AUTHENTICATION_PORT = 
+export INVOKER_CHECK_AUTHENTICATION_DATA_IP =
+export INVOKER_CHECK_AUTHENTICATION_DATA_PORT = 
 #DISCOVER FILTER
 export DISCOVER_FILTER_API_NAME=""
 export DISCOVER_FILTER_API_VERSION=""
diff --git a/sdk/capif_invoker_connector.py b/sdk/capif_invoker_connector.py
index e43a947..20734aa 100644
--- a/sdk/capif_invoker_connector.py
+++ b/sdk/capif_invoker_connector.py
@@ -83,10 +83,10 @@ class capif_invoker_connector:
         
         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()
-        check_authentication = invoker_config.get('check_authentication', {})
+        check_authentication_data = invoker_config.get('check_authentication_data', {})
         self.check_authentication = {
-            "ip": os.getenv('INVOKER_CHECK_AUTHENTICATION_IP', check_authentication.get('ip', '')).strip(),
-            "port":  os.getenv('INVOKER_CHECK_AUTHENTICATION_PORT', check_authentication.get('port', '')).strip()
+            "ip": os.getenv('INVOKER_CHECK_AUTHENTICATION_DATA_IP', check_authentication_data.get('ip', '')).strip(),
+            "port":  os.getenv('INVOKER_CHECK_AUTHENTICATION_DATA_PORT', check_authentication_data.get('port', '')).strip()
         } 
 
         # Extract CSR configuration from the JSON
diff --git a/sdk/service_discoverer.py b/sdk/service_discoverer.py
index 0566dec..6e4fc8a 100644
--- a/sdk/service_discoverer.py
+++ b/sdk/service_discoverer.py
@@ -76,10 +76,10 @@ class service_discoverer:
             os.getenv('invoker_folder', invoker_config.get('invoker_folder', '')).strip()
         )
         supported_features = os.getenv('INVOKER_FOLDER', invoker_config.get('supported_features', '')).strip()
-        check_authentication = invoker_config.get('check_authentication', {})
-        self.check_authentication = {
-            "ip": os.getenv('INVOKER_CHECK_AUTHENTICATION_IP', check_authentication.get('ip', '')).strip(),
-            "port":  os.getenv('INVOKER_CHECK_AUTHENTICATION_PORT', check_authentication.get('port', '')).strip()
+        check_authentication_data = invoker_config.get('check_authentication_data', {})
+        self.check_authentication_data = {
+            "ip": os.getenv('INVOKER_CHECK_AUTHENTICATION_DATA_IP', check_authentication_data.get('ip', '')).strip(),
+            "port":  os.getenv('INVOKER_CHECK_AUTHENTICATION_DATA_PORT', check_authentication_data.get('port', '')).strip()
         } 
         # Retrieve CAPIF invoker username
         capif_invoker_username = os.getenv('CAPIF_USERNAME', config.get('capif_username', '')).strip()
@@ -509,11 +509,12 @@ class service_discoverer:
             raise
 
     def check_authentication(self):
+        print("hola")
         self.logger.info("Checking authentication")
         try:
             invoker_details = self.__load_provider_api_details()
             invoker_id = invoker_details["api_invoker_id"]
-            check_auth = self.check_authentication
+            check_auth = self.check_authentication_data
             url = "http://"+f"{check_auth['ip']}:{check_auth['port']}/" + "aef-security/v1/check-authentication"
             
             payload = {
-- 
GitLab