Skip to content
GitLab
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
OCF
capif
Compare revisions
3f3b18b81bb71d4297fb04e59068b72dc58d2a9a...78fd87c516ede5a55bf06bb9cb8625d3c1aebbeb
Commits (2)
Modify loggin to allow redis communication
· c5507ba9
Jorge Moratinos
authored
Apr 29, 2024
c5507ba9
modify robot docker image
· 78fd87c5
Jorge Moratinos
authored
Apr 29, 2024
78fd87c5
Hide whitespace changes
Inline
Side-by-side
services/TS29222_CAPIF_Logging_API_Invocation_API/api_invocation_logs/core/invocationlogs.py
View file @
78fd87c5
...
...
@@ -13,6 +13,9 @@ from ..util import dict_to_camel_case, clean_empty
from
.resources
import
Resource
from
.responses
import
bad_request_error
,
internal_server_error
,
forbidden_error
,
not_found_error
,
unauthorized_error
,
make_response
from
..models.invocation_log
import
InvocationLog
from
.publisher
import
Publisher
publisher_ops
=
Publisher
()
class
LoggingInvocationOperations
(
Resource
):
...
...
@@ -84,6 +87,12 @@ class LoggingInvocationOperations(Resource):
if
result
is
not
None
:
return
result
if
log
.
result
:
if
int
(
log
.
result
)
>=
200
and
int
(
log
.
result
)
<
300
:
publisher_ops
.
publish_message
(
"events"
,
"SERVICE_API_INVOCATION_SUCCESS"
)
else
:
publisher_ops
.
publish_message
(
"events"
,
"SERVICE_API_INVOCATION_FAILURE"
)
current_app
.
logger
.
debug
(
"Check existing logs"
)
my_query
=
{
'aef_id'
:
aef_id
,
'api_invoker_id'
:
invocationlog
.
api_invoker_id
}
...
...
services/TS29222_CAPIF_Logging_API_Invocation_API/api_invocation_logs/core/publisher.py
0 → 100644
View file @
78fd87c5
import
redis
import
sys
from
flask
import
current_app
class
Publisher
():
def
__init__
(
self
):
self
.
r
=
redis
.
Redis
(
host
=
'redis'
,
port
=
6379
,
db
=
0
)
def
publish_message
(
self
,
channel
,
message
):
self
.
r
.
publish
(
channel
,
message
)
services/TS29222_CAPIF_Logging_API_Invocation_API/requirements.txt
View file @
78fd87c5
...
...
@@ -6,6 +6,7 @@ Flask == 2.0.3
pymongo == 4.0.1
elasticsearch == 8.4.3
flask_jwt_extended == 4.4.4
redis == 4.5.4
opentelemetry-instrumentation == 0.38b0
opentelemetry-instrumentation-flask == 0.38b0
opentelemetry-instrumentation-redis == 0.38b0
...
...
tests/features/CAPIF Api Events/capif_events_api.robot
View file @
78fd87c5
...
...
@@ -5,6 +5,7 @@ Library XML
Resource
/opt/robot-tests/tests/resources/common/basicRequests.robot
Resource
../../resources/common.resource
Suite Teardown
Reset Testing Environment
Test Setup
Reset Testing Environment
...
...
@@ -137,3 +138,46 @@ Deletes an individual CAPIF Event Subscription with invalid SubscriptionId
...
title=Unauthorized
...
detail=User not authorized
...
cause=You are not the owner of this resource
Prueba JMS
[
Tags
]
jms-1
# Log "Prueba 1"
# Wait For Request
# Create a log entry
# [Tags] capif_api_logging_service-1
# Register APF
${register_user_info}
=
Provider Default Registration
# Publish one api
Publish Service Api
${register_user_info}
# Register INVOKER
${register_user_info_invoker}
${url}
${request_body}
=
Invoker Default Onboarding
${discover_response}
=
Get Request Capif
...
${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}
...
server=
${CAPIF_HTTPS_URL}
...
verify=ca.crt
...
username=
${INVOKER_USERNAME}
${api_ids}
${api_names}
=
Get Api Ids And Names From Discover Response
${discover_response}
# Create Log Entry
${request_body}
=
Create Log Entry
...
${register_user_info['aef_id']}
...
${register_user_info_invoker['api_invoker_id']}
...
${api_ids}
...
${api_names}
...
'200'
${resp}
=
Post Request Capif
...
/api-invocation-logs/v1/
${register_user_info['aef_id']}
/logs
...
json=
${request_body}
...
server=
${CAPIF_HTTPS_URL}
...
verify=ca.crt
...
username=
${AEF_PROVIDER_USERNAME}
# Check Results
Check Response Variable Type And Values
${resp}
201
InvocationLog
${resource_url}
=
Check Location Header
${resp}
${LOCATION_LOGGING_RESOURCE_REGEX}
tests/libraries/api_logging_service/bodyRequests.py
View file @
78fd87c5
def
create_log_entry
(
aefId
=
None
,
apiInvokerId
=
None
,
apiId
=
None
,
apiName
=
None
):
def
create_log_entry
(
aefId
,
apiInvokerId
,
apiId
,
apiName
,
result
=
'200'
):
data
=
{
"aefId"
:
aefId
,
"apiInvokerId"
:
apiInvokerId
,
...
...
@@ -11,7 +11,7 @@ def create_log_entry(aefId=None, apiInvokerId=None, apiId=None, apiName=None):
"uri"
:
"http://resource/endpoint"
,
"protocol"
:
"HTTP_1_1"
,
"operation"
:
"GET"
,
"result"
:
"string"
,
"result"
:
result
,
"invocationTime"
:
"2023-03-30T10:30:21.408Z"
,
"invocationLatency"
:
0
,
"inputParameters"
:
"string"
,
...
...
@@ -78,7 +78,7 @@ def create_log_entry(aefId=None, apiInvokerId=None, apiId=None, apiName=None):
}
return
data
def
create_log_entry_bad_service
(
aefId
=
None
,
apiInvokerId
=
None
):
def
create_log_entry_bad_service
(
aefId
,
apiInvokerId
):
data
=
{
"aefId"
:
aefId
,
"apiInvokerId"
:
apiInvokerId
,
...
...
tests/requirements.txt
View file @
78fd87c5
# Requirements file for tests.
robotframework-mongodb-library==3.2
requests==2.28.1
configparser==5.3.0
redis==4.3.4
rfc3987==1.3.8
robotframework-httpctrl
robotframework-archivelibrary == 0.4.2
\ No newline at end of file
robotframework-archivelibrary == 0.4.2
tools/robot/Dockerfile
View file @
78fd87c5
...
...
@@ -25,6 +25,7 @@ VOLUME $ROBOT_RESULTS_DIRECTORY
WORKDIR
$ROBOT_DIRECTORY
ENV
DEBIAN_FRONTEND=noninteractive
RUN
echo
'debconf debconf/frontend select Noninteractive'
| debconf-set-selections
# Install dependencies
RUN
apt-get update
...
...
@@ -49,17 +50,32 @@ RUN apt-get install -y --no-install-recommends \
python3-venv
\
python2.7-dev
\
libssl-dev
\
libldap2-dev libsasl2-dev ldap-utils slapd tox lcov valgrind
\
tshark
libldap2-dev libsasl2-dev ldap-utils slapd tox lcov valgrind
\
tshark
\
nodejs
\
npm
RUN
add-apt-repository ppa:deadsnakes/ppa
RUN
add-apt-repository
-y
ppa:deadsnakes/ppa
RUN
apt-get update
RUN
apt-get
install
-y
--fix-missing
python3.10 python3.10-venv python3.10-dev
RUN
mkdir
/opt/venv
RUN
python3.10
-m
venv /opt/venv
ENV
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers
# Instalación de nvm y node a la última versión
# RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
# # RUN source /root/.bashrc
# # RUN export NVM_DIR="$HOME/.nvm" \
# # [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm \
# # [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# RUN nvm install node
# # RUN npx playwright install
# RUN yes|npx playwright install-deps
ADD
basicRequirements.txt /root/
ADD
basicRobotInstall.sh /root/
...
...
tools/robot/basicRequirements.txt
View file @
78fd87c5
...
...
@@ -13,7 +13,7 @@ certifi==2021.10.8
cffi==1.15.1
chardet==5.0.0
charset-normalizer==2.0.12
click==8.
0.1
click==8.
1.7
configparser==5.3.0
cookiecutter==2.1.1
coverage==4.5.4
...
...
@@ -26,7 +26,6 @@ exceptiongroup==1.0.0rc9
filelock==3.8.0
flake8==3.9.2
h11==0.14.0
robotframework-httpctrl==0.3.1
idna==3.4
iniconfig==1.1.1
invoke==1.6.0
...
...
@@ -69,10 +68,12 @@ redis==4.3.4
rellu==0.7
requests==2.28.1
rfc3987==1.3.8
robotframework==6.0
robotframework==7.0
robotframework-browser==18.3.0
robotframework-httpctrl==0.3.1
robotframework-lint==1.1
robotframework-mongodb-library==3.2
robotframework-pythonlibcore==
3.0.0
robotframework-pythonlibcore==
4.4.1
robotframework-requests==0.9.3
robotframework-seleniumlibrary==6.0.0
robotframework-sshlibrary==3.8.0
...
...
@@ -91,11 +92,11 @@ tox==3.26.0
tqdm==4.64.1
trio==0.22.0
trio-websocket==0.9.2
typing-extensions==
3
.1
0
.0
.2
typing-extensions==
4
.1
1
.0
urllib3==1.26.12
virtualenv==20.16.5
watchdog==0.9.0
webdrivermanager==0.10.0
wrapt==1.1
4.1
wrapt==1.1
5.0
wsproto==1.2.0
xlrd==2.0.1
\ No newline at end of file
tools/robot/basicRobotInstall.sh
View file @
78fd87c5
...
...
@@ -2,6 +2,13 @@
echo
"Installing basic software related with robotFramework"
source
/opt/venv/bin/activate
;
pip
install
--upgrade
pip
pip
install
--upgrade
robotframework
;
pip
install
-r
$1
curl
-o-
https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
source
/root/.bashrc
nvm
install
node
yes
|npx playwright install-deps
pip
install
-r
$1
rfbrowser clean-node
rfbrowser init
--skip-browsers
npx playwright
install
npx playwright install-deps
echo
"Robot framework installed"