Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NOD-498] Call api config schema proxy #348

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions int_test_nodo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
pip install -U -r ./requirements.txt

<<USAGE_EX
NODOPGDB=true SUBSCRIPTION_KEY=9b211c9e90a74fcc8115b64a924219df sh int_test_nodo.sh https://api.dev.platform.pagopa.it/nodo-replica-ndp \
NODOPGDB=true SUBSCRIPTION_KEY=9b211c9e90a74fcc8115b64a924219df sh int_test_nodo.sh \
https://api.dev.platform.pagopa.it/nodo-replica-ndp \
https://api.dev.platform.pagopa.it/nodo-replica-ndp/monitoring/v1/config/refresh/CONFIG \
https://api.dev.platform.pagopa.it/mock-ec-replica-ndp/service/v1/mock \
https://api.dev.platform.pagopa.it/mock-ec-replica-secondary-ndp/service/v1/mock \
Expand All @@ -26,7 +27,8 @@ URL_MOCK_PSP2=$6
URL_MOCK_PM=$7
DB_PWD=$8
#FEATURES_PATH=/PrimitiveAccessorie/primitives
FEATURES_PATH=/Mod1/flows/nodoInviaRT
#FEATURES_PATH=/Mod1/flows/nodoInviaRT
FEATURES_PATH=/NewMod3/primitives/verifyPaymentNotice_syntax_ok.feature

