From 794e34fa14ff5993580b4bccbd3f2d4eb0bc14ea Mon Sep 17 00:00:00 2001 From: Pelayo Torres Date: Wed, 10 Apr 2024 14:30:02 +0200 Subject: [PATCH 1/8] New register Service with httpauth and uuid --- .../controllers/default_controller.py | 9 +-- .../core/apiinvokerenrolmentdetails.py | 9 +-- .../api_invoker_management/db/db.py | 28 +------- .../controllers/default_controller.py | 9 +-- .../core/provider_enrolment_details_api.py | 10 ++- .../api_provider_management/db/db.py | 27 -------- services/register/config.yaml | 4 ++ services/register/register_prepare.sh | 23 ++----- .../register/register_service/__main__.py | 56 ++++++++++++++-- .../register/register_service/auth_utils.py | 8 --- .../controllers/register_controller.py | 55 ++++++++++++---- .../core/register_operations.py | 65 +++++++++---------- services/register/requirements.txt | 1 + 13 files changed, 148 insertions(+), 156 deletions(-) delete mode 100644 services/register/register_service/auth_utils.py diff --git a/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/controllers/default_controller.py b/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/controllers/default_controller.py index 456b4ec..27eb1c8 100644 --- a/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/controllers/default_controller.py +++ b/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/controllers/default_controller.py @@ -104,18 +104,13 @@ def onboarded_invokers_post(body): # noqa: E501 """ identity = get_jwt_identity() - username, role = identity.split() - - if role != "invoker": - prob = ProblemDetails(title="Unauthorized", status=401, detail="Role not authorized for this API route", - cause="User role must be invoker") - return Response(json.dumps(prob, cls=JSONEncoder), status=401, mimetype='application/json') + username, uuid = identity.split() if connexion.request.is_json: body = APIInvokerEnrolmentDetails.from_dict(connexion.request.get_json()) # noqa: E501 current_app.logger.info("Creating Invoker") - res = invoker_operations.add_apiinvokerenrolmentdetail(body, username) + res = invoker_operations.add_apiinvokerenrolmentdetail(body, username, uuid) if res.status_code == 201: current_app.logger.info("Invoker Created") publisher_ops.publish_message("events", "API_INVOKER_ONBOARDED") diff --git a/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/apiinvokerenrolmentdetails.py b/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/apiinvokerenrolmentdetails.py index 1d79405..dc186e4 100644 --- a/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/apiinvokerenrolmentdetails.py +++ b/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/apiinvokerenrolmentdetails.py @@ -52,13 +52,11 @@ class InvokerManagementOperations(Resource): self.config = Config().get_config() - def add_apiinvokerenrolmentdetail(self, apiinvokerenrolmentdetail, username): + def add_apiinvokerenrolmentdetail(self, apiinvokerenrolmentdetail, username, uuid): mycol = self.db.get_col_by_name(self.db.invoker_enrolment_details) - register = self.db.get_col_by_name_register(self.db.capif_users) #try: - current_app.logger.debug("Creating invoker resource") res = mycol.find_one({'onboarding_information.api_invoker_public_key': apiinvokerenrolmentdetail.onboarding_information.api_invoker_public_key}) @@ -83,9 +81,10 @@ class InvokerManagementOperations(Resource): # Onboarding Date Record invoker_dict = apiinvokerenrolmentdetail.to_dict() invoker_dict["onboarding_date"] = datetime.now() + invoker_dict["username"]=username + invoker_dict["uuid"]=uuid mycol.insert_one(apiinvokerenrolmentdetail.to_dict()) - register.update_one({'username':username}, {"$push":{'list_invokers':api_invoker_id}}) current_app.logger.debug("Invoker inserted in database") current_app.logger.debug("Netapp onboarded sucessfuly") @@ -141,7 +140,6 @@ class InvokerManagementOperations(Resource): def remove_apiinvokerenrolmentdetail(self, onboard_id): mycol = self.db.get_col_by_name(self.db.invoker_enrolment_details) - register = self.db.get_col_by_name_register(self.db.capif_users) try: current_app.logger.debug("Removing invoker resource") result = self.__check_api_invoker_id(onboard_id) @@ -150,7 +148,6 @@ class InvokerManagementOperations(Resource): return result mycol.delete_one({'api_invoker_id':onboard_id}) - register.update_one({'list_invokers':onboard_id}, {"$pull":{'list_invokers':onboard_id}}) self.auth_manager.remove_auth_invoker(onboard_id) current_app.logger.debug("Invoker resource removed from database") diff --git a/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/db/db.py b/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/db/db.py index 32a34b8..5bfcd0b 100644 --- a/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/db/db.py +++ b/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/db/db.py @@ -15,7 +15,6 @@ class MongoDatabse(): def __init__(self): self.config = Config().get_config() self.db = self.__connect() - self.register = self.__connect_register() self.invoker_enrolment_details = self.config['mongo']['col'] self.capif_users = self.config['mongo']['capif_users_col'] self.service_col = self.config['mongo']["service_col"] @@ -25,10 +24,6 @@ class MongoDatabse(): def get_col_by_name(self, name): return self.db[name].with_options(codec_options=CodecOptions(tz_aware=True)) - def get_col_by_name_register(self, name): - return self.register[name].with_options(codec_options=CodecOptions(tz_aware=True)) - - def __connect(self, max_retries=3, retry_delay=1): retries = 0 @@ -48,29 +43,8 @@ class MongoDatabse(): print(f"Reconnecting... Retry {retries} of {max_retries}") time.sleep(retry_delay) return None - - def __connect_register(self, max_retries=3, retry_delay=1): - - retries = 0 - - while retries < max_retries: - try: - uri = f"mongodb://{self.config['mongo_register']['user']}:{self.config['mongo_register']['password']}@" \ - f"{self.config['mongo_register']['host']}:{self.config['mongo_register']['port']}" - - - client = MongoClient(uri) - mydb = client[self.config['mongo_register']['db']] - mydb.command("ping") - return mydb - except AutoReconnect: - retries += 1 - print(f"Reconnecting... Retry {retries} of {max_retries}") - time.sleep(retry_delay) - return None def close_connection(self): if self.db.client: self.db.client.close() - if self.register.client: - self.register.client.close() + diff --git a/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/controllers/default_controller.py b/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/controllers/default_controller.py index 70e5373..f5bcf16 100644 --- a/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/controllers/default_controller.py +++ b/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/controllers/default_controller.py @@ -59,20 +59,15 @@ def registrations_post(body): # noqa: E501 """ identity = get_jwt_identity() - username, role = identity.split() + username, uuid = identity.split() current_app.logger.info("Registering Provider Domain") - if role != "provider": - prob = ProblemDetails(title="Unauthorized", status=401, detail="Role not authorized for this API route", - cause="User role must be provider") - return Response(json.dumps(prob, cls=JSONEncoder), status=401, mimetype='application/json') - if connexion.request.is_json: body = APIProviderEnrolmentDetails.from_dict(connexion.request.get_json()) # noqa: E501 - res = provider_management_ops.register_api_provider_enrolment_details(body, username) + res = provider_management_ops.register_api_provider_enrolment_details(body, username, uuid) return res diff --git a/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/core/provider_enrolment_details_api.py b/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/core/provider_enrolment_details_api.py index 18c5e5b..6ba9043 100644 --- a/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/core/provider_enrolment_details_api.py +++ b/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/core/provider_enrolment_details_api.py @@ -31,10 +31,9 @@ class ProviderManagementOperations(Resource): Resource.__init__(self) self.auth_manager = AuthManager() - def register_api_provider_enrolment_details(self, api_provider_enrolment_details, username): + def register_api_provider_enrolment_details(self, api_provider_enrolment_details, username, uuid): try: mycol = self.db.get_col_by_name(self.db.provider_enrolment_details) - register = self.db.get_col_by_name_register(self.db.capif_users) current_app.logger.debug("Creating api provider domain") search_filter = {'reg_sec': api_provider_enrolment_details.reg_sec} @@ -58,10 +57,11 @@ class ProviderManagementOperations(Resource): # Onboarding Date Record provider_dict = api_provider_enrolment_details.to_dict() provider_dict["onboarding_date"] = datetime.now() + provider_dict["username"] = username + provider_dict["uuid"] = uuid mycol.insert_one(provider_dict) - register.update_one({'username':username}, {"$push":{'list_providers':api_provider_enrolment_details.api_prov_dom_id}}) - + current_app.logger.debug("Provider inserted in database") res = make_response(object=api_provider_enrolment_details, status=201) @@ -76,7 +76,6 @@ class ProviderManagementOperations(Resource): def delete_api_provider_enrolment_details(self, api_prov_dom_id): try: mycol = self.db.get_col_by_name(self.db.provider_enrolment_details) - register = self.db.get_col_by_name_register(self.db.capif_users) current_app.logger.debug("Deleting provider domain") result = self.__check_api_provider_domain(api_prov_dom_id) @@ -89,7 +88,6 @@ class ProviderManagementOperations(Resource): amf_id = [ provider_func['api_prov_func_id'] for provider_func in result["api_prov_funcs"] if provider_func['api_prov_func_role'] == 'AMF' ] mycol.delete_one({'api_prov_dom_id': api_prov_dom_id}) - register.update_one({'list_providers':api_prov_dom_id}, {"$pull":{'list_providers':api_prov_dom_id}}) out = "The provider matching apiProvDomainId " + api_prov_dom_id + " was offboarded." current_app.logger.debug("Removed provider domain from database") diff --git a/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/db/db.py b/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/db/db.py index a5d843a..bb08025 100644 --- a/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/db/db.py +++ b/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/db/db.py @@ -16,17 +16,12 @@ class MongoDatabse(): def __init__(self): self.config = Config().get_config() self.db = self.__connect() - self.register = self.__connect_register() self.provider_enrolment_details = self.config['mongo']['col'] self.capif_users = self.config['mongo']['capif_users'] self.certs_col = self.config['mongo']['certs_col'] def get_col_by_name(self, name): return self.db[name].with_options(codec_options=CodecOptions(tz_aware=True)) - def get_col_by_name_register(self, name): - return self.register[name].with_options(codec_options=CodecOptions(tz_aware=True)) - - def __connect(self, max_retries=3, retry_delay=1): retries = 0 @@ -44,30 +39,8 @@ class MongoDatabse(): time.sleep(retry_delay) return None - def __connect_register(self, max_retries=3, retry_delay=1): - - retries = 0 - - while retries < max_retries: - try: - uri = f"mongodb://{self.config['mongo_register']['user']}:{self.config['mongo_register']['password']}@" \ - f"{self.config['mongo_register']['host']}:{self.config['mongo_register']['port']}" - - - client = MongoClient(uri) - mydb = client[self.config['mongo_register']['db']] - mydb.command("ping") - return mydb - except AutoReconnect: - retries += 1 - print(f"Reconnecting... Retry {retries} of {max_retries}") - time.sleep(retry_delay) - return None - def close_connection(self): if self.db.client: self.db.client.close() - if self.register.client: - self.register.client.close() diff --git a/services/register/config.yaml b/services/register/config.yaml index 2ac53bd..3c33fa0 100644 --- a/services/register/config.yaml +++ b/services/register/config.yaml @@ -12,3 +12,7 @@ ca_factory: { "token": "dev-only-token" } +register: { + register_uuid: '6ba7b810-9dad-11d1-80b4-00c04fd430c8', + admin_users: {admin: "password123"} +} \ No newline at end of file diff --git a/services/register/register_prepare.sh b/services/register/register_prepare.sh index de69be7..4a49b87 100644 --- a/services/register/register_prepare.sh +++ b/services/register/register_prepare.sh @@ -1,27 +1,16 @@ #!/bin/bash -CERTS_FOLDER="/usr/src/app/register_service" +CERTS_FOLDER="/usr/src/app/register_service/certs" cd $CERTS_FOLDER -VAULT_ADDR="http://$VAULT_HOSTNAME:$VAULT_PORT" -VAULT_TOKEN=$VAULT_ACCESS_TOKEN - -curl -k -retry 30 \ - --retry-all-errors \ - --connect-timeout 5 \ - --max-time 10 \ - --retry-delay 10 \ - --retry-max-time 300 \ - --header "X-Vault-Token: $VAULT_TOKEN" \ - --request GET "$VAULT_ADDR/v1/secret/data/server_cert/private" 2>/dev/null | jq -r '.data.data.key' -j > $CERTS_FOLDER/server.key - openssl req -x509 \ -sha256 -days 356 \ -nodes \ -newkey rsa:2048 \ -subj "/CN=register/C=ES/L=Madrid" \ - -keyout /usr/src/app/register_service/registerCA.key -out /usr/src/app/register_service/registerCA.crt + -keyout /usr/src/app/register_service/certs/registerCA.key -out /usr/src/app/register_service/certs/registerCA.crt + -openssl genrsa -out /usr/src/app/register_service/register_key.key 2048 +openssl genrsa -out /usr/src/app/register_service/certs/register_key.key 2048 COUNTRY="ES" # 2 letter country-code STATE="Madrid" # state or province name @@ -37,7 +26,7 @@ COMPANY="" # company name # DAYS="-days 365" # create the certificate request -cat <<__EOF__ | openssl req -new $DAYS -key /usr/src/app/register_service/register_key.key -out /usr/src/app/register_service/register.csr +cat <<__EOF__ | openssl req -new $DAYS -key /usr/src/app/register_service/certs/register_key.key -out /usr/src/app/register_service/certs/register.csr $COUNTRY $STATE $LOCALITY @@ -49,7 +38,7 @@ $CHALLENGE $COMPANY __EOF__ -openssl x509 -req -in /usr/src/app/register_service/register.csr -CA /usr/src/app/register_service/registerCA.crt -CAkey /usr/src/app/register_service/registerCA.key -CAcreateserial -out /usr/src/app/register_service/register_cert.crt -days 365 -sha256 +openssl x509 -req -in /usr/src/app/register_service/certs/register.csr -CA /usr/src/app/register_service/certs/registerCA.crt -CAkey /usr/src/app/register_service/certs/registerCA.key -CAcreateserial -out /usr/src/app/register_service/certs/register_cert.crt -days 365 -sha256 cd /usr/src/app/ python3 -m register_service \ No newline at end of file diff --git a/services/register/register_service/__main__.py b/services/register/register_service/__main__.py index 5225f78..2548ebd 100644 --- a/services/register/register_service/__main__.py +++ b/services/register/register_service/__main__.py @@ -1,27 +1,73 @@ import os -import base64 from flask import Flask from .controllers.register_controller import register_routes from flask_jwt_extended import JWTManager +from OpenSSL.crypto import PKey, TYPE_RSA, X509Req, dump_certificate_request, FILETYPE_PEM, dump_privatekey +import requests +import json +from .config import Config app = Flask(__name__) jwt = JWTManager(app) -with open("/usr/src/app/register_service/server.key", "rb") as key_file: - key_data = key_file.read() +config = Config().get_config() +# Create a superadmin CSR and keys +key = PKey() +key.generate_key(TYPE_RSA, 2048) +req = X509Req() +req.get_subject().O = 'Telefonica I+D' +req.get_subject().OU = 'Innovation' +req.get_subject().L = 'Madrid' +req.get_subject().ST = 'Madrid' +req.get_subject().C = 'ES' +req.get_subject().emailAddress = 'inno@tid.es' +req.set_pubkey(key) +req.sign(key, 'sha256') + +csr_request = dump_certificate_request(FILETYPE_PEM, req) +private_key = dump_privatekey(FILETYPE_PEM, key) + +# Save superadmin private key +key_file = open("register_service/certs/superadmin.key", 'wb+') +key_file.write(bytes(private_key)) +key_file.close() + +# Request superadmin certificate +url = 'http://{}:{}/v1/pki_int/sign/my-ca'.format(config["ca_factory"]["url"], config["ca_factory"]["port"]) +headers = {'X-Vault-Token': f"{config["ca_factory"]["token"]}"} +data = { + 'format':'pem_bundle', + 'ttl': '43000h', + 'csr': csr_request, + 'common_name': "superadmin" +} + +response = requests.request("POST", url, headers=headers, data=data, verify = False) +superadmin_cert = json.loads(response.text)['data']['certificate'] + +# Svae the superadmin certificate +cert_file = open("register_service/certs/superadmin.crt", 'wb') +cert_file.write(bytes(superadmin_cert, 'utf-8')) +cert_file.close() + +# Request CAPIF private key to encode the token +url = 'http://{}:{}/v1/secret/data/server_cert/private'.format(config["ca_factory"]["url"], config["ca_factory"]["port"]) +headers = {'X-Vault-Token': f"{config["ca_factory"]["token"]}"} +response = requests.request("GET", url, headers=headers, verify = False) + +key_data = json.loads(response.text)["data"]["data"]["key"] app.config['JWT_ALGORITHM'] = 'RS256' app.config['JWT_PRIVATE_KEY'] = key_data app.register_blueprint(register_routes) - #---------------------------------------- # launch #---------------------------------------- if __name__ == "__main__": - app.run(debug=True, host = '0.0.0.0', port=8080, ssl_context= ("/usr/src/app/register_service/register_cert.crt", "/usr/src/app/register_service/register_key.key")) + app.run(debug=True, host = '0.0.0.0', port=8080, ssl_context= ("/usr/src/app/register_service/certs/register_cert.crt", "/usr/src/app/register_service/certs/register_key.key")) diff --git a/services/register/register_service/auth_utils.py b/services/register/register_service/auth_utils.py deleted file mode 100644 index f799772..0000000 --- a/services/register/register_service/auth_utils.py +++ /dev/null @@ -1,8 +0,0 @@ -import bcrypt - -def hash_password(password): - hashed_password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()) - return hashed_password - -def check_password(input_password, stored_password): - return bcrypt.checkpw(input_password.encode('utf-8'), stored_password) \ No newline at end of file diff --git a/services/register/register_service/controllers/register_controller.py b/services/register/register_service/controllers/register_controller.py index 71af562..119e493 100644 --- a/services/register/register_service/controllers/register_controller.py +++ b/services/register/register_service/controllers/register_controller.py @@ -1,39 +1,68 @@ #!/usr/bin/env python3 -from flask import Flask, jsonify, request, Blueprint -from flask_jwt_extended import JWTManager, jwt_required, create_access_token -from pymongo import MongoClient +from flask import current_app, Flask, jsonify, request, Blueprint from ..core.register_operations import RegisterOperations -import secrets +from ..config import Config +from flask_httpauth import HTTPBasicAuth + +auth = HTTPBasicAuth() + +config = Config().get_config() + +@auth.verify_password +def verify_password(username, password): + users = register_operation.get_users()[0].json["users"] + if username in config["register"]["admin_users"] and password == config["register"]["admin_users"][username]: + return username, "admin" + for user in users: + if user["username"] == username and user["password"]==password: + return username, "client" + +def admin_required(fn): + def wrapper(*args, **kwargs): + username, role = auth.current_user() + if role == 'admin': + return fn(*args, **kwargs) + else: + return {"Access denied. Administrator privileges required."}, 403 + wrapper.__name__ = fn.__name__ + return wrapper register_routes = Blueprint("register_routes", __name__) register_operation = RegisterOperations() -@register_routes.route("/register", methods=["POST"]) +@register_routes.route("/createUser", methods=["POST"]) +@auth.login_required +@admin_required def register(): username = request.json["username"] password = request.json["password"] description = request.json["description"] - role = request.json["role"] - cn = request.json["cn"] - if role != "invoker" and role != "provider": - return jsonify(message="Role must be invoker or provider"), 400 - - - return register_operation.register_user(username, password, description, cn, role) + email = request.json["email"] + return register_operation.register_user(username, password, description, email) @register_routes.route("/getauth", methods=["POST"]) +@auth.login_required def getauth(): username = request.json["username"] password = request.json["password"] return register_operation.get_auth(username, password) -@register_routes.route("/remove", methods=["DELETE"]) +@register_routes.route("/deleteUser", methods=["DELETE"]) +@auth.login_required +@admin_required def remove(): username = request.json["username"] password = request.json["password"] return register_operation.remove_user(username, password) + + +@register_routes.route("/getUsers", methods=["GET"]) +@auth.login_required +@admin_required +def getUsers(): + return register_operation.get_users() diff --git a/services/register/register_service/core/register_operations.py b/services/register/register_service/core/register_operations.py index bef2f65..a6e8992 100644 --- a/services/register/register_service/core/register_operations.py +++ b/services/register/register_service/core/register_operations.py @@ -1,14 +1,14 @@ -from flask import Flask, jsonify, request, current_app +from flask import current_app, Flask, jsonify, request, Response from flask_jwt_extended import create_access_token from ..db.db import MongoDatabse from datetime import datetime from ..config import Config -from register_service import auth_utils import secrets import requests import json import sys - +import uuid + class RegisterOperations: def __init__(self): @@ -16,28 +16,20 @@ class RegisterOperations: self.mimetype = 'application/json' self.config = Config().get_config() - def register_user(self, username, password, description, cn, role): + def register_user(self, username, password, description, email): mycol = self.db.get_col_by_name(self.db.capif_users) exist_user = mycol.find_one({"username": username}) if exist_user: return jsonify("user already exists"), 409 + + name_space = uuid.UUID(self.config["register"]["register_uuid"]) + user_uuid = str(uuid.uuid5(name_space, username)) - hashed_password = auth_utils.hash_password(password) - user_info = dict(_id=secrets.token_hex(7), username=username, password=hashed_password, role=role, description=description, cn=cn, list_invokers=[], list_providers=[]) + user_info = dict(uuid=user_uuid, username=username, password=password, description=description, email=email, onboarding_date=datetime.now()) obj = mycol.insert_one(user_info) - if role == "invoker": - return jsonify(message="invoker registered successfully", - id=obj.inserted_id, - ccf_onboarding_url="api-invoker-management/v1/onboardedInvokers", - ccf_discover_url="service-apis/v1/allServiceAPIs?api-invoker-id="), 201 - else: - return jsonify(message="provider" + " registered successfully", - id=obj.inserted_id, - ccf_api_onboarding_url="api-provider-management/v1/registrations", - ccf_publish_url="published-apis/v1//service-apis"), 201 - + return jsonify(message="invoker registered successfully", uuid=user_uuid), 201 def get_auth(self, username, password): @@ -45,16 +37,12 @@ class RegisterOperations: try: - exist_user = mycol.find_one({"username": username}) + exist_user = mycol.find_one({"username": username, "password": password}) if exist_user is None: - return jsonify("No user with these credentials"), 400 + return jsonify("Not exister user with this credentials"), 400 - stored_password = exist_user["password"] - if not auth_utils.check_password(password, stored_password): - return jsonify("No user with these credentials"), 400 - - access_token = create_access_token(identity=(username + " " + exist_user["role"])) + access_token = create_access_token(identity=(username + " " + exist_user["uuid"])) url = f"http://{self.config['ca_factory']['url']}:{self.config['ca_factory']['port']}/v1/secret/data/ca" headers = { @@ -62,7 +50,13 @@ class RegisterOperations: } response = requests.request("GET", url, headers=headers, verify = False) response_payload = json.loads(response.text) - return jsonify(message="Token and CA root returned successfully", access_token=access_token, ca_root=response_payload['data']['data']['ca']), 200 + return jsonify(message="Token and CA root returned successfully", + access_token=access_token, + ca_root=response_payload['data']['data']['ca'], + ccf_api_onboarding_url="api-provider-management/v1/registrations", + ccf_publish_url="published-apis/v1//service-apis", + ccf_onboarding_url="api-invoker-management/v1/onboardedInvokers", + ccf_discover_url="service-apis/v1/allServiceAPIs?api-invoker-id="), 200 except Exception as e: return jsonify(message=f"Errors when try getting auth: {e}"), 500 @@ -71,17 +65,22 @@ class RegisterOperations: mycol = self.db.get_col_by_name(self.db.capif_users) try: - exist_user = mycol.find_one({"username": username}) + mycol.delete_one({"username": username, "password": password}) + + + # Request to the helper to delete invokers and providers - if exist_user is None: - return jsonify("No user with these credentials"), 400 - stored_password = exist_user["password"] - if not auth_utils.check_password(password, stored_password): - return jsonify("No user with these credentials"), 400 - - mycol.delete_one({"username": username}) return jsonify(message="User removed successfully"), 204 except Exception as e: return jsonify(message=f"Errors when try remove user: {e}"), 500 + + def get_users(self): + mycol = self.db.get_col_by_name(self.db.capif_users) + + try: + users=list(mycol.find({}, {"_id":0})) + return jsonify(message="Users successfully obtained", users=users), 200 + except Exception as e: + return jsonify(message=f"Error trying to get users: {e}"), 500 diff --git a/services/register/requirements.txt b/services/register/requirements.txt index 05b9f7d..c5446a6 100644 --- a/services/register/requirements.txt +++ b/services/register/requirements.txt @@ -7,3 +7,4 @@ pyopenssl pyyaml requests bcrypt +flask_httpauth \ No newline at end of file -- GitLab From a2ac3ccf377fa0a166827f5f5b33427134bd8703 Mon Sep 17 00:00:00 2001 From: Pelayo Torres Date: Thu, 11 Apr 2024 09:20:08 +0200 Subject: [PATCH 2/8] ca root caught in main and getauth GET method without body --- .../register/register_service/__main__.py | 14 ++++++++++- .../controllers/register_controller.py | 9 +++---- .../core/register_operations.py | 25 ++++++++----------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/services/register/register_service/__main__.py b/services/register/register_service/__main__.py index 2548ebd..373cfd2 100644 --- a/services/register/register_service/__main__.py +++ b/services/register/register_service/__main__.py @@ -48,11 +48,23 @@ data = { response = requests.request("POST", url, headers=headers, data=data, verify = False) superadmin_cert = json.loads(response.text)['data']['certificate'] -# Svae the superadmin certificate +# Save the superadmin certificate cert_file = open("register_service/certs/superadmin.crt", 'wb') cert_file.write(bytes(superadmin_cert, 'utf-8')) cert_file.close() +url = f"http://{config['ca_factory']['url']}:{config['ca_factory']['port']}/v1/secret/data/ca" +headers = { + + 'X-Vault-Token': config['ca_factory']['token'] +} +response = requests.request("GET", url, headers=headers, verify = False) + +ca_root = json.loads(response.text)['data']['data']['ca'] +cert_file = open("register_service/certs/ca_root.crt", 'wb') +cert_file.write(bytes(ca_root, 'utf-8')) +cert_file.close() + # Request CAPIF private key to encode the token url = 'http://{}:{}/v1/secret/data/server_cert/private'.format(config["ca_factory"]["url"], config["ca_factory"]["port"]) headers = {'X-Vault-Token': f"{config["ca_factory"]["token"]}"} diff --git a/services/register/register_service/controllers/register_controller.py b/services/register/register_service/controllers/register_controller.py index 119e493..5efd21e 100644 --- a/services/register/register_service/controllers/register_controller.py +++ b/services/register/register_service/controllers/register_controller.py @@ -43,13 +43,12 @@ def register(): return register_operation.register_user(username, password, description, email) -@register_routes.route("/getauth", methods=["POST"]) +@register_routes.route("/getauth", methods=["GET"]) @auth.login_required def getauth(): - username = request.json["username"] - password = request.json["password"] - - return register_operation.get_auth(username, password) + username, role = auth.current_user() + + return register_operation.get_auth(username) @register_routes.route("/deleteUser", methods=["DELETE"]) @auth.login_required diff --git a/services/register/register_service/core/register_operations.py b/services/register/register_service/core/register_operations.py index a6e8992..ab68c5e 100644 --- a/services/register/register_service/core/register_operations.py +++ b/services/register/register_service/core/register_operations.py @@ -1,12 +1,9 @@ -from flask import current_app, Flask, jsonify, request, Response +from flask import Flask, jsonify, request, Response from flask_jwt_extended import create_access_token from ..db.db import MongoDatabse from datetime import datetime from ..config import Config -import secrets -import requests -import json -import sys +import base64 import uuid class RegisterOperations: @@ -31,28 +28,26 @@ class RegisterOperations: return jsonify(message="invoker registered successfully", uuid=user_uuid), 201 - def get_auth(self, username, password): + def get_auth(self, username): mycol = self.db.get_col_by_name(self.db.capif_users) try: - exist_user = mycol.find_one({"username": username, "password": password}) + exist_user = mycol.find_one({"username": username}) if exist_user is None: return jsonify("Not exister user with this credentials"), 400 access_token = create_access_token(identity=(username + " " + exist_user["uuid"])) - url = f"http://{self.config['ca_factory']['url']}:{self.config['ca_factory']['port']}/v1/secret/data/ca" - headers = { + + cert_file = open("register_service/certs/ca_root.crt", 'rb') + ca_root = cert_file.read() + cert_file.close() - 'X-Vault-Token': self.config['ca_factory']['token'] - } - response = requests.request("GET", url, headers=headers, verify = False) - response_payload = json.loads(response.text) return jsonify(message="Token and CA root returned successfully", - access_token=access_token, - ca_root=response_payload['data']['data']['ca'], + access_token=access_token, + ca_root=ca_root.decode("utf-8"), ccf_api_onboarding_url="api-provider-management/v1/registrations", ccf_publish_url="published-apis/v1//service-apis", ccf_onboarding_url="api-invoker-management/v1/onboardedInvokers", -- GitLab From e22523bec105ca305b59c48413c41d0559eafce3 Mon Sep 17 00:00:00 2001 From: Pelayo Torres Date: Thu, 11 Apr 2024 09:50:36 +0200 Subject: [PATCH 3/8] jsonify denied message --- .../register_service/controllers/register_controller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/register/register_service/controllers/register_controller.py b/services/register/register_service/controllers/register_controller.py index 5efd21e..9537808 100644 --- a/services/register/register_service/controllers/register_controller.py +++ b/services/register/register_service/controllers/register_controller.py @@ -25,7 +25,7 @@ def admin_required(fn): if role == 'admin': return fn(*args, **kwargs) else: - return {"Access denied. Administrator privileges required."}, 403 + return jsonify(message="Access denied. Administrator privileges required."), 403 wrapper.__name__ = fn.__name__ return wrapper @@ -47,7 +47,7 @@ def register(): @auth.login_required def getauth(): username, role = auth.current_user() - + return register_operation.get_auth(username) @register_routes.route("/deleteUser", methods=["DELETE"]) -- GitLab From 3bbb84cd5fbd6956f0145400d4cf9cc5375afea6 Mon Sep 17 00:00:00 2001 From: Pelayo Torres Date: Wed, 17 Apr 2024 11:33:23 +0200 Subject: [PATCH 4/8] Admin security with tokens --- services/register/config.yaml | 2 + .../register/register_service/__main__.py | 7 +- .../controllers/register_controller.py | 98 +++++++++++++------ .../core/register_operations.py | 9 +- 4 files changed, 82 insertions(+), 34 deletions(-) diff --git a/services/register/config.yaml b/services/register/config.yaml index 3c33fa0..bc1370f 100644 --- a/services/register/config.yaml +++ b/services/register/config.yaml @@ -14,5 +14,7 @@ ca_factory: { register: { register_uuid: '6ba7b810-9dad-11d1-80b4-00c04fd430c8', + refresh_expiration: 30, #days + token_expiration: 10, #mins admin_users: {admin: "password123"} } \ No newline at end of file diff --git a/services/register/register_service/__main__.py b/services/register/register_service/__main__.py index 373cfd2..12f6ffd 100644 --- a/services/register/register_service/__main__.py +++ b/services/register/register_service/__main__.py @@ -6,11 +6,12 @@ from flask_jwt_extended import JWTManager from OpenSSL.crypto import PKey, TYPE_RSA, X509Req, dump_certificate_request, FILETYPE_PEM, dump_privatekey import requests import json +import jwt from .config import Config app = Flask(__name__) -jwt = JWTManager(app) +jwt_manager = JWTManager(app) config = Config().get_config() @@ -65,15 +66,17 @@ cert_file = open("register_service/certs/ca_root.crt", 'wb') cert_file.write(bytes(ca_root, 'utf-8')) cert_file.close() -# Request CAPIF private key to encode the token +# Request CAPIF private key to encode the CAPIF token url = 'http://{}:{}/v1/secret/data/server_cert/private'.format(config["ca_factory"]["url"], config["ca_factory"]["port"]) headers = {'X-Vault-Token': f"{config["ca_factory"]["token"]}"} response = requests.request("GET", url, headers=headers, verify = False) key_data = json.loads(response.text)["data"]["data"]["key"] + app.config['JWT_ALGORITHM'] = 'RS256' app.config['JWT_PRIVATE_KEY'] = key_data +app.config['REGISTRE_SECRET_KEY'] = config["register"]["register_uuid"] app.register_blueprint(register_routes) diff --git a/services/register/register_service/controllers/register_controller.py b/services/register/register_service/controllers/register_controller.py index 9537808..14877f8 100644 --- a/services/register/register_service/controllers/register_controller.py +++ b/services/register/register_service/controllers/register_controller.py @@ -3,13 +3,34 @@ from flask import current_app, Flask, jsonify, request, Blueprint from ..core.register_operations import RegisterOperations from ..config import Config +from functools import wraps +from datetime import datetime, timedelta from flask_httpauth import HTTPBasicAuth +import jwt auth = HTTPBasicAuth() config = Config().get_config() +register_routes = Blueprint("register_routes", __name__) +register_operation = RegisterOperations() + +# Function to generate access tokens and refresh tokens +def generate_tokens(username): + access_payload = { + 'username': username, + 'exp': datetime.now() + timedelta(minutes=config["register"]["token_expiration"]) + } + refresh_payload = { + 'username': username, + 'exp': datetime.now() + timedelta(days=config["register"]["refresh_expiration"]) + } + access_token = jwt.encode(access_payload, current_app.config['REGISTRE_SECRET_KEY'], algorithm='HS256') + refresh_token = jwt.encode(refresh_payload, current_app.config['REGISTRE_SECRET_KEY'], algorithm='HS256') + return access_token, refresh_token + +# Function in charge of verifying the basic auth @auth.verify_password def verify_password(username, password): users = register_operation.get_users()[0].json["users"] @@ -18,24 +39,51 @@ def verify_password(username, password): for user in users: if user["username"] == username and user["password"]==password: return username, "client" - -def admin_required(fn): - def wrapper(*args, **kwargs): - username, role = auth.current_user() - if role == 'admin': - return fn(*args, **kwargs) - else: - return jsonify(message="Access denied. Administrator privileges required."), 403 - wrapper.__name__ = fn.__name__ - return wrapper -register_routes = Blueprint("register_routes", __name__) -register_operation = RegisterOperations() +# Function responsible for verifying the token +def admin_required(): + def decorator(f): + @wraps(f) + def decorated(*args, **kwargs): + + token = request.headers.get('Authorization') + if not token: + return jsonify({'message': 'Token is missing'}), 401 + + if token.startswith('Bearer '): + token = token.split('Bearer ')[1] + + if not token: + return jsonify({'message': 'Token is missing'}), 401 -@register_routes.route("/createUser", methods=["POST"]) + try: + data = jwt.decode(token, current_app.config['REGISTRE_SECRET_KEY'], algorithms=['HS256'], options={'verify_exp': True}) + username = data['username'] + return f(username, *args, **kwargs) + except Exception as e: + return jsonify({'message': str(e)}), 401 + + return decorated + return decorator + +@register_routes.route('/login', methods=['POST']) @auth.login_required -@admin_required -def register(): +def login(): + username, rol = auth.current_user() + if rol != "admin": + return jsonify(message="Unauthorized. Administrator privileges required."), 401 + access_token, refresh_token = generate_tokens(username) + return jsonify({'access_token': access_token, 'refresh_token': refresh_token}) + +@register_routes.route('/refresh', methods=['POST']) +@admin_required() +def refresh_token(username): + access_token, _ = generate_tokens(username) + return jsonify({'access_token': access_token}) + +@register_routes.route("/createUser", methods=["POST"]) +@admin_required() +def register(username): username = request.json["username"] password = request.json["password"] description = request.json["description"] @@ -46,22 +94,16 @@ def register(): @register_routes.route("/getauth", methods=["GET"]) @auth.login_required def getauth(): - username, role = auth.current_user() - + username, _ = auth.current_user() return register_operation.get_auth(username) -@register_routes.route("/deleteUser", methods=["DELETE"]) -@auth.login_required -@admin_required -def remove(): - username = request.json["username"] - password = request.json["password"] - - return register_operation.remove_user(username, password) +@register_routes.route("/deleteUser/", methods=["DELETE"]) +@admin_required() +def remove(username, uuid): + return register_operation.remove_user(uuid) @register_routes.route("/getUsers", methods=["GET"]) -@auth.login_required -@admin_required -def getUsers(): +@admin_required() +def getUsers(username): return register_operation.get_users() diff --git a/services/register/register_service/core/register_operations.py b/services/register/register_service/core/register_operations.py index ab68c5e..a8fee91 100644 --- a/services/register/register_service/core/register_operations.py +++ b/services/register/register_service/core/register_operations.py @@ -26,7 +26,7 @@ class RegisterOperations: user_info = dict(uuid=user_uuid, username=username, password=password, description=description, email=email, onboarding_date=datetime.now()) obj = mycol.insert_one(user_info) - return jsonify(message="invoker registered successfully", uuid=user_uuid), 201 + return jsonify(message="User registered successfully", uuid=user_uuid), 201 def get_auth(self, username): @@ -51,16 +51,17 @@ class RegisterOperations: ccf_api_onboarding_url="api-provider-management/v1/registrations", ccf_publish_url="published-apis/v1//service-apis", ccf_onboarding_url="api-invoker-management/v1/onboardedInvokers", - ccf_discover_url="service-apis/v1/allServiceAPIs?api-invoker-id="), 200 + ccf_discover_url="service-apis/v1/allServiceAPIs?api-invoker-id=", + ccf_security_url="capif-security/v1/trustedInvokers/"), 200 except Exception as e: return jsonify(message=f"Errors when try getting auth: {e}"), 500 - def remove_user(self, username, password): + def remove_user(self, uuid): mycol = self.db.get_col_by_name(self.db.capif_users) try: - mycol.delete_one({"username": username, "password": password}) + mycol.delete_one({"uuid": uuid}) # Request to the helper to delete invokers and providers -- GitLab From 2d9f55e170b788365f89444bb04413c820723a7d Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Wed, 17 Apr 2024 12:11:37 +0200 Subject: [PATCH 5/8] Update Robot tests with latest changes --- .../capif_security_api.robot | 18 +-- tests/libraries/helpers.py | 13 ++ tests/requirements.txt | 3 +- tests/resources/common/basicRequests.robot | 68 ++++++++-- tests/tasks/Dummy Info/__init__.robot | 2 + tests/tasks/Dummy Info/populate.robot | 126 ++++++++++++++++++ tests/tasks/__init__.robot | 56 ++++++++ 7 files changed, 265 insertions(+), 21 deletions(-) create mode 100644 tests/tasks/Dummy Info/__init__.robot create mode 100644 tests/tasks/Dummy Info/populate.robot create mode 100644 tests/tasks/__init__.robot diff --git a/tests/features/CAPIF Security Api/capif_security_api.robot b/tests/features/CAPIF Security Api/capif_security_api.robot index 2a41e80..c920d01 100644 --- a/tests/features/CAPIF Security Api/capif_security_api.robot +++ b/tests/features/CAPIF Security Api/capif_security_api.robot @@ -670,7 +670,7 @@ Retrieve access token # Test ${discover_response}= Get Request Capif - ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api-name=${api_name} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME} @@ -729,7 +729,7 @@ Retrieve access token by Provider # Test ${discover_response}= Get Request Capif - ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api-name=${api_name} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME} @@ -787,7 +787,7 @@ Retrieve access token by Provider with invalid apiInvokerId # Test ${discover_response}= Get Request Capif - ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api-name=${api_name} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME} @@ -846,7 +846,7 @@ Retrieve access token with invalid apiInvokerId # Test ${discover_response}= Get Request Capif - ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api-name=${api_name} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME} @@ -907,7 +907,7 @@ Retrieve access token with invalid client_id # Test ${discover_response}= Get Request Capif - ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api-name=${api_name} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME} @@ -966,7 +966,7 @@ Retrieve access token with unsupported grant_type # Test ${discover_response}= Get Request Capif - ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api-name=${api_name} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME} @@ -1032,7 +1032,7 @@ Retrieve access token with invalid scope # Test ${discover_response}= Get Request Capif - ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api-name=${api_name} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME} @@ -1093,7 +1093,7 @@ Retrieve access token with invalid aefid at scope # Test ${discover_response}= Get Request Capif - ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api-name=${api_name} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME} @@ -1154,7 +1154,7 @@ Retrieve access token with invalid apiName at scope # Test ${discover_response}= Get Request Capif - ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api-name=${api_name} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME} diff --git a/tests/libraries/helpers.py b/tests/libraries/helpers.py index ec1abe0..94c850f 100644 --- a/tests/libraries/helpers.py +++ b/tests/libraries/helpers.py @@ -7,6 +7,8 @@ from OpenSSL.crypto import (dump_certificate_request, dump_privatekey, from OpenSSL.SSL import FILETYPE_PEM import socket import copy +import json +import pickle def parse_url(input): @@ -139,3 +141,14 @@ def create_scope(aef_id, api_name): data = "3gpp#" + aef_id + ":" + api_name return data + +def read_dictionary(file_path): + with open(file_path, 'rb') as fp: + data = pickle.load(fp) + print('Dictionary loaded') + return data + +def write_dictionary(file_path, data): + with open(file_path, 'wb') as fp: + pickle.dump(data, fp) + print('dictionary saved successfully to file ' + file_path) diff --git a/tests/requirements.txt b/tests/requirements.txt index 71b55e2..c6d9032 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -4,4 +4,5 @@ requests==2.28.1 configparser==5.3.0 redis==4.3.4 rfc3987==1.3.8 -robotframework-httpctrl \ No newline at end of file +robotframework-httpctrl +robotframework-archivelibrary == 0.4.2 \ No newline at end of file diff --git a/tests/resources/common/basicRequests.robot b/tests/resources/common/basicRequests.robot index 1d8d695..580c7d0 100644 --- a/tests/resources/common/basicRequests.robot +++ b/tests/resources/common/basicRequests.robot @@ -332,12 +332,6 @@ Get Auth For User RETURN ${resp.json()} -# Clean Test Information By HTTP Requests -# Create Session jwtsession ${CAPIF_HTTP_URL} verify=True - -# ${resp}= DELETE On Session jwtsession /testdata -# Should Be Equal As Strings ${resp.status_code} 200 - Clean Test Information ${capif_users_dict}= Call Method ${CAPIF_USERS} get_capif_users_dict @@ -413,17 +407,38 @@ Remove entity Log Dictionary ${capif_users_dict} Log List ${register_users} +Remove Resource + [Arguments] ${resource_url} ${management_cert} ${username} + + ${resp}= Delete Request Capif + ... ${resource_url} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${management_cert} + + Status Should Be 204 ${resp} + + &{body}= Create Dictionary + ... password=password + ... username=${username} + + Create Session jwtsession ${CAPIF_HTTPS_REGISTER_URL} verify=False disable_warnings=1 + + ${resp}= DELETE On Session jwtsession /remove json=${body} + + Should Be Equal As Strings ${resp.status_code} 204 + Invoker Default Onboarding [Arguments] ${invoker_username}=${INVOKER_USERNAME} ${register_user_info}= Register User At Jwt Auth - ... username=${INVOKER_USERNAME} role=${INVOKER_ROLE} + ... username=${invoker_username} role=${INVOKER_ROLE} # Send Onboarding Request ${request_body}= Create Onboarding Notification Body ... http://${CAPIF_CALLBACK_IP}:${CAPIF_CALLBACK_PORT}/netapp_callback ... ${register_user_info['csr_request']} - ... ${INVOKER_USERNAME} + ... ${invoker_username} ${resp}= Post Request Capif ... ${register_user_info['ccf_onboarding_url']} ... json=${request_body} @@ -437,12 +452,15 @@ Invoker Default Onboarding # Assertions Status Should Be 201 ${resp} Check Variable ${resp.json()} APIInvokerEnrolmentDetails - Check Location Header ${resp} ${LOCATION_INVOKER_RESOURCE_REGEX} + ${resource_url}= Check Location Header ${resp} ${LOCATION_INVOKER_RESOURCE_REGEX} # Store dummy signede certificate - Store In File ${INVOKER_USERNAME}.crt ${resp.json()['onboardingInformation']['apiInvokerCertificate']} + Store In File ${invoker_username}.crt ${resp.json()['onboardingInformation']['apiInvokerCertificate']} ${url}= Parse Url ${resp.headers['Location']} + Set To Dictionary ${register_user_info} resource_url=${resource_url} + Set To Dictionary ${register_user_info} management_cert=${invoker_username} + RETURN ${register_user_info} ${url} ${request_body} Provider Registration @@ -500,13 +518,15 @@ Provider Registration ... provider_enrollment_details=${request_body} ... resource_url=${resource_url} ... provider_register_response=${resp} + ... management_cert=${register_user_info['amf_username']} RETURN ${register_user_info} Provider Default Registration + [Arguments] ${provider_username}=${PROVIDER_USERNAME} # Register Provider ${register_user_info}= Register User At Jwt Auth Provider - ... username=${PROVIDER_USERNAME} role=${PROVIDER_ROLE} + ... username=${provider_username} role=${PROVIDER_ROLE} ${register_user_info}= Provider Registration ${register_user_info} @@ -591,3 +611,29 @@ Basic ACL registration END RETURN ${register_user_info_invoker} ${register_user_info_provider} ${service_api_description_published} + +Create Security Context Between invoker and provider + [Arguments] ${register_user_info_invoker} ${register_user_info_provider} + + ${discover_response}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info_provider['aef_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${register_user_info_invoker['management_cert']} + + Check Response Variable Type And Values ${discover_response} 200 DiscoveredAPIs + + # create Security Context + ${request_body}= Create Service Security From Discover Response + ... http://${CAPIF_HOSTNAME}:${CAPIF_HTTP_PORT}/test + ... ${discover_response} + + ${resp}= Put Request Capif + ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${register_user_info_invoker['management_cert']} + + Check Response Variable Type And Values ${resp} 201 ServiceSecurity + diff --git a/tests/tasks/Dummy Info/__init__.robot b/tests/tasks/Dummy Info/__init__.robot new file mode 100644 index 0000000..f6bbb18 --- /dev/null +++ b/tests/tasks/Dummy Info/__init__.robot @@ -0,0 +1,2 @@ +*** Settings *** +Force Tags populate \ No newline at end of file diff --git a/tests/tasks/Dummy Info/populate.robot b/tests/tasks/Dummy Info/populate.robot new file mode 100644 index 0000000..9a61a40 --- /dev/null +++ b/tests/tasks/Dummy Info/populate.robot @@ -0,0 +1,126 @@ +*** Settings *** +Resource /opt/robot-tests/tests/resources/common.resource +Resource /opt/robot-tests/tests/resources/api_invoker_management_requests/apiInvokerManagementRequests.robot +Resource ../../resources/common.resource +Resource ../../resources/common/basicRequests.robot +Library /opt/robot-tests/tests/libraries/bodyRequests.py +Library Process +Library Collections +Library ArchiveLibrary +Library OperatingSystem +Library DateTime + +Suite Teardown Reset Testing Environment +Test Setup Reset Testing Environment + + +*** Variables *** +${API_INVOKER_NOT_REGISTERED} not-valid +${TOTAL_INVOKERS} 10 +${TOTAL_PROVIDERS} 10 + +${BACKUP_DIRECTORY} backup +${RESULT_FOLDER} /opt/robot-tests/results +${OUTPUT_ZIP_FILE} entities_loaded.zip + +${INVOKER_USERNAME_POPULATE} ${INVOKER_USERNAME}_POPULATE +${PROVIDER_USERNAME_POPULATE} ${PROVIDER_USERNAME}_POPULATE + + +*** Test Cases *** +Create Dummy Invokers and Providers + [Tags] populate-create + ${entities_dictionary}= Create Dictionary + Create Directory ${BACKUP_DIRECTORY} + + FOR ${counter} IN RANGE ${TOTAL_PROVIDERS} + ${USERNAME}= Set Variable ${PROVIDER_USERNAME_POPULATE}_${counter} + ${register_user_info}= Run Keyword And Continue On Failure Provider Default Registration ${USERNAME} + + Set To Dictionary ${entities_dictionary} ${USERNAME}=${register_user_info} + Copy Files *${USERNAME}* ${BACKUP_DIRECTORY}/ + + ${service_api_description_published} + ... ${resource_url} + ... ${request_body}= + ... Run Keyword And Continue On Failure + ... Publish Service Api + ... ${register_user_info} + ... ROBOT_SERVICE_${counter} + END + + ${last_provider_used}= Evaluate -1 + FOR ${counter} IN RANGE ${TOTAL_INVOKERS} + ${USERNAME}= Set Variable ${INVOKER_USERNAME_POPULATE}_${counter} + ${register_user_info} ${url} ${request_body}= Run Keyword And Continue On Failure + ... Invoker Default Onboarding + ... ${USERNAME} + + IF ${TOTAL_PROVIDERS} > 0 + ${last_provider_used} ${register_user_info_provider}= Get Provider + ... ${last_provider_used} + ... ${entities_dictionary} + Log Dictionary ${register_user_info_provider} + + Run Keyword And Continue On Failure + ... Create Security Context Between invoker and provider + ... ${register_user_info} + ... ${register_user_info_provider} + END + + Set To Dictionary ${entities_dictionary} ${USERNAME}=${register_user_info} + Copy Files ${USERNAME}* ${BACKUP_DIRECTORY}/ + END + + Write Dictionary ${BACKUP_DIRECTORY}/registers.json ${entities_dictionary} + ${date}= Get Current Date result_format=%Y_%m_%d_%H_%M_%S + Create Zip From Files In Directory ${BACKUP_DIRECTORY} ${RESULT_FOLDER}/${date}_${OUTPUT_ZIP_FILE} + + ${result}= Run Process ls -l + + Log Many ${result.stdout} + +Remove Dummy Invokers and Providers + [Tags] populate-remove + ${files}= List Files In Directory ${RESULT_FOLDER} *${OUTPUT_ZIP_FILE} + ${sorted_list}= Copy List ${files} + + Sort List ${sorted_list} + ${last_backup}= Get From List ${sorted_list} -1 + + Copy File ${RESULT_FOLDER}/${last_backup} ./ + Extract Zip File ${last_backup} + + ${entities_dictionary}= Read Dictionary registers.json + + Log Dictionary ${entities_dictionary} + + FOR ${username} IN @{entities_dictionary} + Log ${username}=${entities_dictionary}[${username}] + ${resource_url}= Set Variable ${entities_dictionary}[${username}][resource_url] + ${management_cert}= Set Variable ${entities_dictionary}[${username}][management_cert] + Run Keyword And Ignore Error Remove Resource ${resource_url.path} ${management_cert} ${username} + END + + ${result}= Run Process ls -l + + Log Many ${result.stdout} + + +*** Keywords *** +Get Provider + [Arguments] ${index} ${entities_dictionary} + ${index}= Evaluate ${index} + 1 + IF ${index} == ${TOTAL_PROVIDERS} + ${index}= Evaluate 0 + END + + ${username}= Set Variable ${PROVIDER_USERNAME_POPULATE}_${index} + ${usernames}= Get Dictionary Keys ${entities_dictionary} + IF '${username}' in ${usernames} + log ${username} is in the list + ELSE + Log Dictionary not contain ${username}, no provider returned + END + + RETURN ${index} ${entities_dictionary}[${username}] diff --git a/tests/tasks/__init__.robot b/tests/tasks/__init__.robot new file mode 100644 index 0000000..a65a0e7 --- /dev/null +++ b/tests/tasks/__init__.robot @@ -0,0 +1,56 @@ +*** Settings *** +Resource /opt/robot-tests/tests/resources/common.resource +Resource ../resources/common.resource + +Suite Setup Prepare environment +# Suite Teardown Reset Testing Environment + +Force Tags tasks + + +*** Keywords *** +Prepare environment + Log ${CAPIF_HOSTNAME} + Log "${CAPIF_HTTP_PORT}" + Log "${CAPIF_HTTPS_PORT}" + + Set Global Variable ${CAPIF_HTTP_VAULT_URL} http://${CAPIF_VAULT}/ + IF "${CAPIF_VAULT_PORT}" != "" + Set Global Variable ${CAPIF_HTTP_VAULT_URL} http://${CAPIF_VAULT}:${CAPIF_VAULT_PORT}/ + END + + Set Global Variable ${CAPIF_HTTPS_REGISTER_URL} https://${CAPIF_REGISTER}/ + IF "${CAPIF_REGISTER_PORT}" != "" + Set Global Variable ${CAPIF_HTTPS_REGISTER_URL} https://${CAPIF_REGISTER}:${CAPIF_REGISTER_PORT}/ + END + + Set Global Variable ${CAPIF_HTTP_URL} http://${CAPIF_HOSTNAME}/ + IF "${CAPIF_HTTP_PORT}" != "" + Set Global Variable ${CAPIF_HTTP_URL} http://${CAPIF_HOSTNAME}:${CAPIF_HTTP_PORT}/ + END + + Set Global Variable ${CAPIF_HTTPS_URL} https://${CAPIF_HOSTNAME}/ + IF "${CAPIF_HTTPS_PORT}" != "" + Set Global Variable ${CAPIF_HTTPS_URL} https://${CAPIF_HOSTNAME}:${CAPIF_HTTPS_PORT}/ + END + + ${status} ${CAPIF_IP}= Run Keyword And Ignore Error Get Ip From Hostname ${CAPIF_HOSTNAME} + + IF "${status}" == "PASS" + Log We will use a remote deployment + Log ${CAPIF_IP} + ELSE + Log We will use a local deployment + Add Dns To Hosts 127.0.0.1 ${CAPIF_HOSTNAME} + END + # Obtain ca root certificate + Retrieve Ca Root + + Reset Testing Environment + +Retrieve Ca Root + [Documentation] This keyword retrieve ca.root from CAPIF and store it at ca.crt in order to use at TLS communications + ${resp}= Get CA Vault /v1/secret/data/ca ${CAPIF_HTTP_VAULT_URL} + Status Should Be 200 ${resp} + Log ${resp.json()['data']['data']['ca']} + Store In File ca.crt ${resp.json()['data']['data']['ca']} -- GitLab From 48ade4415db5e710a26c0e73c2d31f90e91bf64b Mon Sep 17 00:00:00 2001 From: Pelayo Torres Date: Wed, 17 Apr 2024 16:01:56 +0200 Subject: [PATCH 6/8] gitKeep in register/certs --- services/register/register_service/certs/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 services/register/register_service/certs/.gitkeep diff --git a/services/register/register_service/certs/.gitkeep b/services/register/register_service/certs/.gitkeep new file mode 100644 index 0000000..e69de29 -- GitLab From a5173bdd04d73a4eab2fc8944e4b7e12f2df8da3 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Wed, 17 Apr 2024 17:14:53 +0200 Subject: [PATCH 7/8] Upgrade Robot to new Register flow --- .../capif_api_access_control_policy.robot | 15 +- .../capif_auditing_api.robot | 20 +- .../capif_api_service_discover.robot | 24 +- .../CAPIF Api Events/capif_events_api.robot | 10 +- .../capif_api_invoker_managenet.robot | 8 - .../capif_logging_api.robot | 20 +- .../capif_api_provider_management.robot | 86 ++++--- .../capif_api_publish_service.robot | 32 +-- .../capif_security_api.robot | 88 +++---- tests/libraries/environment.py | 22 +- tests/resources/common.resource | 15 +- tests/resources/common/basicRequests.robot | 227 +++++++++++++----- 12 files changed, 338 insertions(+), 229 deletions(-) diff --git a/tests/features/CAPIF Api Access Control Policy/capif_api_access_control_policy.robot b/tests/features/CAPIF Api Access Control Policy/capif_api_access_control_policy.robot index 1772f3b..905e4c7 100644 --- a/tests/features/CAPIF Api Access Control Policy/capif_api_access_control_policy.robot +++ b/tests/features/CAPIF Api Access Control Policy/capif_api_access_control_policy.robot @@ -28,7 +28,7 @@ Retrieve ACL ... update_capif_users_dicts ... ${register_user_info_provider['resource_url'].path} ... ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info_provider} @@ -51,7 +51,7 @@ Retrieve ACL ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + # Test ${discover_response}= Get Request Capif @@ -102,7 +102,6 @@ Retrieve ACL with 2 Service APIs published ... update_capif_users_dicts ... ${register_user_info_provider['resource_url'].path} ... ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info_provider} @@ -119,7 +118,6 @@ Retrieve ACL with 2 Service APIs published ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} # Test ${discover_response}= Get Request Capif @@ -184,7 +182,6 @@ Retrieve ACL with security context created by two different Invokers ... update_capif_users_dicts ... ${register_user_info_provider['resource_url'].path} ... ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info_provider} @@ -207,7 +204,6 @@ Retrieve ACL with security context created by two different Invokers ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} ${INVOKER_USERNAME_2}= Set Variable ${INVOKER_USERNAME}_2 @@ -216,7 +212,6 @@ Retrieve ACL with security context created by two different Invokers ... ${INVOKER_USERNAME_2} Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME_2} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME_2} # Get Published APIs ${discover_response}= Get Request Capif @@ -301,7 +296,7 @@ Retrieve ACL filtered by api-invoker-id ... update_capif_users_dicts ... ${register_user_info_provider['resource_url'].path} ... ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info_provider} @@ -324,7 +319,7 @@ Retrieve ACL filtered by api-invoker-id ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${INVOKER_USERNAME_2}= Set Variable ${INVOKER_USERNAME}_2 @@ -333,7 +328,7 @@ Retrieve ACL filtered by api-invoker-id ... ${INVOKER_USERNAME_2} Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME_2} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME_2} + # Get Published APIs ${discover_response}= Get Request Capif diff --git a/tests/features/CAPIF Api Auditing Service/capif_auditing_api.robot b/tests/features/CAPIF Api Auditing Service/capif_auditing_api.robot index e4052ef..4c0a393 100644 --- a/tests/features/CAPIF Api Auditing Service/capif_auditing_api.robot +++ b/tests/features/CAPIF Api Auditing Service/capif_auditing_api.robot @@ -23,7 +23,7 @@ Get Log Entry ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Publish one api Publish Service Api ${register_user_info} @@ -32,7 +32,7 @@ Get Log Entry ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} @@ -68,7 +68,7 @@ Get a log entry without entry created ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Publish one api Publish Service Api ${register_user_info} @@ -77,7 +77,7 @@ Get a log entry without entry created ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${resp_1}= Get Request Capif @@ -100,7 +100,7 @@ Get a log entry withut aefid and apiInvokerId ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Publish one api Publish Service Api ${register_user_info} @@ -109,7 +109,7 @@ Get a log entry withut aefid and apiInvokerId ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} @@ -149,7 +149,7 @@ Get Log Entry with apiVersion filter ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Publish one api Publish Service Api ${register_user_info} @@ -158,7 +158,7 @@ Get Log Entry with apiVersion filter ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} @@ -194,7 +194,7 @@ Get Log Entry with no exist apiVersion filter ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Publish one api Publish Service Api ${register_user_info} @@ -203,7 +203,7 @@ Get Log Entry with no exist apiVersion filter ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${discover_response}= Get Request Capif diff --git a/tests/features/CAPIF Api Discover Service/capif_api_service_discover.robot b/tests/features/CAPIF Api Discover Service/capif_api_service_discover.robot index 0e2a5f7..2b7ed5b 100644 --- a/tests/features/CAPIF Api Discover Service/capif_api_service_discover.robot +++ b/tests/features/CAPIF Api Discover Service/capif_api_service_discover.robot @@ -20,7 +20,7 @@ Discover Published service APIs by Authorised API Invoker ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Publish one api ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api @@ -30,7 +30,7 @@ Discover Published service APIs by Authorised API Invoker ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + # Test ${resp}= Get Request Capif @@ -54,7 +54,7 @@ Discover Published service APIs by Non Authorised API Invoker ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Publish one api Publish Service Api ${register_user_info} @@ -63,7 +63,7 @@ Discover Published service APIs by Non Authorised API Invoker ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${resp}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} @@ -84,7 +84,7 @@ Discover Published service APIs by not registered API Invoker ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Publish one api Publish Service Api ${register_user_info} @@ -93,7 +93,7 @@ Discover Published service APIs by not registered API Invoker ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${resp}= Get Request Capif ... ${DISCOVER_URL}${API_INVOKER_NOT_REGISTERED} @@ -114,7 +114,7 @@ Discover Published service APIs by registered API Invoker with 1 result filtered ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${api_name_1}= Set Variable service_1 ${api_name_2}= Set Variable service_2 @@ -131,7 +131,7 @@ Discover Published service APIs by registered API Invoker with 1 result filtered ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + # Request all APIs for Invoker ${resp}= Get Request Capif @@ -168,7 +168,7 @@ Discover Published service APIs by registered API Invoker filtered with no match ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${api_name_1}= Set Variable apiName1 ${api_name_2}= Set Variable apiName2 @@ -185,7 +185,7 @@ Discover Published service APIs by registered API Invoker filtered with no match ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + # Request all APIs for Invoker ${resp}= Get Request Capif @@ -222,7 +222,7 @@ Discover Published service APIs by registered API Invoker not filtered ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${api_name_1}= Set Variable apiName1 ${api_name_2}= Set Variable apiName2 @@ -239,7 +239,7 @@ Discover Published service APIs by registered API Invoker not filtered ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + # Request all APIs for Invoker ${resp}= Get Request Capif diff --git a/tests/features/CAPIF Api Events/capif_events_api.robot b/tests/features/CAPIF Api Events/capif_events_api.robot index aecff95..c027769 100644 --- a/tests/features/CAPIF Api Events/capif_events_api.robot +++ b/tests/features/CAPIF Api Events/capif_events_api.robot @@ -22,7 +22,7 @@ Creates a new individual CAPIF Event Subscription ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${request_body}= Create Events Subscription ${resp}= Post Request Capif @@ -42,7 +42,7 @@ Creates a new individual CAPIF Event Subscription with Invalid SubscriberId ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${request_body}= Create Events Subscription ${resp}= Post Request Capif @@ -65,7 +65,7 @@ Deletes an individual CAPIF Event Subscription ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${request_body}= Create Events Subscription ${resp}= Post Request Capif @@ -93,7 +93,7 @@ Deletes an individual CAPIF Event Subscription with invalid SubscriberId ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${request_body}= Create Events Subscription ${resp}= Post Request Capif @@ -128,7 +128,7 @@ Deletes an individual CAPIF Event Subscription with invalid SubscriptionId ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${request_body}= Create Events Subscription ${resp}= Post Request Capif diff --git a/tests/features/CAPIF Api Invoker Management/capif_api_invoker_managenet.robot b/tests/features/CAPIF Api Invoker Management/capif_api_invoker_managenet.robot index 48eaa87..7127cc4 100644 --- a/tests/features/CAPIF Api Invoker Management/capif_api_invoker_managenet.robot +++ b/tests/features/CAPIF Api Invoker Management/capif_api_invoker_managenet.robot @@ -37,7 +37,6 @@ Onboard NetApp Check Response Variable Type And Values ${resp} 201 APIInvokerEnrolmentDetails ${url}= Parse Url ${resp.headers['Location']} Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} Check Location Header ${resp} ${LOCATION_INVOKER_RESOURCE_REGEX} # Store dummy signed certificate @@ -49,7 +48,6 @@ Register NetApp Already Onboarded ${register_user_info} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} ${resp}= Post Request Capif ... ${register_user_info['ccf_onboarding_url']} @@ -73,7 +71,6 @@ Update Onboarded NetApp ${register_user_info} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} Set To Dictionary ... ${request_body} @@ -96,7 +93,6 @@ Update Not Onboarded NetApp ${register_user_info} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} ${resp}= Put Request Capif ... /api-invoker-management/v1/onboardedInvokers/${INVOKER_NOT_REGISTERED} @@ -117,8 +113,6 @@ Offboard NetApp # Default Invoker Registration and Onboarding ${register_user_info} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} - ${resp}= Delete Request Capif ... ${url.path} ... server=${CAPIF_HTTPS_URL} @@ -134,7 +128,6 @@ Offboard Not Previously Onboarded NetApp ${register_user_info} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} ${resp}= Delete Request Capif ... /api-invoker-management/v1/onboardedInvokers/${INVOKER_NOT_REGISTERED} @@ -157,7 +150,6 @@ Update Onboarded NetApp Certificate ${register_user_info} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} ${INVOKER_USERNAME_NEW}= Set Variable ${INVOKER_USERNAME}_NEW diff --git a/tests/features/CAPIF Api Logging Service/capif_logging_api.robot b/tests/features/CAPIF Api Logging Service/capif_logging_api.robot index de9c672..2604bdb 100644 --- a/tests/features/CAPIF Api Logging Service/capif_logging_api.robot +++ b/tests/features/CAPIF Api Logging Service/capif_logging_api.robot @@ -21,7 +21,7 @@ Create a log entry ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Publish one api Publish Service Api ${register_user_info} @@ -30,7 +30,7 @@ Create a log entry ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} @@ -60,7 +60,7 @@ Create a log entry invalid aefId ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Publish one api Publish Service Api ${register_user_info} @@ -69,7 +69,7 @@ Create a log entry invalid aefId ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} @@ -103,7 +103,7 @@ Create a log entry invalid serviceApi ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Publish one api Publish Service Api ${register_user_info} @@ -112,7 +112,7 @@ Create a log entry invalid serviceApi ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} @@ -141,7 +141,7 @@ Create a log entry invalid apiInvokerId ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Publish one api Publish Service Api ${register_user_info} @@ -150,7 +150,7 @@ Create a log entry invalid apiInvokerId ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} @@ -183,7 +183,7 @@ Create a log entry different aef_id in body ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Publish one api Publish Service Api ${register_user_info} @@ -192,7 +192,7 @@ Create a log entry different aef_id in body ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${discover_response}= Get Request Capif diff --git a/tests/features/CAPIF Api Provider Management/capif_api_provider_management.robot b/tests/features/CAPIF Api Provider Management/capif_api_provider_management.robot index fd70925..f47385f 100644 --- a/tests/features/CAPIF Api Provider Management/capif_api_provider_management.robot +++ b/tests/features/CAPIF Api Provider Management/capif_api_provider_management.robot @@ -1,12 +1,12 @@ *** Settings *** -Resource /opt/robot-tests/tests/resources/common.resource -Resource ../../resources/common.resource -Library /opt/robot-tests/tests/libraries/bodyRequests.py -Library Process -Library Collections +Resource /opt/robot-tests/tests/resources/common.resource +Resource ../../resources/common.resource +Library /opt/robot-tests/tests/libraries/bodyRequests.py +Library Process +Library Collections -Test Setup Reset Testing Environment -Suite Teardown Reset Testing Environment +Suite Teardown Reset Testing Environment +Test Setup Reset Testing Environment *** Variables *** @@ -16,7 +16,7 @@ ${API_PROVIDER_NOT_REGISTERED} notValid *** Test Cases *** Register Api Provider [Tags] capif_api_provider_management-1 - #Register Provider User An create Certificates for each function + # Register Provider User An create Certificates for each function ${register_user_info}= Register User At Jwt Auth Provider ... username=${PROVIDER_USERNAME} role=${PROVIDER_ROLE} @@ -51,12 +51,10 @@ Register Api Provider Check Response Variable Type And Values ${resp} 201 APIProviderEnrolmentDetails ${url}= Parse Url ${resp.headers['Location']} - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${register_user_info['amf_username']} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${register_user_info['amf_username']} ${resource_url}= Check Location Header ${resp} ${LOCATION_PROVIDER_RESOURCE_REGEX} - FOR ${prov} IN @{resp.json()['apiProvFuncs']} Log Dictionary ${prov} Store In File ${prov['apiProvFuncInfo']}.crt ${prov['regInfo']['apiProvCert']} @@ -66,9 +64,11 @@ Register Api Provider Already registered [Tags] capif_api_provider_management-2 ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} - + Call Method + ... ${CAPIF_USERS} + ... update_capif_users_dicts + ... ${register_user_info['resource_url'].path} + ... ${AMF_PROVIDER_USERNAME} ${resp}= Post Request Capif ... /api-provider-management/v1/registrations @@ -88,8 +88,11 @@ Update Registered Api Provider [Tags] capif_api_provider_management-3 ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + Call Method + ... ${CAPIF_USERS} + ... update_capif_users_dicts + ... ${register_user_info['resource_url'].path} + ... ${AMF_PROVIDER_USERNAME} ${request_body}= Set Variable ${register_user_info['provider_enrollment_details']} @@ -124,8 +127,11 @@ Update Not Registered Api Provider [Tags] capif_api_provider_management-4 ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + Call Method + ... ${CAPIF_USERS} + ... update_capif_users_dicts + ... ${register_user_info['resource_url'].path} + ... ${AMF_PROVIDER_USERNAME} ${request_body}= Set Variable ${register_user_info['provider_enrollment_details']} @@ -144,31 +150,34 @@ Update Not Registered Api Provider ... cause=Not found registrations to send this api provider details # Partially Update Registered Api Provider -# [Tags] capif_api_provider_management-5 -# ${register_user_info}= Provider Default Registration +# [Tags] capif_api_provider_management-5 +# ${register_user_info}= Provider Default Registration -# ${request_body}= Create Api Provider Enrolment Details Patch Body ROBOT_TESTING_MOD +# ${request_body}= Create Api Provider Enrolment Details Patch Body ROBOT_TESTING_MOD -# ${resp}= Patch Request Capif -# ... ${register_user_info['resource_url'].path} -# ... json=${request_body} -# ... server=${CAPIF_HTTPS_URL} -# ... verify=ca.crt -# ... username=${AMF_PROVIDER_USERNAME} +# ${resp}= Patch Request Capif +# ... ${register_user_info['resource_url'].path} +# ... json=${request_body} +# ... server=${CAPIF_HTTPS_URL} +# ... verify=ca.crt +# ... username=${AMF_PROVIDER_USERNAME} -# Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${register_user_info['amf_username']} -# Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} +# Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${register_user_info['amf_username']} +# -# # Check Results -# Check Response Variable Type And Values ${resp} 200 APIProviderEnrolmentDetails -# ... apiProvDomInfo=ROBOT_TESTING_MOD +# # Check Results +# Check Response Variable Type And Values ${resp} 200 APIProviderEnrolmentDetails +# ... apiProvDomInfo=ROBOT_TESTING_MOD Partially Update Not Registered Api Provider [Tags] capif_api_provider_management-6 ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + Call Method + ... ${CAPIF_USERS} + ... update_capif_users_dicts + ... ${register_user_info['resource_url'].path} + ... ${AMF_PROVIDER_USERNAME} ${request_body}= Create Api Provider Enrolment Details Patch Body @@ -190,8 +199,6 @@ Delete Registered Api Provider [Tags] capif_api_provider_management-7 ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} - ${resp}= Delete Request Capif ... ${register_user_info['resource_url'].path} ... server=${CAPIF_HTTPS_URL} @@ -205,8 +212,11 @@ Delete Not Registered Api Provider [Tags] capif_api_provider_management-8 ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + Call Method + ... ${CAPIF_USERS} + ... update_capif_users_dicts + ... ${register_user_info['resource_url'].path} + ... ${AMF_PROVIDER_USERNAME} ${resp}= Delete Request Capif ... /api-provider-management/v1/registrations/${API_PROVIDER_NOT_REGISTERED} diff --git a/tests/features/CAPIF Api Publish Service/capif_api_publish_service.robot b/tests/features/CAPIF Api Publish Service/capif_api_publish_service.robot index cd58b3e..daef4be 100644 --- a/tests/features/CAPIF Api Publish Service/capif_api_publish_service.robot +++ b/tests/features/CAPIF Api Publish Service/capif_api_publish_service.robot @@ -20,7 +20,7 @@ Publish API by Authorised API Publisher ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Test ${request_body}= Create Service Api Description service_1 @@ -42,7 +42,7 @@ Publish API by NON Authorised API Publisher ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${request_body}= Create Service Api Description ${resp}= Post Request Capif @@ -64,7 +64,7 @@ Retrieve all APIs Published by Authorised apfId ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Register One Service ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api @@ -92,7 +92,7 @@ Retrieve all APIs Published by NON Authorised apfId ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Retrieve Services published ${resp}= Get Request Capif @@ -113,7 +113,7 @@ Retrieve single APIs Published by Authorised apfId ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info} @@ -152,7 +152,7 @@ Retrieve single APIs non Published by Authorised apfId ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${resp}= Get Request Capif ... /published-apis/v1/${register_user_info['apf_id']}/service-apis/${SERVICE_API_ID_NOT_VALID} @@ -172,7 +172,7 @@ Retrieve single APIs Published by NON Authorised apfId ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Publish Service API ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api @@ -183,7 +183,7 @@ Retrieve single APIs Published by NON Authorised apfId ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${resp}= Get Request Capif ... ${resource_url.path} @@ -203,7 +203,7 @@ Update API Published by Authorised apfId with valid serviceApiId ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info} @@ -236,7 +236,7 @@ Update APIs Published by Authorised apfId with invalid serviceApiId ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info} @@ -261,7 +261,7 @@ Update APIs Published by NON Authorised apfId ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info} @@ -271,7 +271,7 @@ Update APIs Published by NON Authorised apfId ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${request_body}= Create Service Api Description service_1_modified ${resp}= Put Request Capif @@ -303,7 +303,7 @@ Delete API Published by Authorised apfId with valid serviceApiId ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info} @@ -334,7 +334,7 @@ Delete APIs Published by Authorised apfId with invalid serviceApiId ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${resp}= Delete Request Capif ... /published-apis/v1/${register_user_info['apf_id']}/service-apis/${SERVICE_API_ID_NOT_VALID} @@ -353,13 +353,13 @@ Delete APIs Published by NON Authorised apfId ${register_user_info}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + #Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${resp}= Delete Request Capif ... /published-apis/v1/${register_user_info['apf_id']}/service-apis/${SERVICE_API_ID_NOT_VALID} diff --git a/tests/features/CAPIF Security Api/capif_security_api.robot b/tests/features/CAPIF Security Api/capif_security_api.robot index c920d01..4e27948 100644 --- a/tests/features/CAPIF Security Api/capif_security_api.robot +++ b/tests/features/CAPIF Security Api/capif_security_api.robot @@ -23,7 +23,7 @@ Create a security context for an API invoker ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + # Create Security Context ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} @@ -44,13 +44,13 @@ Create a security context for an API invoker with Provider role ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + # Register Provider ${register_user_info_publisher}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Create Security Context ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} @@ -74,7 +74,7 @@ Create a security context for an API invoker with Provider entity role and inval ${register_user_info_publisher}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Create Security Context ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} @@ -98,7 +98,7 @@ Create a security context for an API invoker with Invalid apiInvokerID ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif @@ -121,7 +121,7 @@ Retrieve the Security Context of an API Invoker ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif @@ -140,7 +140,7 @@ Retrieve the Security Context of an API Invoker ${register_user_info_publisher}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Retrieve Security context can setup by parameters if authenticationInfo and authorizationInfo are needed at response. # ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']}?authenticationInfo=true&authorizationInfo=true @@ -166,7 +166,7 @@ Retrieve the Security Context of an API Invoker with invalid apiInvokerID ${register_user_info_publisher}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${resp}= Get Request Capif ... /capif-security/v1/trustedInvokers/${API_INVOKER_NOT_VALID} @@ -186,7 +186,7 @@ Retrieve the Security Context of an API Invoker with invalid apfId ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif @@ -218,7 +218,7 @@ Delete the Security Context of an API Invoker ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif @@ -234,7 +234,7 @@ Delete the Security Context of an API Invoker ${register_user_info_publisher}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Remove Security Context ${resp}= Delete Request Capif @@ -264,7 +264,7 @@ Delete the Security Context of an API Invoker with Invoker entity role ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif @@ -295,7 +295,7 @@ Delete the Security Context of an API Invoker with Invoker entity role and inval ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${resp}= Delete Request Capif ... /capif-security/v1/trustedInvokers/${API_INVOKER_NOT_VALID} @@ -316,7 +316,7 @@ Delete the Security Context of an API Invoker with invalid apiInvokerID ${register_user_info_publisher}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${resp}= Delete Request Capif ... /capif-security/v1/trustedInvokers/${API_INVOKER_NOT_VALID} @@ -337,13 +337,13 @@ Update the Security Context of an API Invoker ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + # Register Provider ${register_user_info_publisher}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif @@ -390,7 +390,7 @@ Update the Security Context of an API Invoker with Provider entity role ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif @@ -406,7 +406,7 @@ Update the Security Context of an API Invoker with Provider entity role ${register_user_info_publisher}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${resp}= Post Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']}/update @@ -428,7 +428,7 @@ Update the Security Context of an API Invoker with AEF entity role and invalid a ${register_user_info_publisher}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Post Request Capif @@ -450,7 +450,7 @@ Update the Security Context of an API Invoker with invalid apiInvokerID ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Post Request Capif @@ -473,7 +473,7 @@ Revoke the authorization of the API invoker for APIs ${register_user_info_provider}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${api_name}= Set Variable service_1 @@ -486,7 +486,7 @@ Revoke the authorization of the API invoker for APIs ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + # Test @@ -546,7 +546,7 @@ Revoke the authorization of the API invoker for APIs without valid apfID. ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif @@ -564,7 +564,7 @@ Revoke the authorization of the API invoker for APIs without valid apfID. ${register_user_info_publisher}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + # Revoke Security Context by Invoker ${request_body}= Create Security Notification Body ${register_user_info_invoker['api_invoker_id']} 1234 @@ -602,7 +602,7 @@ Revoke the authorization of the API invoker for APIs with invalid apiInvokerId ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif @@ -620,7 +620,7 @@ Revoke the authorization of the API invoker for APIs with invalid apiInvokerId ${register_user_info_publisher}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${request_body}= Create Security Notification Body ${API_INVOKER_NOT_VALID} 1234 ${resp}= Post Request Capif @@ -653,7 +653,7 @@ Retrieve access token ${register_user_info_provider}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${api_name}= Set Variable service_1 @@ -666,7 +666,7 @@ Retrieve access token ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + # Test ${discover_response}= Get Request Capif @@ -712,7 +712,7 @@ Retrieve access token by Provider ${register_user_info_provider}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${api_name}= Set Variable service_1 @@ -725,7 +725,7 @@ Retrieve access token by Provider ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + # Test ${discover_response}= Get Request Capif @@ -770,7 +770,7 @@ Retrieve access token by Provider with invalid apiInvokerId ${register_user_info_provider}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${api_name}= Set Variable service_1 @@ -783,7 +783,7 @@ Retrieve access token by Provider with invalid apiInvokerId ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + # Test ${discover_response}= Get Request Capif @@ -829,7 +829,7 @@ Retrieve access token with invalid apiInvokerId ${register_user_info_provider}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${api_name}= Set Variable service_1 @@ -842,7 +842,7 @@ Retrieve access token with invalid apiInvokerId ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + # Test ${discover_response}= Get Request Capif @@ -890,7 +890,7 @@ Retrieve access token with invalid client_id ${register_user_info_provider}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${api_name}= Set Variable service_1 @@ -903,7 +903,7 @@ Retrieve access token with invalid client_id ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + # Test ${discover_response}= Get Request Capif @@ -949,7 +949,7 @@ Retrieve access token with unsupported grant_type ${register_user_info_provider}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${api_name}= Set Variable service_1 @@ -962,7 +962,7 @@ Retrieve access token with unsupported grant_type ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + # Test ${discover_response}= Get Request Capif @@ -1015,7 +1015,7 @@ Retrieve access token with invalid scope ${register_user_info_provider}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${api_name}= Set Variable service_1 @@ -1028,7 +1028,7 @@ Retrieve access token with invalid scope ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + # Test ${discover_response}= Get Request Capif @@ -1076,7 +1076,7 @@ Retrieve access token with invalid aefid at scope ${register_user_info_provider}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${api_name}= Set Variable service_1 @@ -1089,7 +1089,7 @@ Retrieve access token with invalid aefid at scope ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + # Test ${discover_response}= Get Request Capif @@ -1137,7 +1137,7 @@ Retrieve access token with invalid apiName at scope ${register_user_info_provider}= Provider Default Registration Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + ${api_name}= Set Variable service_1 @@ -1150,7 +1150,7 @@ Retrieve access token with invalid apiName at scope ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} + # Test ${discover_response}= Get Request Capif diff --git a/tests/libraries/environment.py b/tests/libraries/environment.py index d8100fa..8b7a504 100644 --- a/tests/libraries/environment.py +++ b/tests/libraries/environment.py @@ -1,10 +1,10 @@ class CapifUserManager(): def __init__(self): self.capif_users = {} - self.register_users = [] + self.register_users = {} - def update_register_users(self, value): - self.register_users.append(value) + def update_register_users(self, uuid, username): + self.register_users[uuid] = username def update_capif_users_dicts(self, key, value): self.capif_users[key] = value @@ -12,14 +12,22 @@ class CapifUserManager(): def remove_capif_users_entry(self, key): self.capif_users.pop(key) - def remove_register_users_entry(self, value): - self.register_users.remove(value) + def remove_register_users_entry(self, uuid=None, username=None): + if uuid != None: + self.register_users.pop(uuid) + elif username != None: + uuid=self.get_user_uuid(username) + self.register_users.pop(uuid) def get_capif_users_dict(self): return self.capif_users - def get_register_users(self): + def get_register_users_dict(self): return self.register_users - + + def get_user_uuid(self, username): + for uuid, stored_user in self.register_users.items(): + if stored_user == username: + return uuid CAPIF_USERS = CapifUserManager() \ No newline at end of file diff --git a/tests/resources/common.resource b/tests/resources/common.resource index b111127..c46131b 100644 --- a/tests/resources/common.resource +++ b/tests/resources/common.resource @@ -1,7 +1,7 @@ *** Settings *** -Library /opt/robot-tests/tests/libraries/helpers.py -Variables /opt/robot-tests/tests/libraries/environment.py -Resource /opt/robot-tests/tests/resources/common/basicRequests.robot +Library /opt/robot-tests/tests/libraries/helpers.py +Variables /opt/robot-tests/tests/libraries/environment.py +Resource /opt/robot-tests/tests/resources/common/basicRequests.robot *** Variables *** @@ -21,12 +21,15 @@ ${CAPIF_VAULT_PORT} 8200 ${CAPIF_VAULT_TOKEN} read-ca-token ${CAPIF_REGISTER} register ${CAPIF_REGISTER_PORT} 8084 -${CAPIF_HTTP_PORT} -${CAPIF_HTTPS_PORT} +${CAPIF_HTTP_PORT} ${EMPTY} +${CAPIF_HTTPS_PORT} ${EMPTY} ${CAPIF_IP} 127.0.0.1 ${CAPIF_CALLBACK_IP} host.docker.internal ${CAPIF_CALLBACK_PORT} 8086 +${REGISTER_ADMIN_USER} admin +${REGISTER_ADMIN_PASSWORD} password123 + ${DISCOVER_URL} /service-apis/v1/allServiceAPIs?api-invoker-id= @@ -34,7 +37,7 @@ ${DISCOVER_URL} /service-apis/v1/allServiceAPIs?api-invoker-id= Reset Testing Environment Log Db capif.invokerdetails collection will be removed in order to isolate each test. - #Clean Test Information By HTTP Requests + # Clean Test Information By HTTP Requests Clean Test Information Check Location Header diff --git a/tests/resources/common/basicRequests.robot b/tests/resources/common/basicRequests.robot index 580c7d0..3a24b84 100644 --- a/tests/resources/common/basicRequests.robot +++ b/tests/resources/common/basicRequests.robot @@ -5,6 +5,7 @@ Library RequestsLibrary Library Collections Library OperatingSystem Library XML +Library Telnet *** Variables *** @@ -53,6 +54,97 @@ Create CAPIF Session RETURN ${headers} +Create Register Admin Session + [Documentation] Create needed session to reach Register as Administrator. + [Arguments] ${server}=${NONE} ${access_token}=${NONE} ${verify}=${NONE} ${vault_token}=${NONE} + IF "${server}" != "${NONE}" + IF "${access_token}" != "${NONE}" + ## Return Header with bearer + ${headers}= Create Dictionary Authorization=Bearer ${access_token} + + RETURN ${headers} + END + + # Request Admin Login to retrieve access token + Create Session register_session ${server} verify=${verify} disable_warnings=1 + + ${auth}= Set variable ${{ ('${REGISTER_ADMIN_USER}','${REGISTER_ADMIN_PASSWORD}') }} + ${resp}= POST On Session register_session /login auth=${auth} + + Log Dictionary ${resp.json()} + + ## Crear sesiĆ³n con token + ${headers}= Create Dictionary Authorization=Bearer ${resp.json()['access_token']} + + RETURN ${headers} + END + + + RETURN ${NONE} + +## NEW REQUESTS TO REGISTER +Post Request Admin Register + [Timeout] 60s + [Arguments] + ... ${endpoint} + ... ${json}=${NONE} + ... ${server}=${NONE} + ... ${access_token}=${NONE} + ... ${auth}=${NONE} + ... ${verify}=${FALSE} + ... ${cert}=${NONE} + ... ${username}=${NONE} + ... ${data}=${NONE} + + ${headers}= Create Register Admin Session ${server} ${access_token} ${verify} + + IF '${username}' != '${NONE}' + ${cert}= Set variable ${{ ('${username}.crt','${username}.key') }} + END + + ${resp}= POST On Session + ... register_session + ... ${endpoint} + ... headers=${headers} + ... json=${json} + ... expected_status=any + ... verify=${verify} + ... cert=${cert} + ... data=${data} + RETURN ${resp} + +Get Request Admin Register + [Timeout] 60s + [Arguments] + ... ${endpoint} + ... ${server}=${NONE} + ... ${access_token}=${NONE} + ... ${auth}=${NONE} + ... ${verify}=${FALSE} + ... ${cert}=${NONE} + ... ${username}=${NONE} + + ${headers}= Create Register Admin Session ${server} ${access_token} + + IF '${username}' != '${NONE}' + ${cert}= Set variable ${{ ('${username}.crt','${username}.key') }} + END + + ${resp}= GET On Session + ... register_session + ... ${endpoint} + ... headers=${headers} + ... expected_status=any + ... verify=${verify} + ... cert=${cert} + RETURN ${resp} + + + + +# NEW REQUESTS END + + Post Request Capif [Timeout] 60s [Arguments] @@ -235,24 +327,15 @@ Register User At Jwt Auth END Log cn=${cn} - - &{body}= Create Dictionary - ... password=${password} - ... username=${username} - ... role=${role} - ... description=${description} - ... cn=${cn} - - Create Session jwtsession ${CAPIF_HTTPS_REGISTER_URL} verify=False disable_warnings=1 - - ${resp}= POST On Session jwtsession /register json=${body} - - Should Be Equal As Strings ${resp.status_code} 201 + + ${resp}= Create User At Register ${username} ${password} ${description} email="${username}@nobody.com" ${get_auth_response}= Get Auth For User ${username} ${password} + Log Dictionary ${get_auth_response} + ${register_user_info}= Create Dictionary - ... netappID=${resp.json()['id']} + ... netappID=${resp.json()['uuid']} ... csr_request=${csr_request} ... &{resp.json()} ... &{get_auth_response} @@ -270,6 +353,8 @@ Register User At Jwt Auth Store In File ${username}.key ${register_user_info['private_key']} END + Call Method ${CAPIF_USERS} update_register_users ${register_user_info['uuid']} ${username} + RETURN ${register_user_info} Register User At Jwt Auth Provider @@ -287,24 +372,14 @@ Register User At Jwt Auth Provider ${amf_csr_request}= Create User Csr ${amf_username} amf # Register provider - &{body}= Create Dictionary - ... password=${password} - ... username=${username} - ... role=${role} - ... description=${description} - ... cn=${username} - - Create Session jwtsession ${CAPIF_HTTPS_REGISTER_URL} verify=False disable_warnings=1 - - ${resp}= POST On Session jwtsession /register json=${body} - - Should Be Equal As Strings ${resp.status_code} 201 + ${resp}= Create User At Register ${username} ${password} ${description} email="${username}@nobody.com" - # Get Auth to obtain access_token ${get_auth_response}= Get Auth For User ${username} ${password} + Log Dictionary ${get_auth_response} + ${register_user_info}= Create Dictionary - ... netappID=${resp.json()['id']} + ... netappID=${resp.json()['uuid']} ... csr_request=${csr_request} ... apf_csr_request=${apf_csr_request} ... aef_csr_request=${aef_csr_request} @@ -317,25 +392,71 @@ Register User At Jwt Auth Provider Log Dictionary ${register_user_info} + Call Method ${CAPIF_USERS} update_register_users ${register_user_info['uuid']} ${username} + RETURN ${register_user_info} -Get Auth For User - [Arguments] ${username} ${password} - &{body}= Create Dictionary username=${username} password=${password} +Login Register Admin + ${headers}= Create Register Admin Session ${CAPIF_HTTPS_REGISTER_URL} + RETURN ${headers} + +Create User At Register + [Documentation] (Administrator) This Keyword create a user at register component. + [Arguments] ${username} ${password} ${description} ${email} + + # Obtain Admin Token to request creation of User + ${headers}= Login Register Admin + + &{body}= Create Dictionary username=${username} password=${password} description=${description} email=${email} + ${resp}= Post On Session register_session /createUser headers=${headers} json=${body} + Should Be Equal As Strings ${resp.status_code} 201 + + RETURN ${resp} - ${resp}= POST On Session jwtsession /getauth json=${body} +Delete User At Register + [Documentation] (Administrator) This Keyword delete a user from register. + [Arguments] ${username}=${NONE} ${uuid}=${NONE} + ${user_uuid}= Set Variable ${uuid} + + IF "${username}" != "${NONE}" + ${user_uuid}= Call Method ${CAPIF_USERS} get_user_uuid ${username} + END + + ${headers}= Create Register Admin Session ${CAPIF_HTTPS_REGISTER_URL} verify=False + + ${resp}= DELETE On Session register_session /deleteUser/${user_uuid} headers=${headers} + + Should Be Equal As Strings ${resp.status_code} 204 + + Call Method ${CAPIF_USERS} remove_register_users_entry ${user_uuid} + + RETURN ${resp} + +Get List of User At Register + [Documentation] (Administrator) This Keyword retrieve a list of users from register. + ${headers}= Create Register Admin Session ${CAPIF_HTTPS_REGISTER_URL} verify=False + + ${resp}= DELETE On Session register_session /getUsers headers=${headers} Should Be Equal As Strings ${resp.status_code} 200 - # Should Be Equal As Strings ${resp.json()['message']} Certificate created successfuly + RETURN ${resp.json()['users']} + +Get Auth For User + [Documentation] (User) This Keyword retrieve token to be used by user towards first interaction with CCF. + [Arguments] ${username} ${password} + ${auth}= Set variable ${{ ('${username}','${password}') }} + ${resp}= GET On Session register_session /getauth auth=${auth} + + Should Be Equal As Strings ${resp.status_code} 200 RETURN ${resp.json()} Clean Test Information ${capif_users_dict}= Call Method ${CAPIF_USERS} get_capif_users_dict - ${register_users}= Call Method ${CAPIF_USERS} get_register_users + ${register_users_dict}= Call Method ${CAPIF_USERS} get_register_users_dict ${keys}= Get Dictionary Keys ${capif_users_dict} @@ -352,18 +473,9 @@ Clean Test Information Call Method ${CAPIF_USERS} remove_capif_users_entry ${key} END - FOR ${user} IN @{register_users} - &{body}= Create Dictionary - ... password=password - ... username=${user} - - Create Session jwtsession ${CAPIF_HTTPS_REGISTER_URL} verify=False disable_warnings=1 - - ${resp}= DELETE On Session jwtsession /remove json=${body} - - Should Be Equal As Strings ${resp.status_code} 204 - - Call Method ${CAPIF_USERS} remove_register_users_entry ${user} + ${uuids}= Get Dictionary Keys ${register_users_dict} + FOR ${uuid} IN @{uuids} + Delete User At Register uuid=${uuid} END Remove entity @@ -371,10 +483,10 @@ Remove entity ${capif_users_dict}= Call Method ${CAPIF_USERS} get_capif_users_dict - ${register_users}= Call Method ${CAPIF_USERS} get_register_users + ${register_users_dict}= Call Method ${CAPIF_USERS} get_register_users_dict Log Dictionary ${capif_users_dict} - Log List ${register_users} + Log Dictionary ${register_users_dict} ${keys}= Get Dictionary Keys ${capif_users_dict} FOR ${key} IN @{keys} @@ -391,21 +503,11 @@ Remove entity Call Method ${CAPIF_USERS} remove_capif_users_entry ${key} END END - - &{body}= Create Dictionary - ... password=password - ... username=${entity_user} - - Create Session jwtsession ${CAPIF_HTTPS_REGISTER_URL} verify=False disable_warnings=1 - - ${resp}= DELETE On Session jwtsession /remove json=${body} - - Should Be Equal As Strings ${resp.status_code} 204 - - Call Method ${CAPIF_USERS} remove_register_users_entry ${entity_user} + + Delete User At Register username=${entity_user} Log Dictionary ${capif_users_dict} - Log List ${register_users} + Log Dictionary ${register_users_dict} Remove Resource [Arguments] ${resource_url} ${management_cert} ${username} @@ -560,7 +662,7 @@ Basic ACL registration ... update_capif_users_dicts ... ${register_user_info_provider['resource_url'].path} ... ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${PROVIDER_USERNAME} + Call Method ${CAPIF_USERS} update_register_users ${register_user_info_provider['uuid']} ${PROVIDER_USERNAME} ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info_provider} @@ -583,7 +685,6 @@ Basic ACL registration ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${INVOKER_USERNAME} # Test ${discover_response}= Get Request Capif -- GitLab From 123dcb2e23ba3af82f7b1bc8b0de313bd23d8cc1 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Wed, 17 Apr 2024 17:57:35 +0200 Subject: [PATCH 8/8] Code Refactor of delete entities --- .../capif_api_access_control_policy.robot | 44 +---- .../capif_auditing_api.robot | 133 ++++++--------- .../capif_api_service_discover.robot | 84 +++------- .../CAPIF Api Events/capif_events_api.robot | 37 ++--- .../capif_api_invoker_managenet.robot | 38 ++--- .../capif_logging_api.robot | 110 ++++++------- .../capif_api_provider_management.robot | 32 +--- .../capif_api_publish_service.robot | 89 +++------- .../capif_security_api.robot | 155 ++---------------- tests/resources/common/basicRequests.robot | 122 +++++++------- 10 files changed, 248 insertions(+), 596 deletions(-) diff --git a/tests/features/CAPIF Api Access Control Policy/capif_api_access_control_policy.robot b/tests/features/CAPIF Api Access Control Policy/capif_api_access_control_policy.robot index 905e4c7..04d7898 100644 --- a/tests/features/CAPIF Api Access Control Policy/capif_api_access_control_policy.robot +++ b/tests/features/CAPIF Api Access Control Policy/capif_api_access_control_policy.robot @@ -23,13 +23,6 @@ Retrieve ACL # Register APF ${register_user_info_provider}= Provider Default Registration - Call Method - ... ${CAPIF_USERS} - ... update_capif_users_dicts - ... ${register_user_info_provider['resource_url'].path} - ... ${AMF_PROVIDER_USERNAME} - - ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info_provider} ... service_1 @@ -50,9 +43,6 @@ Retrieve ACL # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - # Test ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info_provider['aef_id']} @@ -97,12 +87,6 @@ Retrieve ACL with 2 Service APIs published # Register APF ${register_user_info_provider}= Provider Default Registration - Call Method - ... ${CAPIF_USERS} - ... update_capif_users_dicts - ... ${register_user_info_provider['resource_url'].path} - ... ${AMF_PROVIDER_USERNAME} - ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info_provider} ... service_1 @@ -117,8 +101,6 @@ Retrieve ACL with 2 Service APIs published # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - # Test ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info_provider['aef_id']} @@ -177,12 +159,6 @@ Retrieve ACL with security context created by two different Invokers # Register APF ${register_user_info_provider}= Provider Default Registration - Call Method - ... ${CAPIF_USERS} - ... update_capif_users_dicts - ... ${register_user_info_provider['resource_url'].path} - ... ${AMF_PROVIDER_USERNAME} - ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info_provider} ... service_1 @@ -203,16 +179,12 @@ Retrieve ACL with security context created by two different Invokers # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - ${INVOKER_USERNAME_2}= Set Variable ${INVOKER_USERNAME}_2 # Register another invoker ${register_user_info_invoker_2} ${url} ${request_body}= Invoker Default Onboarding ... ${INVOKER_USERNAME_2} - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME_2} - # Get Published APIs ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info_provider['aef_id']} @@ -291,13 +263,6 @@ Retrieve ACL filtered by api-invoker-id # Register APF ${register_user_info_provider}= Provider Default Registration - Call Method - ... ${CAPIF_USERS} - ... update_capif_users_dicts - ... ${register_user_info_provider['resource_url'].path} - ... ${AMF_PROVIDER_USERNAME} - - ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info_provider} ... service_1 @@ -318,18 +283,12 @@ Retrieve ACL filtered by api-invoker-id # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${INVOKER_USERNAME_2}= Set Variable ${INVOKER_USERNAME}_2 # Register another invoker ${register_user_info_invoker_2} ${url} ${request_body}= Invoker Default Onboarding ... ${INVOKER_USERNAME_2} - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME_2} - - # Get Published APIs ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info_provider['aef_id']} @@ -602,7 +561,7 @@ No ACL for invoker after be removed Check Response Variable Type And Values ${resp} 200 AccessControlPolicyList - Remove entity ${INVOKER_USERNAME} + Remove entity ${INVOKER_USERNAME} ${resp}= Get Request Capif ... /access-control-policy/v1/accessControlPolicyList/${service_api_description_published['apiId']}?aef-id=${register_user_info_provider['aef_id']} @@ -619,4 +578,3 @@ No ACL for invoker after be removed ... title=Not Found ... detail=No ACLs found for the requested service: ${service_api_description_published['apiId']}, aef_id: ${register_user_info_provider['aef_id']}, invoker: None and supportedFeatures: None ... cause=Wrong id - diff --git a/tests/features/CAPIF Api Auditing Service/capif_auditing_api.robot b/tests/features/CAPIF Api Auditing Service/capif_auditing_api.robot index 4c0a393..0676168 100644 --- a/tests/features/CAPIF Api Auditing Service/capif_auditing_api.robot +++ b/tests/features/CAPIF Api Auditing Service/capif_auditing_api.robot @@ -1,12 +1,13 @@ *** Settings *** -Resource /opt/robot-tests/tests/resources/common.resource -Library /opt/robot-tests/tests/libraries/bodyRequests.py -Library Collections -Resource /opt/robot-tests/tests/resources/common/basicRequests.robot -Resource ../../resources/common.resource +Resource /opt/robot-tests/tests/resources/common.resource +Library /opt/robot-tests/tests/libraries/bodyRequests.py +Library Collections +Resource /opt/robot-tests/tests/resources/common/basicRequests.robot +Resource ../../resources/common.resource + +Suite Teardown Reset Testing Environment +Test Setup Reset Testing Environment -Test Setup Reset Testing Environment -Suite Teardown Reset Testing Environment *** Variables *** ${AEF_ID_NOT_VALID} aef-example @@ -16,34 +17,33 @@ ${NOTIFICATION_DESTINATION} http://robot.testing:1080 ${API_VERSION_VALID} v1 ${API_VERSION_NOT_VALID} v58 + *** Test Cases *** Get Log Entry [Tags] capif_api_auditing_service-1 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Publish one api Publish Service Api ${register_user_info} - #Register INVOKER + # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${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} + ${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} + ${request_body}= Create Log Entry + ... ${register_user_info['aef_id']} + ... ${register_user_info_invoker['api_invoker_id']} + ... ${api_ids} + ... ${api_names} ${resp_1}= Post Request Capif ... /api-invocation-logs/v1/${register_user_info['aef_id']}/logs ... json=${request_body} @@ -51,7 +51,6 @@ Get Log Entry ... verify=ca.crt ... username=${AEF_PROVIDER_USERNAME} - ${resp_2}= Get Request Capif ... /logs/v1/apiInvocationLogs?aef-id=${register_user_info['aef_id']}&api-invoker-id=${register_user_info_invoker['api_invoker_id']} ... server=${CAPIF_HTTPS_URL} @@ -60,67 +59,56 @@ Get Log Entry # Check Results Check Response Variable Type And Values ${resp_2} 200 InvocationLog - Length Should Be ${resp_2.json()["logs"]} 2 + Length Should Be ${resp_2.json()["logs"]} 2 Get a log entry without entry created [Tags] capif_api_auditing_service-2 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Publish one api Publish Service Api ${register_user_info} - #Register INVOKER + # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - - - ${resp_1}= Get Request Capif + ${resp_1}= Get Request Capif ... /logs/v1/apiInvocationLogs?aef-id=${register_user_info['aef_id']}&api-invoker-id=${register_user_info_invoker['api_invoker_id']} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${AMF_PROVIDER_USERNAME} # Check Results - Check Response Variable Type And Values ${resp_1} 404 ProblemDetails + Check Response Variable Type And Values ${resp_1} 404 ProblemDetails ... title=Not Found ... status=404 ... detail=aefId or/and apiInvokerId do not match any InvocationLogs ... cause=No log invocations found - Get a log entry withut aefid and apiInvokerId [Tags] capif_api_auditing_service-3 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Publish one api Publish Service Api ${register_user_info} - #Register INVOKER + # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${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} + ${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} + ${request_body}= Create Log Entry + ... ${register_user_info['aef_id']} + ... ${register_user_info_invoker['api_invoker_id']} + ... ${api_ids} + ... ${api_names} ${resp_1}= Post Request Capif ... /api-invocation-logs/v1/${AEF_ID_NOT_VALID}/logs ... json=${request_body} @@ -128,48 +116,44 @@ Get a log entry withut aefid and apiInvokerId ... verify=ca.crt ... username=${AEF_PROVIDER_USERNAME} - - ${resp_2}= Get Request Capif + ${resp_2}= Get Request Capif ... /logs/v1/apiInvocationLogs ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${AMF_PROVIDER_USERNAME} # Check Results - Check Response Variable Type And Values ${resp_2} 400 ProblemDetails + Check Response Variable Type And Values ${resp_2} 400 ProblemDetails ... title=Bad Request ... status=400 ... detail=aef_id and api_invoker_id parameters are mandatory ... cause=Mandatory parameters missing - Get Log Entry with apiVersion filter [Tags] capif_api_auditing_service-4 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Publish one api Publish Service Api ${register_user_info} - #Register INVOKER + # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${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} + ${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} + ${request_body}= Create Log Entry + ... ${register_user_info['aef_id']} + ... ${register_user_info_invoker['api_invoker_id']} + ... ${api_ids} + ... ${api_names} ${resp_1}= Post Request Capif ... /api-invocation-logs/v1/${register_user_info['aef_id']}/logs ... json=${request_body} @@ -177,45 +161,41 @@ Get Log Entry with apiVersion filter ... verify=ca.crt ... username=${AEF_PROVIDER_USERNAME} - ${resp_2}= Get Request Capif - ... /logs/v1/apiInvocationLogs?aef-id=${register_user_info['aef_id']}&api-invoker-id=${register_user_info_invoker['api_invoker_id']}&api-version=${API_VERSION_VALID} + ... /logs/v1/apiInvocationLogs?aef-id=${register_user_info['aef_id']}&api-invoker-id=${register_user_info_invoker['api_invoker_id']}&api-version=${API_VERSION_VALID} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${AMF_PROVIDER_USERNAME} # Check Results Check Response Variable Type And Values ${resp_2} 200 InvocationLog - Length Should Be ${resp_2.json()["logs"]} 1 + Length Should Be ${resp_2.json()["logs"]} 1 -Get Log Entry with no exist apiVersion filter +Get Log Entry with no exist apiVersion filter [Tags] capif_api_auditing_service-5 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Publish one api Publish Service Api ${register_user_info} - #Register INVOKER + # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - - ${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} + ${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} + ${request_body}= Create Log Entry + ... ${register_user_info['aef_id']} + ... ${register_user_info_invoker['api_invoker_id']} + ... ${api_ids} + ... ${api_names} ${resp_1}= Post Request Capif ... /api-invocation-logs/v1/${register_user_info['aef_id']}/logs ... json=${request_body} @@ -223,21 +203,16 @@ Get Log Entry with no exist apiVersion filter ... verify=ca.crt ... username=${AEF_PROVIDER_USERNAME} - ${resp_2}= Get Request Capif - ... /logs/v1/apiInvocationLogs?aef-id=${register_user_info['aef_id']}&api-invoker-id=${register_user_info_invoker['api_invoker_id']}&api-version=${API_VERSION_NOT_VALID} + ... /logs/v1/apiInvocationLogs?aef-id=${register_user_info['aef_id']}&api-invoker-id=${register_user_info_invoker['api_invoker_id']}&api-version=${API_VERSION_NOT_VALID} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${AMF_PROVIDER_USERNAME} # Check Results - # Check Results - Check Response Variable Type And Values ${resp_2} 404 ProblemDetails + # Check Results + Check Response Variable Type And Values ${resp_2} 404 ProblemDetails ... title=Not Found ... status=404 ... detail=Parameters do not match any log entry ... cause=No logs found - - - - diff --git a/tests/features/CAPIF Api Discover Service/capif_api_service_discover.robot b/tests/features/CAPIF Api Discover Service/capif_api_service_discover.robot index 2b7ed5b..ff82ec3 100644 --- a/tests/features/CAPIF Api Discover Service/capif_api_service_discover.robot +++ b/tests/features/CAPIF Api Discover Service/capif_api_service_discover.robot @@ -1,11 +1,11 @@ *** Settings *** -Resource /opt/robot-tests/tests/resources/common.resource -Resource /opt/robot-tests/tests/resources/api_invoker_management_requests/apiInvokerManagementRequests.robot -Resource ../../resources/common.resource -Library /opt/robot-tests/tests/libraries/bodyRequests.py +Resource /opt/robot-tests/tests/resources/common.resource +Resource /opt/robot-tests/tests/resources/api_invoker_management_requests/apiInvokerManagementRequests.robot +Resource ../../resources/common.resource +Library /opt/robot-tests/tests/libraries/bodyRequests.py -Test Setup Reset Testing Environment -Suite Teardown Reset Testing Environment +Suite Teardown Reset Testing Environment +Test Setup Reset Testing Environment # Test Setup Initialize Test And Register role=invoker @@ -16,12 +16,9 @@ ${API_INVOKER_NOT_REGISTERED} not-valid *** Test Cases *** Discover Published service APIs by Authorised API Invoker [Tags] capif_api_discover_service-1 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Publish one api ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info} @@ -29,9 +26,6 @@ Discover Published service APIs by Authorised API Invoker # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - # Test ${resp}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info['aef_id']} @@ -45,26 +39,19 @@ Discover Published service APIs by Authorised API Invoker Dictionary Should Contain Key ${resp.json()} serviceAPIDescriptions Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 - List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published} - + List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published} Discover Published service APIs by Non Authorised API Invoker [Tags] capif_api_discover_service-2 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Publish one api Publish Service Api ${register_user_info} - #Register INVOKER + # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${resp}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} ... server=${CAPIF_HTTPS_URL} @@ -80,21 +67,15 @@ Discover Published service APIs by Non Authorised API Invoker Discover Published service APIs by not registered API Invoker [Tags] capif_api_discover_service-3 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Publish one api Publish Service Api ${register_user_info} - #Register INVOKER + # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${resp}= Get Request Capif ... ${DISCOVER_URL}${API_INVOKER_NOT_REGISTERED} ... server=${CAPIF_HTTPS_URL} @@ -110,12 +91,9 @@ Discover Published service APIs by not registered API Invoker Discover Published service APIs by registered API Invoker with 1 result filtered [Tags] capif_api_discover_service-4 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${api_name_1}= Set Variable service_1 ${api_name_2}= Set Variable service_2 @@ -130,9 +108,6 @@ Discover Published service APIs by registered API Invoker with 1 result filtered # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - # Request all APIs for Invoker ${resp}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info['aef_id']} @@ -145,8 +120,8 @@ Discover Published service APIs by registered API Invoker with 1 result filtered # Check returned values Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} Length Should Be ${resp.json()['serviceAPIDescriptions']} 2 - List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published_1} - List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published_2} + List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published_1} + List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published_2} # Request api 1 ${resp}= Get Request Capif @@ -164,12 +139,9 @@ Discover Published service APIs by registered API Invoker with 1 result filtered Discover Published service APIs by registered API Invoker filtered with no match [Tags] capif_api_discover_service-5 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${api_name_1}= Set Variable apiName1 ${api_name_2}= Set Variable apiName2 @@ -184,9 +156,6 @@ Discover Published service APIs by registered API Invoker filtered with no match # Change to invoker role and register at api invoker management ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - # Request all APIs for Invoker ${resp}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info['aef_id']} @@ -199,8 +168,8 @@ Discover Published service APIs by registered API Invoker filtered with no match # Check returned values Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} Length Should Be ${resp.json()['serviceAPIDescriptions']} 2 - List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published_1} - List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published_2} + List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published_1} + List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published_2} # Request api 1 ${resp}= Get Request Capif @@ -210,7 +179,10 @@ Discover Published service APIs by registered API Invoker filtered with no match ... username=${INVOKER_USERNAME} # Check Results - Check Response Variable Type And Values ${resp} 404 ProblemDetails + Check Response Variable Type And Values + ... ${resp} + ... 404 + ... ProblemDetails ... title=Not Found ... status=404 ... detail=API Invoker ${register_user_info_invoker['api_invoker_id']} has no API Published that accomplish filter conditions @@ -218,12 +190,9 @@ Discover Published service APIs by registered API Invoker filtered with no match Discover Published service APIs by registered API Invoker not filtered [Tags] capif_api_discover_service-6 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${api_name_1}= Set Variable apiName1 ${api_name_2}= Set Variable apiName2 @@ -238,9 +207,6 @@ Discover Published service APIs by registered API Invoker not filtered # Change to invoker role and register at api invoker management ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - # Request all APIs for Invoker ${resp}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info['aef_id']} @@ -253,5 +219,5 @@ Discover Published service APIs by registered API Invoker not filtered # Check Results Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} Length Should Be ${resp.json()['serviceAPIDescriptions']} 2 - List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published_1} - List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published_2} + List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published_1} + List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published_2} diff --git a/tests/features/CAPIF Api Events/capif_events_api.robot b/tests/features/CAPIF Api Events/capif_events_api.robot index c027769..f2a5966 100644 --- a/tests/features/CAPIF Api Events/capif_events_api.robot +++ b/tests/features/CAPIF Api Events/capif_events_api.robot @@ -1,12 +1,12 @@ *** Settings *** -Resource /opt/robot-tests/tests/resources/common.resource -Library /opt/robot-tests/tests/libraries/bodyRequests.py -Library XML -Resource /opt/robot-tests/tests/resources/common/basicRequests.robot -Resource ../../resources/common.resource +Resource /opt/robot-tests/tests/resources/common.resource +Library /opt/robot-tests/tests/libraries/bodyRequests.py +Library XML +Resource /opt/robot-tests/tests/resources/common/basicRequests.robot +Resource ../../resources/common.resource -Test Setup Reset Testing Environment -Suite Teardown Reset Testing Environment +Suite Teardown Reset Testing Environment +Test Setup Reset Testing Environment *** Variables *** @@ -21,9 +21,6 @@ Creates a new individual CAPIF Event Subscription # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${request_body}= Create Events Subscription ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions @@ -41,9 +38,6 @@ Creates a new individual CAPIF Event Subscription with Invalid SubscriberId # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${request_body}= Create Events Subscription ${resp}= Post Request Capif ... /capif-events/v1/${SUBSCRIBER_ID_NOT_VALID}/subscriptions @@ -53,7 +47,7 @@ Creates a new individual CAPIF Event Subscription with Invalid SubscriberId ... username=${INVOKER_USERNAME} # Check Results - Check Response Variable Type And Values ${resp} 404 ProblemDetails + Check Response Variable Type And Values ${resp} 404 ProblemDetails ... title=Not Found ... status=404 ... detail=Invoker or APF or AEF or AMF Not found @@ -64,9 +58,6 @@ Deletes an individual CAPIF Event Subscription # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${request_body}= Create Events Subscription ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions @@ -92,9 +83,6 @@ Deletes an individual CAPIF Event Subscription with invalid SubscriberId # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${request_body}= Create Events Subscription ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions @@ -112,24 +100,20 @@ Deletes an individual CAPIF Event Subscription with invalid SubscriberId ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME} - + # Check Results - Check Response Variable Type And Values ${resp} 404 ProblemDetails + Check Response Variable Type And Values ${resp} 404 ProblemDetails ... title=Not Found ... status=404 ... detail=Invoker or APF or AEF or AMF Not found ... cause=Subscriber Not Found - Deletes an individual CAPIF Event Subscription with invalid SubscriptionId [Tags] capif_api_events-5 # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${request_body}= Create Events Subscription ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions @@ -153,4 +137,3 @@ Deletes an individual CAPIF Event Subscription with invalid SubscriptionId ... title=Unauthorized ... detail=User not authorized ... cause=You are not the owner of this resource - diff --git a/tests/features/CAPIF Api Invoker Management/capif_api_invoker_managenet.robot b/tests/features/CAPIF Api Invoker Management/capif_api_invoker_managenet.robot index 7127cc4..8c40f72 100644 --- a/tests/features/CAPIF Api Invoker Management/capif_api_invoker_managenet.robot +++ b/tests/features/CAPIF Api Invoker Management/capif_api_invoker_managenet.robot @@ -1,13 +1,13 @@ *** Settings *** -Resource /opt/robot-tests/tests/resources/common.resource -Resource /opt/robot-tests/tests/resources/api_invoker_management_requests/apiInvokerManagementRequests.robot -Resource ../../resources/common.resource -Library /opt/robot-tests/tests/libraries/bodyRequests.py -Library Process -Library Collections +Resource /opt/robot-tests/tests/resources/common.resource +Resource /opt/robot-tests/tests/resources/api_invoker_management_requests/apiInvokerManagementRequests.robot +Resource ../../resources/common.resource +Library /opt/robot-tests/tests/libraries/bodyRequests.py +Library Process +Library Collections -Test Setup Reset Testing Environment -Suite Teardown Reset Testing Environment +Suite Teardown Reset Testing Environment +Test Setup Reset Testing Environment *** Variables *** @@ -17,7 +17,7 @@ ${API_INVOKER_NOT_REGISTERED} not-valid *** Test Cases *** Onboard NetApp [Tags] capif_api_invoker_management-1 - #Register Netapp + # Register Netapp ${register_user_info}= Register User At Jwt Auth ... username=${INVOKER_USERNAME} role=${INVOKER_ROLE} @@ -34,9 +34,9 @@ Onboard NetApp ... access_token=${register_user_info['access_token']} # Check Results - Check Response Variable Type And Values ${resp} 201 APIInvokerEnrolmentDetails + Check Response Variable Type And Values ${resp} 201 APIInvokerEnrolmentDetails ${url}= Parse Url ${resp.headers['Location']} - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} + Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} Check Location Header ${resp} ${LOCATION_INVOKER_RESOURCE_REGEX} # Store dummy signed certificate @@ -47,8 +47,6 @@ Register NetApp Already Onboarded # Default Invoker Registration and Onboarding ${register_user_info} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - ${resp}= Post Request Capif ... ${register_user_info['ccf_onboarding_url']} ... json=${request_body} @@ -70,8 +68,6 @@ Update Onboarded NetApp # Default Invoker Registration and Onboarding ${register_user_info} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - Set To Dictionary ... ${request_body} ... notificationDestination=${new_notification_destination} @@ -92,8 +88,6 @@ Update Not Onboarded NetApp # Default Invoker Registration and Onboarding ${register_user_info} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - ${resp}= Put Request Capif ... /api-invoker-management/v1/onboardedInvokers/${INVOKER_NOT_REGISTERED} ... ${request_body} @@ -118,6 +112,8 @@ Offboard NetApp ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME} + + Call Method ${CAPIF_USERS} remove_capif_users_entry ${url.path} # Check Results Should Be Equal As Strings ${resp.status_code} 204 @@ -127,8 +123,6 @@ Offboard Not Previously Onboarded NetApp # Default Invoker Registration and Onboarding ${register_user_info} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - ${resp}= Delete Request Capif ... /api-invoker-management/v1/onboardedInvokers/${INVOKER_NOT_REGISTERED} ... server=${CAPIF_HTTPS_URL} @@ -149,9 +143,7 @@ Update Onboarded NetApp Certificate # Default Invoker Registration and Onboarding ${register_user_info} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${INVOKER_USERNAME_NEW}= Set Variable ${INVOKER_USERNAME}_NEW + ${INVOKER_USERNAME_NEW}= Set Variable ${INVOKER_USERNAME}_NEW ${csr_request_new}= Create User Csr ${INVOKER_USERNAME_NEW} invoker @@ -189,5 +181,3 @@ Update Onboarded NetApp Certificate # Check Results Check Response Variable Type And Values ${resp} 200 APIInvokerEnrolmentDetails ... notificationDestination=${new_notification_destination} - - diff --git a/tests/features/CAPIF Api Logging Service/capif_logging_api.robot b/tests/features/CAPIF Api Logging Service/capif_logging_api.robot index 2604bdb..a7a0253 100644 --- a/tests/features/CAPIF Api Logging Service/capif_logging_api.robot +++ b/tests/features/CAPIF Api Logging Service/capif_logging_api.robot @@ -1,12 +1,13 @@ *** Settings *** -Resource /opt/robot-tests/tests/resources/common.resource -Library /opt/robot-tests/tests/libraries/bodyRequests.py -Library Collections -Resource /opt/robot-tests/tests/resources/common/basicRequests.robot -Resource ../../resources/common.resource +Resource /opt/robot-tests/tests/resources/common.resource +Library /opt/robot-tests/tests/libraries/bodyRequests.py +Library Collections +Resource /opt/robot-tests/tests/resources/common/basicRequests.robot +Resource ../../resources/common.resource + +Suite Teardown Reset Testing Environment +Test Setup Reset Testing Environment -Test Setup Reset Testing Environment -Suite Teardown Reset Testing Environment *** Variables *** ${AEF_ID_NOT_VALID} aef-example @@ -14,34 +15,33 @@ ${SERVICE_API_ID_NOT_VALID} not-valid ${API_INVOKER_NOT_VALID} not-valid ${NOTIFICATION_DESTINATION} http://robot.testing:1080 + *** Test Cases *** Create a log entry [Tags] capif_api_logging_service-1 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Publish one api Publish Service Api ${register_user_info} - #Register INVOKER + # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${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} + ${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} + ${request_body}= Create Log Entry + ... ${register_user_info['aef_id']} + ... ${register_user_info_invoker['api_invoker_id']} + ... ${api_ids} + ... ${api_names} ${resp}= Post Request Capif ... /api-invocation-logs/v1/${register_user_info['aef_id']}/logs ... json=${request_body} @@ -49,38 +49,35 @@ Create a log entry ... 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} Create a log entry invalid aefId [Tags] capif_api_logging_service-2 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Publish one api Publish Service Api ${register_user_info} - #Register INVOKER + # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${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} + ${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} + ${request_body}= Create Log Entry + ... ${register_user_info['aef_id']} + ... ${register_user_info_invoker['api_invoker_id']} + ... ${api_ids} + ... ${api_names} ${resp}= Post Request Capif ... /api-invocation-logs/v1/${AEF_ID_NOT_VALID}/logs ... json=${request_body} @@ -89,31 +86,23 @@ Create a log entry invalid aefId ... username=${AEF_PROVIDER_USERNAME} # Check Results - Check Response Variable Type And Values ${resp} 404 ProblemDetails + Check Response Variable Type And Values ${resp} 404 ProblemDetails ... title=Not Found ... status=404 ... detail=Exposer not exist ... cause=Exposer id not found - - Create a log entry invalid serviceApi [Tags] capif_api_logging_service-3 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Publish one api Publish Service Api ${register_user_info} - #Register INVOKER + # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} ... server=${CAPIF_HTTPS_URL} @@ -121,7 +110,9 @@ Create a log entry invalid serviceApi ... username=${INVOKER_USERNAME} # Create Log Entry - ${request_body}= Create Log Entry Bad Service ${register_user_info['aef_id']} ${register_user_info_invoker['api_invoker_id']} + ${request_body}= Create Log Entry Bad Service + ... ${register_user_info['aef_id']} + ... ${register_user_info_invoker['api_invoker_id']} ${resp}= Post Request Capif ... /api-invocation-logs/v1/${register_user_info['aef_id']}/logs ... json=${request_body} @@ -137,31 +128,29 @@ Create a log entry invalid serviceApi Create a log entry invalid apiInvokerId [Tags] capif_api_logging_service-4 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Publish one api Publish Service Api ${register_user_info} - #Register INVOKER + # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${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} + ${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']} ${API_INVOKER_NOT_VALID} ${api_ids} ${api_names} + ${request_body}= Create Log Entry + ... ${register_user_info['aef_id']} + ... ${API_INVOKER_NOT_VALID} + ... ${api_ids} + ... ${api_names} ${resp}= Post Request Capif ... /api-invocation-logs/v1/${register_user_info['aef_id']}/logs ... json=${request_body} @@ -176,35 +165,31 @@ Create a log entry invalid apiInvokerId ... detail=Invoker not exist ... cause=Invoker id not found - Create a log entry different aef_id in body [Tags] capif_api_logging_service-5 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Publish one api Publish Service Api ${register_user_info} - #Register INVOKER + # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - - ${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} + ${api_ids} ${api_names}= Get Api Ids And Names From Discover Response ${discover_response} # Create Log Entry - ${request_body}= Create Log Entry ${AEF_ID_NOT_VALID} ${register_user_info_invoker['api_invoker_id']} ${api_ids} ${api_names} + ${request_body}= Create Log Entry + ... ${AEF_ID_NOT_VALID} + ... ${register_user_info_invoker['api_invoker_id']} + ... ${api_ids} + ... ${api_names} ${resp}= Post Request Capif ... /api-invocation-logs/v1/${register_user_info['aef_id']}/logs ... json=${request_body} @@ -218,4 +203,3 @@ Create a log entry different aef_id in body ... status=401 ... detail=AEF id not matching in request and body ... cause=Not identical AEF id - diff --git a/tests/features/CAPIF Api Provider Management/capif_api_provider_management.robot b/tests/features/CAPIF Api Provider Management/capif_api_provider_management.robot index f47385f..a6f9674 100644 --- a/tests/features/CAPIF Api Provider Management/capif_api_provider_management.robot +++ b/tests/features/CAPIF Api Provider Management/capif_api_provider_management.robot @@ -64,12 +64,6 @@ Register Api Provider Already registered [Tags] capif_api_provider_management-2 ${register_user_info}= Provider Default Registration - Call Method - ... ${CAPIF_USERS} - ... update_capif_users_dicts - ... ${register_user_info['resource_url'].path} - ... ${AMF_PROVIDER_USERNAME} - ${resp}= Post Request Capif ... /api-provider-management/v1/registrations ... json=${register_user_info['provider_enrollment_details']} @@ -88,12 +82,6 @@ Update Registered Api Provider [Tags] capif_api_provider_management-3 ${register_user_info}= Provider Default Registration - Call Method - ... ${CAPIF_USERS} - ... update_capif_users_dicts - ... ${register_user_info['resource_url'].path} - ... ${AMF_PROVIDER_USERNAME} - ${request_body}= Set Variable ${register_user_info['provider_enrollment_details']} Set To Dictionary ${request_body} apiProvDomInfo=ROBOT_TESTING_MOD @@ -127,12 +115,6 @@ Update Not Registered Api Provider [Tags] capif_api_provider_management-4 ${register_user_info}= Provider Default Registration - Call Method - ... ${CAPIF_USERS} - ... update_capif_users_dicts - ... ${register_user_info['resource_url'].path} - ... ${AMF_PROVIDER_USERNAME} - ${request_body}= Set Variable ${register_user_info['provider_enrollment_details']} ${resp}= Put Request Capif @@ -173,12 +155,6 @@ Partially Update Not Registered Api Provider [Tags] capif_api_provider_management-6 ${register_user_info}= Provider Default Registration - Call Method - ... ${CAPIF_USERS} - ... update_capif_users_dicts - ... ${register_user_info['resource_url'].path} - ... ${AMF_PROVIDER_USERNAME} - ${request_body}= Create Api Provider Enrolment Details Patch Body ${resp}= Patch Request Capif @@ -205,6 +181,8 @@ Delete Registered Api Provider ... verify=ca.crt ... username=${AMF_PROVIDER_USERNAME} + Call Method ${CAPIF_USERS} remove_capif_users_entry ${register_user_info['resource_url'].path} + # Check Results Status Should Be 204 ${resp} @@ -212,12 +190,6 @@ Delete Not Registered Api Provider [Tags] capif_api_provider_management-8 ${register_user_info}= Provider Default Registration - Call Method - ... ${CAPIF_USERS} - ... update_capif_users_dicts - ... ${register_user_info['resource_url'].path} - ... ${AMF_PROVIDER_USERNAME} - ${resp}= Delete Request Capif ... /api-provider-management/v1/registrations/${API_PROVIDER_NOT_REGISTERED} ... server=${CAPIF_HTTPS_URL} diff --git a/tests/features/CAPIF Api Publish Service/capif_api_publish_service.robot b/tests/features/CAPIF Api Publish Service/capif_api_publish_service.robot index daef4be..56484d2 100644 --- a/tests/features/CAPIF Api Publish Service/capif_api_publish_service.robot +++ b/tests/features/CAPIF Api Publish Service/capif_api_publish_service.robot @@ -1,11 +1,11 @@ *** Settings *** -Resource /opt/robot-tests/tests/resources/common.resource -Resource ../../resources/common/basicRequests.robot -Resource ../../resources/common.resource -Library /opt/robot-tests/tests/libraries/bodyRequests.py +Resource /opt/robot-tests/tests/resources/common.resource +Resource ../../resources/common/basicRequests.robot +Resource ../../resources/common.resource +Library /opt/robot-tests/tests/libraries/bodyRequests.py -Test Setup Reset Testing Environment -Suite Teardown Reset Testing Environment +Suite Teardown Reset Testing Environment +Test Setup Reset Testing Environment *** Variables *** @@ -16,12 +16,9 @@ ${SERVICE_API_ID_NOT_VALID} not-valid *** Test Cases *** Publish API by Authorised API Publisher [Tags] capif_api_publish_service-1 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Test ${request_body}= Create Service Api Description service_1 ${resp}= Post Request Capif @@ -38,12 +35,9 @@ Publish API by Authorised API Publisher Publish API by NON Authorised API Publisher [Tags] capif_api_publish_service-2 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${request_body}= Create Service Api Description ${resp}= Post Request Capif ... /published-apis/v1/${APF_ID_NOT_VALID}/service-apis @@ -60,12 +54,9 @@ Publish API by NON Authorised API Publisher Retrieve all APIs Published by Authorised apfId [Tags] capif_api_publish_service-3 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Register One Service ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info} @@ -88,12 +79,9 @@ Retrieve all APIs Published by Authorised apfId Retrieve all APIs Published by NON Authorised apfId [Tags] capif_api_publish_service-4 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Retrieve Services published ${resp}= Get Request Capif ... /published-apis/v1/${APF_ID_NOT_VALID}/service-apis @@ -109,12 +97,9 @@ Retrieve all APIs Published by NON Authorised apfId Retrieve single APIs Published by Authorised apfId [Tags] capif_api_publish_service-5 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info} ... service_1 @@ -148,19 +133,15 @@ Retrieve single APIs Published by Authorised apfId Retrieve single APIs non Published by Authorised apfId [Tags] capif_api_publish_service-6 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${resp}= Get Request Capif ... /published-apis/v1/${register_user_info['apf_id']}/service-apis/${SERVICE_API_ID_NOT_VALID} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${APF_PROVIDER_USERNAME} - Check Response Variable Type And Values ${resp} 401 ProblemDetails ... title=Unauthorized ... detail=User not authorized @@ -171,9 +152,6 @@ Retrieve single APIs Published by NON Authorised apfId # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Publish Service API ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info} @@ -182,9 +160,6 @@ Retrieve single APIs Published by NON Authorised apfId # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${resp}= Get Request Capif ... ${resource_url.path} ... server=${CAPIF_HTTPS_URL} @@ -199,12 +174,9 @@ Retrieve single APIs Published by NON Authorised apfId Update API Published by Authorised apfId with valid serviceApiId [Tags] capif_api_publish_service-8 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info} ... service_1 @@ -232,12 +204,9 @@ Update API Published by Authorised apfId with valid serviceApiId Update APIs Published by Authorised apfId with invalid serviceApiId [Tags] capif_api_publish_service-9 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info} ... service_1 @@ -257,22 +226,16 @@ Update APIs Published by Authorised apfId with invalid serviceApiId Update APIs Published by NON Authorised apfId [Tags] capif_api_publish_service-10 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info} ... service_1 - #Register INVOKER + # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${request_body}= Create Service Api Description service_1_modified ${resp}= Put Request Capif ... ${resource_url.path} @@ -299,12 +262,9 @@ Update APIs Published by NON Authorised apfId Delete API Published by Authorised apfId with valid serviceApiId [Tags] capif_api_publish_service-11 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info} ... first_service @@ -330,12 +290,9 @@ Delete API Published by Authorised apfId with valid serviceApiId Delete APIs Published by Authorised apfId with invalid serviceApiId [Tags] capif_api_publish_service-12 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${resp}= Delete Request Capif ... /published-apis/v1/${register_user_info['apf_id']}/service-apis/${SERVICE_API_ID_NOT_VALID} ... server=${CAPIF_HTTPS_URL} @@ -349,18 +306,12 @@ Delete APIs Published by Authorised apfId with invalid serviceApiId Delete APIs Published by NON Authorised apfId [Tags] capif_api_publish_service-13 - #Register APF + # Register APF ${register_user_info}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - - #Register INVOKER + # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${resp}= Delete Request Capif ... /published-apis/v1/${register_user_info['apf_id']}/service-apis/${SERVICE_API_ID_NOT_VALID} ... server=${CAPIF_HTTPS_URL} diff --git a/tests/features/CAPIF Security Api/capif_security_api.robot b/tests/features/CAPIF Security Api/capif_security_api.robot index 4e27948..6342aa9 100644 --- a/tests/features/CAPIF Security Api/capif_security_api.robot +++ b/tests/features/CAPIF Security Api/capif_security_api.robot @@ -1,12 +1,12 @@ *** Settings *** -Resource /opt/robot-tests/tests/resources/common.resource -Library /opt/robot-tests/tests/libraries/bodyRequests.py -Library Collections -Resource /opt/robot-tests/tests/resources/common/basicRequests.robot -Resource ../../resources/common.resource +Resource /opt/robot-tests/tests/resources/common.resource +Library /opt/robot-tests/tests/libraries/bodyRequests.py +Library Collections +Resource /opt/robot-tests/tests/resources/common/basicRequests.robot +Resource ../../resources/common.resource -Test Setup Reset Testing Environment -Suite Teardown Reset Testing Environment +Suite Teardown Reset Testing Environment +Test Setup Reset Testing Environment *** Variables *** @@ -22,9 +22,6 @@ Create a security context for an API invoker # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - # Create Security Context ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif @@ -43,15 +40,9 @@ Create a security context for an API invoker with Provider role # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - # Register Provider ${register_user_info_publisher}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Create Security Context ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif @@ -73,9 +64,6 @@ Create a security context for an API invoker with Provider entity role and inval # Register APF ${register_user_info_publisher}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Create Security Context ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif @@ -97,9 +85,6 @@ Create a security context for an API invoker with Invalid apiInvokerID # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${API_INVOKER_NOT_VALID} @@ -120,9 +105,6 @@ Retrieve the Security Context of an API Invoker # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} @@ -139,9 +121,6 @@ Retrieve the Security Context of an API Invoker # Register APF ${register_user_info_publisher}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Retrieve Security context can setup by parameters if authenticationInfo and authorizationInfo are needed at response. # ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']}?authenticationInfo=true&authorizationInfo=true ${resp}= Get Request Capif @@ -165,9 +144,6 @@ Retrieve the Security Context of an API Invoker with invalid apiInvokerID # Register APF ${register_user_info_publisher}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${resp}= Get Request Capif ... /capif-security/v1/trustedInvokers/${API_INVOKER_NOT_VALID} ... server=${CAPIF_HTTPS_URL} @@ -185,9 +161,6 @@ Retrieve the Security Context of an API Invoker with invalid apfId # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} @@ -217,9 +190,6 @@ Delete the Security Context of an API Invoker # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} @@ -233,9 +203,6 @@ Delete the Security Context of an API Invoker # Register APF ${register_user_info_publisher}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Remove Security Context ${resp}= Delete Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} @@ -263,9 +230,6 @@ Delete the Security Context of an API Invoker with Invoker entity role # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} @@ -294,9 +258,6 @@ Delete the Security Context of an API Invoker with Invoker entity role and inval # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${resp}= Delete Request Capif ... /capif-security/v1/trustedInvokers/${API_INVOKER_NOT_VALID} ... server=${CAPIF_HTTPS_URL} @@ -315,9 +276,6 @@ Delete the Security Context of an API Invoker with invalid apiInvokerID # Register Provider ${register_user_info_publisher}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${resp}= Delete Request Capif ... /capif-security/v1/trustedInvokers/${API_INVOKER_NOT_VALID} ... server=${CAPIF_HTTPS_URL} @@ -336,15 +294,9 @@ Update the Security Context of an API Invoker # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - # Register Provider ${register_user_info_publisher}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} @@ -389,9 +341,6 @@ Update the Security Context of an API Invoker with Provider entity role # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} @@ -402,12 +351,9 @@ Update the Security Context of an API Invoker with Provider entity role Check Response Variable Type And Values ${resp} 201 ServiceSecurity - #Register Provider + # Register Provider ${register_user_info_publisher}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${resp}= Post Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']}/update ... json=${request_body} @@ -424,12 +370,9 @@ Update the Security Context of an API Invoker with Provider entity role Update the Security Context of an API Invoker with AEF entity role and invalid apiInvokerId [Tags] capif_security_api-14 - #Register Provider + # Register Provider ${register_user_info_publisher}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Post Request Capif ... /capif-security/v1/trustedInvokers/${API_INVOKER_NOT_VALID}/update @@ -449,9 +392,6 @@ Update the Security Context of an API Invoker with invalid apiInvokerID # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Post Request Capif ... /capif-security/v1/trustedInvokers/${API_INVOKER_NOT_VALID}/update @@ -472,9 +412,6 @@ Revoke the authorization of the API invoker for APIs # Register APF ${register_user_info_provider}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${api_name}= Set Variable service_1 # Register One Service @@ -485,10 +422,6 @@ Revoke the authorization of the API invoker for APIs # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - - # Test ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info_provider['aef_id']} @@ -545,9 +478,6 @@ Revoke the authorization of the API invoker for APIs without valid apfID. # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} @@ -563,9 +493,6 @@ Revoke the authorization of the API invoker for APIs without valid apfID. # Register Provider ${register_user_info_publisher}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - # Revoke Security Context by Invoker ${request_body}= Create Security Notification Body ${register_user_info_invoker['api_invoker_id']} 1234 ${resp}= Post Request Capif @@ -601,9 +528,6 @@ Revoke the authorization of the API invoker for APIs with invalid apiInvokerId # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} @@ -616,12 +540,9 @@ Revoke the authorization of the API invoker for APIs with invalid apiInvokerId ${security_context}= Set Variable ${resp.json()} - #Register Provider + # Register Provider ${register_user_info_publisher}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_publisher['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${request_body}= Create Security Notification Body ${API_INVOKER_NOT_VALID} 1234 ${resp}= Post Request Capif ... /capif-security/v1/trustedInvokers/${API_INVOKER_NOT_VALID}/delete @@ -652,9 +573,6 @@ Retrieve access token # Register APF ${register_user_info_provider}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${api_name}= Set Variable service_1 # Register One Service @@ -665,9 +583,6 @@ Retrieve access token # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - # Test ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api-name=${api_name} @@ -711,9 +626,6 @@ Retrieve access token by Provider # Register APF ${register_user_info_provider}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${api_name}= Set Variable service_1 # Register One Service @@ -724,9 +636,6 @@ Retrieve access token by Provider # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - # Test ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api-name=${api_name} @@ -769,9 +678,6 @@ Retrieve access token by Provider with invalid apiInvokerId # Register APF ${register_user_info_provider}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${api_name}= Set Variable service_1 # Register One Service @@ -782,9 +688,6 @@ Retrieve access token by Provider with invalid apiInvokerId # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - # Test ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api-name=${api_name} @@ -828,9 +731,6 @@ Retrieve access token with invalid apiInvokerId # Register APF ${register_user_info_provider}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${api_name}= Set Variable service_1 # Register One Service @@ -841,9 +741,6 @@ Retrieve access token with invalid apiInvokerId # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - # Test ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api-name=${api_name} @@ -889,9 +786,6 @@ Retrieve access token with invalid client_id # Register APF ${register_user_info_provider}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${api_name}= Set Variable service_1 # Register One Service @@ -902,9 +796,6 @@ Retrieve access token with invalid client_id # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - # Test ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api-name=${api_name} @@ -948,9 +839,6 @@ Retrieve access token with unsupported grant_type # Register APF ${register_user_info_provider}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${api_name}= Set Variable service_1 # Register One Service @@ -961,9 +849,6 @@ Retrieve access token with unsupported grant_type # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - # Test ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api-name=${api_name} @@ -1014,9 +899,6 @@ Retrieve access token with invalid scope # Register APF ${register_user_info_provider}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${api_name}= Set Variable service_1 # Register One Service @@ -1027,9 +909,6 @@ Retrieve access token with invalid scope # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - # Test ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api-name=${api_name} @@ -1075,9 +954,6 @@ Retrieve access token with invalid aefid at scope # Register APF ${register_user_info_provider}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${api_name}= Set Variable service_1 # Register One Service @@ -1088,9 +964,6 @@ Retrieve access token with invalid aefid at scope # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - # Test ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api-name=${api_name} @@ -1136,9 +1009,6 @@ Retrieve access token with invalid apiName at scope # Register APF ${register_user_info_provider}= Provider Default Registration - Call Method ${CAPIF_USERS} update_capif_users_dicts ${register_user_info_provider['resource_url'].path} ${AMF_PROVIDER_USERNAME} - - ${api_name}= Set Variable service_1 # Register One Service @@ -1149,9 +1019,6 @@ Retrieve access token with invalid apiName at scope # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} - - # Test ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api-name=${api_name} @@ -1189,4 +1056,4 @@ Retrieve access token with invalid apiName at scope # Check Results Check Response Variable Type And Values ${resp} 400 AccessTokenErr ... error=invalid_scope - ... error_description=One of the api names does not exist or is not associated with the aef id provided \ No newline at end of file + ... error_description=One of the api names does not exist or is not associated with the aef id provided diff --git a/tests/resources/common/basicRequests.robot b/tests/resources/common/basicRequests.robot index 3a24b84..ea3a96f 100644 --- a/tests/resources/common/basicRequests.robot +++ b/tests/resources/common/basicRequests.robot @@ -5,7 +5,7 @@ Library RequestsLibrary Library Collections Library OperatingSystem Library XML -Library Telnet +Library Telnet *** Variables *** @@ -58,31 +58,31 @@ Create Register Admin Session [Documentation] Create needed session to reach Register as Administrator. [Arguments] ${server}=${NONE} ${access_token}=${NONE} ${verify}=${NONE} ${vault_token}=${NONE} IF "${server}" != "${NONE}" - IF "${access_token}" != "${NONE}" + IF "${access_token}" != "${NONE}" ## Return Header with bearer ${headers}= Create Dictionary Authorization=Bearer ${access_token} - RETURN ${headers} + RETURN ${headers} END - + # Request Admin Login to retrieve access token - Create Session register_session ${server} verify=${verify} disable_warnings=1 + Create Session register_session ${server} verify=${verify} disable_warnings=1 ${auth}= Set variable ${{ ('${REGISTER_ADMIN_USER}','${REGISTER_ADMIN_PASSWORD}') }} - ${resp}= POST On Session register_session /login auth=${auth} + ${resp}= POST On Session register_session /login auth=${auth} Log Dictionary ${resp.json()} - + ## Crear sesiĆ³n con token ${headers}= Create Dictionary Authorization=Bearer ${resp.json()['access_token']} - RETURN ${headers} + RETURN ${headers} END - RETURN ${NONE} ## NEW REQUESTS TO REGISTER + Post Request Admin Register [Timeout] 60s [Arguments] @@ -139,12 +139,8 @@ Get Request Admin Register ... cert=${cert} RETURN ${resp} - - - # NEW REQUESTS END - Post Request Capif [Timeout] 60s [Arguments] @@ -327,8 +323,12 @@ Register User At Jwt Auth END Log cn=${cn} - - ${resp}= Create User At Register ${username} ${password} ${description} email="${username}@nobody.com" + + ${resp}= Create User At Register + ... ${username} + ... ${password} + ... ${description} + ... email="${username}@nobody.com" ${get_auth_response}= Get Auth For User ${username} ${password} @@ -353,7 +353,7 @@ Register User At Jwt Auth Store In File ${username}.key ${register_user_info['private_key']} END - Call Method ${CAPIF_USERS} update_register_users ${register_user_info['uuid']} ${username} + Call Method ${CAPIF_USERS} update_register_users ${register_user_info['uuid']} ${username} RETURN ${register_user_info} @@ -372,7 +372,11 @@ Register User At Jwt Auth Provider ${amf_csr_request}= Create User Csr ${amf_username} amf # Register provider - ${resp}= Create User At Register ${username} ${password} ${description} email="${username}@nobody.com" + ${resp}= Create User At Register + ... ${username} + ... ${password} + ... ${description} + ... email="${username}@nobody.com" ${get_auth_response}= Get Auth For User ${username} ${password} @@ -392,59 +396,62 @@ Register User At Jwt Auth Provider Log Dictionary ${register_user_info} - Call Method ${CAPIF_USERS} update_register_users ${register_user_info['uuid']} ${username} + Call Method ${CAPIF_USERS} update_register_users ${register_user_info['uuid']} ${username} RETURN ${register_user_info} - Login Register Admin - ${headers}= Create Register Admin Session ${CAPIF_HTTPS_REGISTER_URL} - RETURN ${headers} + ${headers}= Create Register Admin Session ${CAPIF_HTTPS_REGISTER_URL} + RETURN ${headers} Create User At Register - [Documentation] (Administrator) This Keyword create a user at register component. - [Arguments] ${username} ${password} ${description} ${email} - + [Documentation] (Administrator) This Keyword create a user at register component. + [Arguments] ${username} ${password} ${description} ${email} + # Obtain Admin Token to request creation of User ${headers}= Login Register Admin - - &{body}= Create Dictionary username=${username} password=${password} description=${description} email=${email} - ${resp}= Post On Session register_session /createUser headers=${headers} json=${body} + + &{body}= Create Dictionary + ... username=${username} + ... password=${password} + ... description=${description} + ... email=${email} + ${resp}= Post On Session register_session /createUser headers=${headers} json=${body} Should Be Equal As Strings ${resp.status_code} 201 - + RETURN ${resp} Delete User At Register - [Documentation] (Administrator) This Keyword delete a user from register. - [Arguments] ${username}=${NONE} ${uuid}=${NONE} - ${user_uuid}= Set Variable ${uuid} + [Documentation] (Administrator) This Keyword delete a user from register. + [Arguments] ${username}=${NONE} ${uuid}=${NONE} + ${user_uuid}= Set Variable ${uuid} - IF "${username}" != "${NONE}" - ${user_uuid}= Call Method ${CAPIF_USERS} get_user_uuid ${username} + IF "${username}" != "${NONE}" + ${user_uuid}= Call Method ${CAPIF_USERS} get_user_uuid ${username} END - ${headers}= Create Register Admin Session ${CAPIF_HTTPS_REGISTER_URL} verify=False + ${headers}= Create Register Admin Session ${CAPIF_HTTPS_REGISTER_URL} verify=False - ${resp}= DELETE On Session register_session /deleteUser/${user_uuid} headers=${headers} + ${resp}= DELETE On Session register_session /deleteUser/${user_uuid} headers=${headers} Should Be Equal As Strings ${resp.status_code} 204 Call Method ${CAPIF_USERS} remove_register_users_entry ${user_uuid} - RETURN ${resp} + RETURN ${resp} Get List of User At Register - [Documentation] (Administrator) This Keyword retrieve a list of users from register. - ${headers}= Create Register Admin Session ${CAPIF_HTTPS_REGISTER_URL} verify=False + [Documentation] (Administrator) This Keyword retrieve a list of users from register. + ${headers}= Create Register Admin Session ${CAPIF_HTTPS_REGISTER_URL} verify=False - ${resp}= DELETE On Session register_session /getUsers headers=${headers} + ${resp}= DELETE On Session register_session /getUsers headers=${headers} Should Be Equal As Strings ${resp.status_code} 200 - RETURN ${resp.json()['users']} + RETURN ${resp.json()['users']} Get Auth For User - [Documentation] (User) This Keyword retrieve token to be used by user towards first interaction with CCF. + [Documentation] (User) This Keyword retrieve token to be used by user towards first interaction with CCF. [Arguments] ${username} ${password} ${auth}= Set variable ${{ ('${username}','${password}') }} ${resp}= GET On Session register_session /getauth auth=${auth} @@ -475,11 +482,11 @@ Clean Test Information ${uuids}= Get Dictionary Keys ${register_users_dict} FOR ${uuid} IN @{uuids} - Delete User At Register uuid=${uuid} + Delete User At Register uuid=${uuid} END Remove entity - [Arguments] ${entity_user} ${certificate_name}=${entity_user} + [Arguments] ${entity_user} ${certificate_name}=${entity_user} ${capif_users_dict}= Call Method ${CAPIF_USERS} get_capif_users_dict @@ -491,7 +498,7 @@ Remove entity FOR ${key} IN @{keys} ${value}= Get From Dictionary ${capif_users_dict} ${key} - IF "${value}" == "${certificate_name}" + IF "${value}" == "${certificate_name}" ${resp}= Delete Request Capif ... ${key} ... server=${CAPIF_HTTPS_URL} @@ -503,14 +510,14 @@ Remove entity Call Method ${CAPIF_USERS} remove_capif_users_entry ${key} END END - - Delete User At Register username=${entity_user} + + Delete User At Register username=${entity_user} Log Dictionary ${capif_users_dict} Log Dictionary ${register_users_dict} Remove Resource - [Arguments] ${resource_url} ${management_cert} ${username} + [Arguments] ${resource_url} ${management_cert} ${username} ${resp}= Delete Request Capif ... ${resource_url} @@ -530,7 +537,6 @@ Remove Resource Should Be Equal As Strings ${resp.status_code} 204 - Invoker Default Onboarding [Arguments] ${invoker_username}=${INVOKER_USERNAME} ${register_user_info}= Register User At Jwt Auth @@ -554,11 +560,12 @@ Invoker Default Onboarding # Assertions Status Should Be 201 ${resp} Check Variable ${resp.json()} APIInvokerEnrolmentDetails - ${resource_url}= Check Location Header ${resp} ${LOCATION_INVOKER_RESOURCE_REGEX} + ${resource_url}= Check Location Header ${resp} ${LOCATION_INVOKER_RESOURCE_REGEX} # Store dummy signede certificate Store In File ${invoker_username}.crt ${resp.json()['onboardingInformation']['apiInvokerCertificate']} ${url}= Parse Url ${resp.headers['Location']} + Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${invoker_username} Set To Dictionary ${register_user_info} resource_url=${resource_url} Set To Dictionary ${register_user_info} management_cert=${invoker_username} @@ -622,6 +629,12 @@ Provider Registration ... provider_register_response=${resp} ... management_cert=${register_user_info['amf_username']} + Call Method + ... ${CAPIF_USERS} + ... update_capif_users_dicts + ... ${register_user_info['resource_url'].path} + ... ${register_user_info['amf_username']} + RETURN ${register_user_info} Provider Default Registration @@ -633,6 +646,7 @@ Provider Default Registration ${register_user_info}= Provider Registration ${register_user_info} Log Dictionary ${register_user_info} + RETURN ${register_user_info} Publish Service Api @@ -657,13 +671,6 @@ Basic ACL registration # Register APF ${register_user_info_provider}= Provider Default Registration - Call Method - ... ${CAPIF_USERS} - ... update_capif_users_dicts - ... ${register_user_info_provider['resource_url'].path} - ... ${AMF_PROVIDER_USERNAME} - Call Method ${CAPIF_USERS} update_register_users ${register_user_info_provider['uuid']} ${PROVIDER_USERNAME} - ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info_provider} ... service_1 @@ -714,7 +721,7 @@ Basic ACL registration RETURN ${register_user_info_invoker} ${register_user_info_provider} ${service_api_description_published} Create Security Context Between invoker and provider - [Arguments] ${register_user_info_invoker} ${register_user_info_provider} + [Arguments] ${register_user_info_invoker} ${register_user_info_provider} ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info_provider['aef_id']} @@ -737,4 +744,3 @@ Create Security Context Between invoker and provider ... username=${register_user_info_invoker['management_cert']} Check Response Variable Type And Values ${resp} 201 ServiceSecurity - -- GitLab