Skip to content
README.md 7.41 KiB
Newer Older
Jorge Moratinos's avatar
Jorge Moratinos committed
# Common API Framework (CAPIF)

- [Common API Framework (CAPIF)](#common-api-framework-capif)
- [Repository structure](#repository-structure)
- [CAPIF\_API\_Services](#capif_api_services)
  - [How to run CAPIF services in this Repository](#how-to-run-capif-services-in-this-repository)
    - [Run All CAPIF Services locally with Docker images](#run-all-capif-services-locally-with-docker-images)
    - [Run All CAPIF Services locally with Docker images and deploy monitoring stack](#run-all-capif-services-locally-with-docker-images-and-deploy-monitoring-stack)
    - [Run each service using Docker](#run-each-service-using-docker)
    - [Run each service using Python](#run-each-service-using-python)
- [How to test CAPIF APIs](#how-to-test-capif-apis)
  - [Test Plan Documentation](#test-plan-documentation)
  - [Robot Framework](#robot-framework)
  - [Using Curl](#using-curl)
  - [Using PostMan](#using-postman)
- [Important urls:](#important-urls)
  - [Mongo CAPIF's DB Dashboard](#mongo-capifs-db-dashboard)
  - [Mongo Register's DB Dashboard](#mongo-registers-db-dashboard)
Jorge Moratinos's avatar
Jorge Moratinos committed
- [FAQ Documentation](#faq-documentation)
- [CAPIF Release 0](#capif-release-0)
Jorge Moratinos's avatar
Jorge Moratinos committed


# Repository structure
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
```
CAPIF_API_Services
└───docs
│    └───test_plan
│    └───testing_with_postman
└───services
└───tests
└───tools
    └───robot
    └───open_api_script
```
* **services**: Services developed following CAPIF API specifications. Also, other complementary services (e.g., NGINX and JWTauth services for the authentication of API consuming entities).
* **tools**: Auxiliary tools. Robot Framework related code and OpenAPI scripts.
* **test**: Tests developed using Robot Framework.
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
* **docs**: Documents related to the code in the repository.
  * images: images used in the repository
  * test_plan: test plan descriptions for each API service referring to the test that are executed with the Robot Framework.
  * testing_with_postman: auxiliary JSON file needed for the Postman-based examples.
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
# CAPIF_API_Services
This repository has the python-flask Mockup servers created with openapi-generator related with CAPIF APIS defined here:
[Open API Descriptions of 3GPP 5G APIs]
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
## How to run CAPIF services in this Repository
Capif services are developed under /service/ folder.
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
### Run All CAPIF Services locally with Docker images
To run using docker and docker compose, version 2.10 or higher, you must ensure you have that tools installed at your machine. Also to simplify the process, we have 3 script to control docker images to deploy, check and cleanup.
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
To run all CAPIF APIs locally using docker and docker-compose you can execute:
```
cd services/
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
./run.sh
```
This will build and run all services using docker images, including mongodb and nginx locally and in background, and import ca.crt to nginx.
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
Nginx deployed by default use **capifcore** hostname, but can add a parameter when run.sh is executed setting a different hostname, for example,
Jorge Moratinos's avatar
Jorge Moratinos committed
```
./run.sh -c openshift.evolved-5g.eu
```

Also you can run monitoring just using option -m true, for example:
```
./run.sh -m true
./run.sh -m true -c openshift.evolved-5g.eu
Jorge Moratinos's avatar
Jorge Moratinos committed
```

Jorge Moratinos's avatar
Jorge Moratinos committed
If you want to check if all CAPIF services are running properly in local machine after execute run.sh, we can use:
```
./check_services_are_running.sh
```
This shell script will return 0 if all services are running properly.
Jorge Moratinos's avatar
Jorge Moratinos committed

When we need to stop all CAPIF services, we can use next bash script:
Jorge Moratinos's avatar
Jorge Moratinos committed
```
./clean_capif_docker_services.sh -a
Jorge Moratinos's avatar
Jorge Moratinos committed
```
Jorge Moratinos's avatar
Jorge Moratinos committed

NOTE: You can use different flags if you only want to stop some of them, please check help using
Jorge Moratinos's avatar
Jorge Moratinos committed
```
./clean_capif_docker_services.sh -h

Usage: clean_capif_docker_services.sh <options>
       -c : clean capif services
       -v : clean vault service
       -r : clean register service
       -m : clean monitoring service
       -a : clean all services
       -h : show this help
``````
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
This shell script will remove and clean all CAPIF services started previously with run.sh
Jorge Moratinos's avatar
Jorge Moratinos committed

On the other hand you can check logs using show_logs.sh script, please check options:
```
./show_logs.sh
You must specify an option before run script.
Usage: ./show_logs.sh <options>
       -c : Show capif services
       -v : Show vault service
       -r : Show register service
       -m : Show monitoring service
       -a : Show all services
       -f : Follow log output
       -h : Show this help
```
You can also use option -f in order to live follow log output

Jorge Moratinos's avatar
Jorge Moratinos committed
### Run All CAPIF Services locally with Docker images and deploy monitoring stack
It is now possible to deploy a monitoring stack for CAPIF with Grafana, Prometheus, FluentBit, Loki, Cadvisor, Tempo and Opentelemetry.
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
To deploy CAPIF together with the monitoring stack, it is only necessary to execute the following.
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
```
Jorge Moratinos's avatar
Jorge Moratinos committed
```
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
After they have been built, the different panels can be consulted in Grafana at the url
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
```
http://localhost:3000
Jorge Moratinos's avatar
Jorge Moratinos committed
```
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
By default, the monitoring option is set to false. Once up, all data sources and dashboards are automatically provisioned
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
### Run each service using Docker
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
Also you can run service by service using docker:
```
cd <Service>
docker build -t capif_security .
docker run -p 8080:8080 capif_security
```

### Run each service using Python

Run using python
```
cd <Service>
pip3 install -r requirements.txt
python3 -m <service>
```

# How to test CAPIF APIs
The above APIs can be tested either with "curl" command, POSTMAN tool or running developed tests with Robot Framework.
## Test Plan Documentation

Complete documentation of tests is here: [Test Plan Directory]
## Robot Framework
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
In order to ensure modifications over CAPIF services still accomplish the required functionality, Robot Framework test suite must be success.
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
Test suite implemented accomplish requirements described under test plan at [Test Plan Directory] folder.
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
Please go to [Testing with Robot Framework] Section
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
## Using Curl
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
Please go to [Testing Using Curl] section.
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
## Using PostMan
You can test the CAPIF flow using the Postman tool. To do this, we have created a collection with some examples of CAPIF requests with everything necessary to carry them out.

For more information on how to test the APIs with POSTMAN, follow this [Document](docs/testing_with_postman/README.md).
Also you have here the [POSTMAN Collection](docs/testing_with_postman/CAPIF.postman_collection.json)

# Important urls:

## Mongo CAPIF's DB Dashboard
Jorge Moratinos's avatar
Jorge Moratinos committed
```
http://localhost:8082/ (if accessed from localhost) 
http://<Mongo CAPIF Express Host IP>:8082/ (if accessed from another host)
Jorge Moratinos's avatar
Jorge Moratinos committed
```

## Mongo Register's DB Dashboard
```
http://localhost:8083/ (if accessed from localhost) 

or

http://<Mongo Register Express Host IP>:8083/ (if accessed from another host)
```

Jorge Moratinos's avatar
Jorge Moratinos committed
# FAQ Documentation
Jorge Moratinos's avatar
Jorge Moratinos committed

Jorge Moratinos's avatar
Jorge Moratinos committed
Frequently asked questions can be found here: [FAQ Directory]
Jorge Moratinos's avatar
Jorge Moratinos committed

# CAPIF Release 0
Jorge Moratinos's avatar
Jorge Moratinos committed

The APIs included in release 0 are:
Jorge Moratinos's avatar
Jorge Moratinos committed
- JWT Authentication APIs
- CAPIF Invoker Management API
- CAPIF Publish API
- CAPIF Discover API
- CAPIF Security API
- CAPIF Events API
- CAPIF Provider Management API
Jorge Moratinos's avatar
Jorge Moratinos committed

Testing Suite of all services with robot.
Also Postman suite to a simple test.
Jorge Moratinos's avatar
Jorge Moratinos committed
[Open API Descriptions of 3GPP 5G APIs]: https://forge.3gpp.org/rep/all/5G_APIs  "Open API Descriptions of 3GPP 5G APIs"
[Test Plan Directory]: ./docs/test_plan/README.md  "Test Plan Directory"
[Testing Using Curl]: ./docs/testing_with_curl/README.md  "Testing Using Curl"
[Testing with Robot Framework]: ./docs/testing_with_robot/README.md  "Testing with Robot Framework"
[FAQ Directory]: ./FAQ.md "FAQ directory"