if [ "$#" -lt 9 ] && [ "$#" -gt 0 ]; then
echo "Yeaaah 🚀"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Feature: Syntax checks for verifyPaymentReq - OK
</soapenv:Body>
</soapenv:Envelope>
"""
@runnable @independent
@runnable @independent @shorttrack
Scenario: Check valid URL in WSDL namespace
When psp sends SOAP verifyPaymentNotice to nodo-dei-pagamenti
Then check outcome is OK of verifyPaymentNotice response
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ Feature: flow checks for sendPaymentResult with PA new
Then verify the HTTP status code of mod3CancelV2 response is 200
And wait 5 seconds for expiration
@test @lazy @dependentread @dependentwrite
Scenario: T_SPR_08 (closePayment)
Given the T_SPR_08 (mod3CancelV2) scenario executed successfully
And the closePayment scenario executed successfully
When WISP sends rest POST v1/closepayment_json to nodo-dei-pagamenti
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Feature: GT_01
And checks the value $activateIOPaymentResponse.paymentToken of the record at column TOKEN of the table IDEMPOTENCY_CACHE retrived by the query payment_status on db nodo_online under macro AppIO
And checks the value NotNone of the record at column VALID_TO of the table IDEMPOTENCY_CACHE retrived by the query payment_status on db nodo_online under macro AppIO
And checks the value NotNone of the record at column TOKEN_VALID_FROM of the table POSITION_ACTIVATE retrived by the query payment_status on db nodo_online under macro AppIO
@runnable @lazy @dependentread @dependentwrite
@runnable @lazy @dependentread @dependentwrite @shorttrack
Scenario: Execute nodoChiediInformazioniPagamento (Phase 3)
Given the Execute activateIOPayment (Phase 2) scenario executed successfully
When WISP sends rest GET informazioniPagamento?idPagamento=$activateIOPaymentResponse.paymentToken to nodo-dei-pagamenti
Expand Down
28 changes: 18 additions & 10 deletions src/integ-test/bdd-test/features/environment.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import json
from behave.model import Table
import os, requests
import os
import steps.utils as utils
import time
import requests

if 'NODOPGDB' in os.environ:
import steps.db_operation_pg as db
import psycopg2
from psycopg2 import OperationalError
else:
import steps.db_operation as db
import os, cx_Oracle, requests
import cx_Oracle

if 'APICFG' in os.environ:
import steps.db_operation_apicfg_testing_support as db


def before_all(context):
Expand All @@ -21,8 +23,11 @@

more_userdata = json.load(open(os.path.join(context.config.base_dir + "/../resources/config.json")))
context.config.update_userdata(more_userdata)
#services = context.config.userdata.get("services")
#db_config = context.config.userdata.get("db_configuration")

if 'APICFG' in os.environ:
apicfg_testing_support_service = context.config.userdata.get("services").get("apicfg-testing-support")
db.set_address(apicfg_testing_support_service)

db_selected = context.config.userdata.get("db_configuration").get('nodo_cfg')
selected_query = utils.query_json(context, 'select_config', 'configurations')
conn = db.getConnection(db_selected.get('host'), db_selected.get('database'),db_selected.get('user'),db_selected.get('password'),db_selected.get('port'))
Expand All @@ -37,17 +42,19 @@

setattr(context, 'configurations', config_dict)


def before_feature(context, feature):
services = context.config.userdata.get("services")
# add heading
feature.background.steps[0].table = Table(headings=("name", "url", "healthcheck", "soap_service", "rest_service"))
feature.background.steps[0].table = Table(headings=("name", "url", "healthcheck", "soap_service", "rest_service", "subscription_key_name"))
# add data in the tables
for system_name in services.keys():
row = (system_name,
services.get(system_name).get("url", ""),
services.get(system_name).get("healthcheck", ""),
services.get(system_name).get("soap_service", ""),
services.get(system_name).get("rest_service", ""))
services.get(system_name).get("rest_service", ""),
services.get(system_name).get("subscription_key_name", ""))
feature.background.steps[0].table.add_row(row)

# DISABLE see @config-ec too
Expand All @@ -65,6 +72,7 @@
# # reset apiconfig
# context.apiconfig.delete_creditor_institution(global_configuration.get("creditor_institution_code"))


def after_all(context):
db_selected = context.config.userdata.get("db_configuration").get('nodo_cfg')
conn = db.getConnection(db_selected.get('host'), db_selected.get('database'), db_selected.get('user'), db_selected.get('password'),db_selected.get('port'))
Expand All @@ -77,7 +85,7 @@

db.closeConnection(conn)
headers = {'Host': 'api.dev.platform.pagopa.it:443'}
requests.get(utils.get_refresh_config_url(context),verify=False,headers=headers)
requests.get(utils.get_refresh_config_url(context), verify=False, headers=headers)

Check failure

Code scanning / CodeQL

Request without certificate validation High

This request may run without certificate validation because
it is disabled
.

Copilot Autofix AI 8 days ago

To fix the problem, we need to ensure that the request made on line 88 performs TLS certificate verification. This can be done by either removing the verify=False parameter, which will default to verify=True, or by explicitly setting verify=True. If there is a specific certificate that needs to be used, we can provide the path to the certificate file.

Steps to fix:

  1. Remove the verify=False parameter from the requests.get call on line 88.
  2. Ensure that the request still functions correctly with certificate verification enabled.
Suggested changeset 1
src/integ-test/bdd-test/features/environment.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/integ-test/bdd-test/features/environment.py b/src/integ-test/bdd-test/features/environment.py
--- a/src/integ-test/bdd-test/features/environment.py
+++ b/src/integ-test/bdd-test/features/environment.py
@@ -87,3 +87,3 @@
     headers = {'Host': 'api.dev.platform.pagopa.it:443'}  
-    requests.get(utils.get_refresh_config_url(context), verify=False, headers=headers)
+    requests.get(utils.get_refresh_config_url(context), headers=headers)
 
EOF
@@ -87,3 +87,3 @@
headers = {'Host': 'api.dev.platform.pagopa.it:443'}
requests.get(utils.get_refresh_config_url(context), verify=False, headers=headers)
requests.get(utils.get_refresh_config_url(context), headers=headers)

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options


def config_ec(context):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import requests
import os

apicfg_testing_support = {
"base_path": None,
"service": "/genericQuery"
}


def set_address(service):
apicfg_testing_support["base_path"] = service.get("url")


def create_connection(db_name, db_user, db_password, db_host, db_port):
print("Fake connection to DB executed successfully")


def getConnection(host:str, database:str, user:str, password:str, port:str):
return None


def execute_read_query(connection, query):
print('execute_sql_query ...')
print(query)

try:
print('executing_sql_query ...')
except Exception as e:
print(f"The error '{e}' occurred")


def executeQuery(conn, query:str) -> list:
print('execute_sql_query ...')
print(query)
try:
print('executing_sql_query ...')
headers = {}
if 'APICFG_SUBSCRIPTION_KEY' in os.environ:
headers["Ocp-Apim-Subscription-Key"] = os.getenv("APICFG_SUBSCRIPTION_KEY", default="")

url = apicfg_testing_support.get("base_path") + apicfg_testing_support.get("service")
response = requests.post(url, data=query, headers=headers)

return response.json()
except Exception as e:
print(f"The error '{e}' occurred")


def closeConnection(conn) -> None:
print('Fake connection closed successfully')
Loading
Loading