Skip to content
Snippets Groups Projects
README.md 60.2 KiB
Newer Older
# Test Plan for CAPIF Api Events Service
At this documentation you will have all information and related files and examples of test plan for this API.

## Test Case 1: Creates a new individual CAPIF Event Subscription.

**Test ID**: ***capif_api_events-1***

**Description**:

  This test case will check that a CAPIF subscriber (Invoker or Publisher) can Subscribe to Events
**Pre-Conditions**:
  * CAPIF subscriber is pre-authorised (has valid InvokerId or apfId from CAPIF Authority)

**Execution Steps**:

  1. Register Invoker and Onboard Invoker at CCF
  2. Subscribe to Events
  3. Retrieve {subscriberId} and {subscriptionId} from Location Header

**Information of Test**:

  1. Perform [Invoker Onboarding]

  2. Event Subscription:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**
     2. body [event subscription request body]

**Expected Result**:

  1. Response to Onboard request must accomplish:
     1. **201 Created**
     2. Response Body must follow **APIInvokerEnrolmentDetails** data structure with:
        * apiInvokerId
        * onboardingInformation->apiInvokerCertificate must contain the public key signed.
     3. Response Header **Location** must be received with URI to new resource created, following this structure: **{apiRoot}/api-invoker-management/{apiVersion}/onboardedInvokers/{onboardingId}**

  2. Response to Event Subscription must accomplish:
     1. **201 Created**
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/capif-events/{apiVersion}/{subscriberId}/subscriptions/{subscriptionId}**
     3. Response Body must follow **EventSubscription** data structure.

  3. Event Subscriptions are stored in CAPIF Database

## Test Case 2: Creates a new individual CAPIF Event Subscription with Invalid SubscriberId

**Test ID**: ***capif_api_events-2***

**Description**:

  This test case will check that a CAPIF subscriber (Invoker or Publisher) cannot Subscribe to Events without valid SubcriberId

**Pre-Conditions**:
  * CAPIF subscriber is not pre-authorised (has invalid InvokerId or apfId)

**Execution Steps**:

  1. Register Invoker and Onboard Invoker at CCF
  2. Subscribe to Events

**Information of Test**:

  1. Perform [Invoker Onboarding]

  2. Event Subscription:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{SUBSCRIBER_NOT_REGISTERED}/subscriptions**
     2. body [event subscription request body]

**Expected Result**:

  1. Response to Onboard request must accomplish:
     1. **201 Created**
     2. Response Body must follow **APIInvokerEnrolmentDetails** data structure with:
        * apiInvokerId
        * onboardingInformation->apiInvokerCertificate must contain the public key signed.
     3. Response Header **Location** must be received with URI to new resource created, following this structure: **{apiRoot}/api-invoker-management/{apiVersion}/onboardedInvokers/{onboardingId}**

  2. Response to Event Subscription must accomplish:
     1. **404 Not Found**
     2. Error Response Body must accomplish with **ProblemDetails** data structure with:
        * status 404
        * title with message "Not Found"
        * detail with message "Invoker or APF or AEF or AMF Not found".
        * cause with message "Subscriber Not Found".

  3. Event Subscriptions are not stored in CAPIF Database

## Test Case 3: Deletes an individual CAPIF Event Subscription

**Test ID**: ***capif_api_events-3***

**Description**:

  This test case will check that a CAPIF subscriber (Invoker or Publisher) can Delete an Event Subscription

**Pre-Conditions**:
  * CAPIF subscriber is pre-authorised (has valid InvokerId or apfId from CAPIF Authority)

**Execution Steps**:

  1. Register Invoker and Onboard Invoker at CCF
  2. Subscribe to Events
  3. Retrieve {subscriberId} and {subscriptionId} from Location Header
  4. Remove Event Subscription

**Information of Test**:

  1. Perform [Invoker Onboarding]

  2. Event Subscription:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**
     2. body [event subscription request body]

  3. Remove Event Subscription:
     1. Send **DELETE** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**

**Expected Result**:

  1. Response to Onboard request must accomplish:
     1. **201 Created**
     2. Response Body must follow **APIInvokerEnrolmentDetails** data structure with:
        * apiInvokerId
        * onboardingInformation->apiInvokerCertificate must contain the public key signed.
     3. Response Header **Location** must be received with URI to new resource created, following this structure: **{apiRoot}/api-invoker-management/{apiVersion}/onboardedInvokers/{onboardingId}**

  2. Response to Event Subscription must accomplish:
     1. **201 Created**
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/capif-events/{apiVersion}/{subscriberId}/subscriptions/{subscriptionId}**
     3. Response Body must follow **EventSubscription** data structure.

  3. Event Subscriptions are stored in CAPIF Database
  4. Remove Event Subscription:
     1. **204 No Content**

  5. Event Subscription is not present at CAPIF Database.

## Test Case 4: Deletes an individual CAPIF Event Subscription with invalid SubscriberId

**Test ID**: ***capif_api_events-4***

**Description**:

  This test case will check that a CAPIF subscriber (Invoker or Publisher) cannot Delete to Events without valid SubcriberId

**Pre-Conditions**:
  * CAPIF subscriber is pre-authorised (has valid InvokerId or apfId).
  * CAPIF subscriber is subscribed to Events.

**Execution Steps**:

  1. Register Invoker and Onboard Invoker at CCF
  2. Subscribe to Events
  3. Retrieve Location Header with subscriptionId.
  4. Remove Event Subscribed with not valid Subscriber.

**Information of Test**:

  1. Perform [Invoker Onboarding]

  2. Event Subscription:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**
     2. body [event subscription request body]

  3. Remove Event Subcription with not valid subscriber:
     1. Send **DELETE** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{SUBSCRIBER_ID_NOT_VALID}/subscriptions/{subcriptionId}**

**Expected Result**:

  1. Response to Onboard request must accomplish:
     1. **201 Created**
     2. Response Body must follow **APIInvokerEnrolmentDetails** data structure with:
        * apiInvokerId
        * onboardingInformation->apiInvokerCertificate must contain the public key signed.
     3. Response Header **Location** must be received with URI to new resource created, following this structure: **{apiRoot}/api-invoker-management/{apiVersion}/onboardedInvokers/{onboardingId}**

  2. Response to Event Subscription must accomplish:
     1. 201 Created
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/capif-events/{apiVersion}/{subscriberId}/subscriptions/{subscriptionId}**
     3. Response Body must follow **EventSubscription** data structure.

  3. Event Subscriptions are stored in CAPIF Database
  4. Error Response Body must accomplish with **ProblemDetails** data structure with:

     * status 404
     * title with message "Not Found"
     * detail with message "Invoker or APF or AEF or AMF Not found".
     * cause with message "Subscriber Not Found".
## Test Case 5: Deletes an individual CAPIF Event Subscription with invalid SubscriptionId

**Test ID**: ***capif_api_events-5***

**Description**:

  This test case will check that a CAPIF subscriber (Invoker or Publisher) cannot Delete an Event Subscription without valid SubscriptionId

**Pre-Conditions**:
  * CAPIF subscriber is pre-authorised (has invalid InvokerId or apfId).
  * CAPIF subscriber is subscribed to Events.

**Execution Steps**:

  1. Register Invoker and Onboard Invoker at CCF
  2. Subscribe to Events
  3. Retrieve Location Header with subscriptionId.
  4. Remove Event Subscribed with not valid Subscriber.

**Information of Test**:

  1. Perform [Invoker Onboarding]

  2. Event Subscription:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**
     2. body [event subscription request body]

  3. Remove Event Subcription with not valid subscriber:
     1. Send **DELETE** to to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subcriberId}/subscriptions/{SUBSCRIPTION_ID_NOT_VALID}**

**Expected Result**:

  1. Response to Onboard request must accomplish:
     1. **201 Created**
     2. Response Body must follow **APIInvokerEnrolmentDetails** data structure with:
        * apiInvokerId
        * onboardingInformation->apiInvokerCertificate must contain the public key signed.
     3. Response Header **Location** must be received with URI to new resource created, following this structure: **{apiRoot}/api-invoker-management/{apiVersion}/onboardedInvokers/{onboardingId}**

  2. Response to Event Subscription must accomplish:
     1. **201 Created**
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/capif-events/{apiVersion}/{subscriberId}/subscriptions/{subscriptionId}**
     3. Response Body must follow **EventSubscription** data structure.

  3. Event Subscriptions are stored in CAPIF Database
  4. Remove Event Subscription with not valid subscriber:
     1. **404 Not Found**
     2. Error Response Body must accomplish with **ProblemDetails** data structure with:
        * status 404
        * detail with message "Service API not existing".
        * cause with message "Event API subscription id not found".

## Test Case 6: Invoker receives Service API Invocation events

Jorge Moratinos's avatar
Jorge Moratinos committed
**Test ID**: ***capif_api_events-6***, ***mockserver***
  This test case will check that a CAPIF Invoker subscribed to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION_FAILURE, receive the notification when AEF Send **TO** logging service result of invocations to their APIs.
  Enhanced Event Report feature must be active.
  * CAPIF subscriber is pre-authorised (has valid InvokerId or apfId from CAPIF Authority)
  * CAPIF provider is correctly registered and published APIs.
  * API Provider had a Service API Published on CAPIF
  * **Mock Server is up and running to receive requests.**
  * **Mock Server is clean.**
**Execution Steps**:

  1. Register provider and publish one API at CCF
  2. Register Invoker and Onboard Invoker at CCF
  3. Discover published APIs and extract apiIds and apiNames
  4. Subscribe to **SERVICE_API_INVOCATION_SUCCESS** and **SERVICE_API_INVOCATION_FAILURE** event filtering by aefId. Enhanced_event_report active at supported features.
  5. Retrieve {subscriberId} and {subscriptionId} from Location Header
  6. Emulate Success and Failure on API invocation of provider by Invoker, using Invocation Logs API.

**Information of Test**:

  1. Perform [provider registration]
  2. Publish Service API at CCF:

     * Send **POST** to ccf_publish_url **https://{CAPIF_HOSTNAME}/published-apis/v1/{apfId}/service-apis**
     * body [service api description] with apiName **service_1**

  3. Perform [invoker onboarding]
  4. Discover published APIs:

     * Get **Api Ids** And **Api Names** from response.

  5. Event Subscription to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION_FAILURE of provider previously registered:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**
     2. body [event subscription request body] with:
        1. events: **['SERVICE_API_INVOCATION_SUCCESS','SERVICE_API_INVOCATION_FAILURE']**
        2. eventFilter: only receive events from provider's aefId.
        3. supportedFeatures: binary 0100 -> string **4**
  6. Create Log Entry emulating provider receive Success and Failure api invocation from invoker:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/api-invocation-logs/v1/{aefId}/logs**
     2. body [log entry request body] with:
        1. aefId from provider published.
        2. apiInvokerId from invoker onboarded.
        3. apiId of published API
        4. apiName of published API
        5. 200 and 400 results in two logs.

**Expected Result**:

  1. Response to Event Subscription must accomplish:
     1. **201 Created**
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/capif-events/{apiVersion}/{subscriberId}/subscriptions/{subscriptionId}**
     3. Response Body must follow **EventSubscription** data structure.
  2. Response to creation of log entry on CCF must accomplish:
     1. **201 Created**
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/api-invocation-logs/{apiVersion}/{aefId}/subscriptions/{logId}**
  3. Mock Server received messages must accomplish:
     1. **Two Events have been received**.
     2. Validate received events follow **EventNotification** data structure, with **invocationLog** in **eventDetail** parameter.
        1. One should be **SERVICE_API_INVOCATION_SUCCESS** related with **200** result at Log.
        2. The other one must be **SERVICE_API_INVOCATION_FAILURE** related with **400** result at Log.

---
## Test Case 7: Invoker subscribe to Service API Available and Unavailable events
Jorge Moratinos's avatar
Jorge Moratinos committed
**Test ID**: ***capif_api_events-7***, ***mockserver***
  This test case will check that a CAPIF Invoker subscribed to SERVICE_API_AVAILABLE and SERVICE_API_UNAVAILABLE, receive the notification when AEF publish and remove it.
  Enhanced Event Report feature must be active.
  * CAPIF subscriber is pre-authorised (has valid InvokerId or apfId from CAPIF Authority)
  * CAPIF provider is correctly registered and published APIs.
  * **Mock Server is up and running to receive requests.**
  * **Mock Server is clean.**

**Execution Steps**:
  1. Register provider and publish one API at CCF
  2. Register Invoker and Onboard Invoker at CCF
  3. Discover published APIs and extract apiIds and apiNames
  4. Subscribe to **SERVICE_API_AVAILABLE** and **SERVICE_API_UNAVAILABLE** event filtering by aefId. Enhanced_event_report active at supported features.
  5. Retrieve {subscriberId} and {subscriptionId} from Location Header
  6. Provider publish new API.
  7. Provider remove published API.

**Information of Test**:

  1. Perform [provider registration]
  2. Publish Service API at CCF:

     * Send **POST** to ccf_publish_url **https://{CAPIF_HOSTNAME}/published-apis/v1/{apfId}/service-apis**
     * body [service api description] with apiName **service_1**
     * Store **serviceApiId**
     * Use **APF Certificate**

  3. Perform [invoker onboarding]
  4. Discover published APIs:

     * Get **Api Ids** And **Api Names** from response.

  5. Event Subscription to SERVICE_API_AVAILABLE and SERVICE_API_UNAVAILABLE of provider previously registered:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**
     2. body [event subscription request body] with:
        1. events: **['SERVICE_API_AVAILABLE','SERVICE_API_UNAVAILABLE']**
        2. eventFilter: only receive events from provider's aefId.
        3. supportedFeatures: binary 0100 -> string **4**
     3. Use **Invoker Certificate**

  6. Publish new Service API at CCF:

     * Send **POST** to ccf_publish_url **https://{CAPIF_HOSTNAME}/published-apis/v1/{apfId}/service-apis**
     * body [service api description] with apiName **service_2**
     * Store **serviceApiId**
     * Use **APF Certificate**

  7. Remove published Service API at CCF:
     * Send **DELETE** to resource URL **https://{CAPIF_HOSTNAME}/published-apis/v1/{apfId}/service-apis/{SERVICE_API_ID}**
**Expected Result**:

  1. Response to Event Subscription must accomplish:
     1. **201 Created**
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/capif-events/{apiVersion}/{subscriberId}/subscriptions/{subscriptionId}**
     3. Response Body must follow **EventSubscription** data structure.

  2. Mock Server received messages must accomplish:
     1. **Two Events have been received**.
     2. Validate received events follow **EventNotification** data structure, with **apiIds** in **eventDetail** parameter.
        1. One should be **SERVICE_API_AVAILABLE** apiId of **service_2** published API.
        2. The other one must be **SERVICE_API_UNAVAILABLE** apiId of **service_1** published API.

---
## Test Case 8: Invoker subscribe to Service API Update

Jorge Moratinos's avatar
Jorge Moratinos committed
**Test ID**: ***capif_api_events-8***, ***mockserver***

**Description**:

  This test case will check that a CAPIF Invoker subscribed to SERVICE_API_UPDATE, receive the notification when AEF Update some information on API Published.
  Enhanced Event Report feature must be active.
  * CAPIF subscriber is pre-authorised (has valid InvokerId or apfId from CAPIF Authority)
  * CAPIF provider is correctly registered and published APIs.
  * API Provider had a Service API Published on CAPIF
  * **Mock Server is up and running to receive requests.**
  * **Mock Server is clean.**

**Execution Steps**:
  1. Register Provider and publish one API at CCF
  2. Register Invoker and Onboard Invoker at CCF
  3. Discover published APIs and extract apiIds and apiNames
  4. Subscribe to **SERVICE_API_UPDATE** event filtering by aefId. Enhanced_event_report active at supported features.
  5. Retrieve {subscriberId} and {subscriptionId} from Location Header at event subscription
  6. Provider update information of Service API Published.

**Information of Test**:
  1. Check and Clean Mock Server
  2. Perform [provider registration]
  3. Publish Service API at CCF:
     * Send **POST** to ccf_publish_url **https://{CAPIF_HOSTNAME}/published-apis/v1/{apfId}/service-apis**
     * body [service api description] with apiName **service_1**
     * Use ***APF Certificate***
     * Store **serviceApiId**

  4. Perform [invoker onboarding]
  5. Discover published APIs:

     * Get **Api Ids** And **Api Names** from response.

  6. Event Subscription to SERVICE_API_UPDATE of provider previously registered:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**
     2. body [event subscription request body] with:
        1. events: **['SERVICE_API_UPDATE']**
        2. eventFilter: only receive events from provider's aefId.
        3. supportedFeatures: binary 0100 -> string **4**
     3. Use **Invoker Certificate**

  7. Update published API at CCF:
     * Send **PUT** to resource URL **https://{CAPIF_HOSTNAME}/published-apis/v1/{apfId}/service-apis/{serivceApiId}**
     * body [service api description] with overrided **apiName** to **service_1**_modified**
     * Use **APF Certificate**

**Expected Result**:

  1. Response to Event Subscription must accomplish:
     1. **201 Created**
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/capif-events/{apiVersion}/{subscriberId}/subscriptions/{subscriptionId}**
     3. Response Body must follow **EventSubscription** data structure.
  2. Response to Update Published Service API:
     1. **200 OK**
     2. Response Body must follow **ServiceAPIDescription** data structure with:
  3. Mock Server received messages must accomplish:
     1. **One Event has been received**.
     2. Validate received events follow **EventNotification** data structure, with **serviceAPIDescriptions** in **eventDetail** parameter.
        1. Event should be **SERVICE_API_UPDATE** with **eventDetail** with modified **apiName**.

---
## Test Case 9: Provider subscribe to API Invoker events

Jorge Moratinos's avatar
Jorge Moratinos committed
**Test ID**: ***capif_api_events-9***, ***mockserver***

**Description**:

  This test case will check that a CAPIF Provider subscribed to API Invoker events (API_INVOKER_ONBOARDED, API_INVOKER_UPDATED and API_INVOKER_OFFBOARDED), receive the notifications when Invoker is onboarded, updated and removed respectively.
  Enhanced Event Report feature must be active.
  * CAPIF subscriber is pre-authorised (has valid InvokerId or apfId from CAPIF Authority)
  * CAPIF provider is correctly registered.
  * **Mock Server is up and running to receive requests.**
  * **Mock Server is clean.**

**Execution Steps**:
  2. Subscribe Provider to **API_INVOKER_ONBOARDED, API_INVOKER_UPDATED and API_INVOKER_OFFBOARDED** events. Enhanced_event_report active at supported features.
  3. Register Invoker and Onboard Invoker at CCF
  4. Update Onboarding Information at CCF with a minor change on "notificationDestination"
  5. Offboard Invoker

**Information of Test**:

  1. Check and Clean Mock Server
  2. Perform [provider registration]
  3. Event Subscription to API_INVOKER_ONBOARDED, API_INVOKER_UPDATED and API_INVOKER_OFFBOARDED events:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**
     2. body [event subscription request body] with:
        1. events: **['API_INVOKER_ONBOARDED', 'API_INVOKER_UPDATED', 'API_INVOKER_OFFBOARDED']**
        2. supportedFeatures: binary 0100 -> string **4**
     3. Use **Provider AMF Certificate**
  4. Perform [invoker onboarding]
  5. Update information of previously onboarded Invoker:
     * Send **PUT** to **https://{CAPIF_HOSTNAME}/api-invoker-management/v1/onboardedInvokers/{onboardingId}**
     * Reference Request Body is: [put invoker onboarding body]
       * "notificationDestination": "**http://host.docker.internal:8086/netapp_new_callback**",
  6. Offboard:
     * Send **DELETE** to **https://{CAPIF_HOSTNAME}/api-invoker-management/v1/onboardedInvokers/{onboardingId}**

**Expected Result**:

  1. Response to Event Subscription must accomplish:
     1. **201 Created**
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/capif-events/{apiVersion}/{subscriberId}/subscriptions/{subscriptionId}**
     3. Response Body must follow **EventSubscription** data structure.
  2. Response to Onboard request must accomplish:
     1. **201 Created**
     2. Response Body must follow **APIInvokerEnrolmentDetails** data structure with:
        * apiInvokerId
        * onboardingInformation->apiInvokerCertificate must contain the public key signed.
     3. Response Header **Location** must be received with URI to new resource created, following this structure: **{apiRoot}/api-invoker-management/{apiVersion}/onboardedInvokers/{onboardingId}**
  3. Response to Update Request (PUT) with minor change must contain:
     1. **200 OK** response.
     2. notificationDestination on response must contain the new value
  4. Response to Offboard Request (DELETE) must contain:
     1. **204 No Content**
  5. Mock Server received messages must accomplish:
     1. **Three Events have been received**.
     2. Validate received events follow **EventNotification** data structure, with **apiInvokerIds** in **eventDetail** parameter.
        1. One Event should be **API_INVOKER_ONBOARDED** with **eventDetail** with modified **apiInvokerId**.
        2. One Event should be **API_INVOKER_UPDATED** with **eventDetail** with modified **apiInvokerId**.
        3. One Event should be **API_INVOKER_OFFBOARDED** with **eventDetail** with modified **apiInvokerId**.
---
## Test Case 10: Provider subscribed to ACL update event
Jorge Moratinos's avatar
Jorge Moratinos committed
**Test ID**: ***capif_api_events-10***, ***mockserver***
  This test case will check that a CAPIF Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE receive a notification when ACL Changes.
  Enhanced Event Report feature must be active.

**Pre-Conditions**:
  * CAPIF subscriber is pre-authorised (has valid InvokerId or apfId from CAPIF Authority)
  * CAPIF provider is correctly registered.
  * API Provider had one Service API Published on CAPIF
  * API Invoker had a Security Context for the Service API published by provider.
  * **Mock Server is up and running to receive requests.**
  * **Mock Server is clean.**

**Execution Steps**:
  1. Register Provider at CCF.
  2. Publish a provider API with name **service_1**.
  3. Register Invoker and Onboard Invoker at CCF.
  4. Subscribe Provider to **ACCESS_CONTROL_POLICY_UPDATE** event. Enhanced_event_report active at supported features.
  5. Discover APIs filtered by **aef_id**
  6. Create Security Context for Invoker.
  7. Provider Retrieve ACL

**Information of Test**:

  1. Check and Clean Mock Server
  2. Perform [provider registration]
  3. Perform [invoker onboarding]
  4. Event Subscription to **ACCESS_CONTROL_POLICY_UPDATE** event:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**
     2. body [event subscription request body] with:
        1. events: **['ACCESS_CONTROL_POLICY_UPDATE']**
        2. eventFilters: apiInvokerIds array with apiInvokerId of invoker
        3. supportedFeatures: binary 0100 -> string **4**
     3. Use **Provider AMF Certificate**
  5. Discover published APIs
  6. Create Security Context for Invoker
     * Send **PUT** **https://{CAPIF_HOSTNAME}/trustedInvokers/{apiInvokerId}**
     * body [service security body]
  7. Provider Retrieve ACL
     * Send **GET** **https://{CAPIF_HOSTNAME}/access-control-policy/v1/accessControlPolicyList/${serviceApiId}?aef-id=${aef_id}**
     * Use **serviceApiId** and **aefId**
     * Use AEF Provider Certificate

**Expected Result**:

  1. Response to Event Subscription must accomplish:
     1. **201 Created**
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/capif-events/{apiVersion}/{subscriberId}/subscriptions/{subscriptionId}**
     3. Response Body must follow **EventSubscription** data structure.
  2. Create security context:
     1. **201 Created** response.
     2. body returned must accomplish **ServiceSecurity** data structure.
     3. Location Header must contain the new resource URL **{apiRoot}/capif-security/v1/trustedInvokers/{apiInvokerId}**
  3. ACL Response:
     1. **200 OK** Response.
     2. body returned must accomplish **AccessControlPolicyList** data structure.
     3. apiInvokerPolicies must:
        1. contain only one object.
        2. apiInvokerId must match apiInvokerId registered previously.
  4. Mock Server received messages must accomplish:
     1. **One Event has been received**.
     2. Validate received event follow **EventNotification** data structure, with **accCtrlPolListExt** in **eventDetail** parameter.
        1. One Event should be **ACCESS_CONTROL_POLICY_UPDATE** with **eventDetail** with **accCtrlPolListExt** including the **apiId** and **apiInvokerPolicies**.
## Test Case 11: Provider receives an ACL unavailable event when invoker remove Security Context.
Jorge Moratinos's avatar
Jorge Moratinos committed
**Test ID**: ***capif_api_events-11***, ***mockserver***
  This test case will check that a CAPIF Invoker subscribed to ACCESS_CONTROL_POLICY_UNAVAILABLE will receive the notification when AEF remove Security Context created previously.
  Enhanced Event Report feature must be active.

**Pre-Conditions**:

  * CAPIF subscriber is pre-authorised (has valid InvokerId or apfId from CAPIF Authority)
  * CAPIF provider is correctly registered.
  * API Provider had one Service API Published on CAPIF
  * **Mock Server is up and running to receive requests.**
  * **Mock Server is clean.**

**Execution Steps**:

  1. Register Provider at CCF.
  2. Publish a provider API with name **service_1**.
  3. Register Invoker and Onboard Invoker at CCF.
  4. Subscribe Invoker to **ACCESS_CONTROL_POLICY_UNAVAILABLE** event. Enhanced_event_report active at supported features.
  5. Discover APIs filtered by **aef_id**
  6. Create Security Context for Invoker.
  7. Provider Retrieve ACL.
  8. Remove Security Context for Invoker.

**Information of Test**:

  1. Check and Clean Mock Server
  2. Perform [provider registration]
  3. Perform [invoker onboarding]
  4. Event Subscription to **ACCESS_CONTROL_POLICY_UNAVAILABLE** event:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**
     2. body [event subscription request body] with:
        1. events: **['ACCESS_CONTROL_POLICY_UNAVAILABLE']**
        2. eventFilters: apiInvokerIds array with apiInvokerId of invoker
        3. supportedFeatures: binary 0100 -> string **4**
     3. Use **Invoker Certificate**
  5. Discover published APIs
  6. Create Security Context for Invoker
     * Send **PUT** **https://{CAPIF_HOSTNAME}/trustedInvokers/{apiInvokerId}**
     * body [service security body]
  7. Provider Retrieve ACL
     * Send **GET** **https://{CAPIF_HOSTNAME}/access-control-policy/v1/accessControlPolicyList/${serviceApiId}?aef-id=${aef_id}**
     * Use **serviceApiId** and **aefId**
     * Use **AEF Provider Certificate**
  8. Delete Security Context of Invoker by Provider:
     * Send **DELETE** **https://{CAPIF_HOSTNAME}/trustedInvokers/{apiInvokerId}**

**Expected Result**:
  1. Response to Event Subscription must accomplish:
     1. **201 Created**
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/capif-events/{apiVersion}/{subscriberId}/subscriptions/{subscriptionId}**
     3. Response Body must follow **EventSubscription** data structure.
  2. Create security context:
     1. **201 Created** response.
     2. body returned must accomplish **ServiceSecurity** data structure.
     3. Location Header must contain the new resource URL **{apiRoot}/capif-security/v1/trustedInvokers/{apiInvokerId}**
  3. ACL Response:
     1. **200 OK** Response.
     2. body returned must accomplish **AccessControlPolicyList** data structure.
     3. apiInvokerPolicies must:
        1. contain only one object.
        2. apiInvokerId must match apiInvokerId registered previously.
  4. Delete security context:
     1. **204 No Content** response.
  5. Mock Server received messages must accomplish:
     1. **One Event has been received**.
     2. Validate received event follow **EventNotification** data structure, without **eventDetail** parameter.
        1. One Event should be **ACCESS_CONTROL_POLICY_UNAVAILABLE** without **eventDetail**.
## Test Case 12: Invoker receives an Invoker Authorization Revoked and ACL unavailable event when Provider revoke Invoker Authorization.
Jorge Moratinos's avatar
Jorge Moratinos committed
**Test ID**: ***capif_api_events-12***, ***mockserver***
  This test case will check that a CAPIF Invoker subscribed to API_INVOKER_AUTHORIZATION_REVOKED and ACCESS_CONTROL_POLICY_UNAVAILABLE receive both notification when AEF revoke invoker's authorization.
  Enhanced Event Report feature must be active.
**Pre-Conditions**:

  * CAPIF subscriber is pre-authorised (has valid InvokerId or apfId from CAPIF Authority)
  * CAPIF provider is correctly registered.
  * API Provider had one Service API Published on CAPIF
  * **Mock Server is up and running to receive requests.**
  * **Mock Server is clean.**

**Execution Steps**:
  1. Register Provider at CCF.
  2. Publish a provider API with name **service_1**.
  3. Register Invoker and Onboard Invoker at CCF.
  4. Subscribe Invoker to **ACCESS_CONTROL_POLICY_UNAVAILABLE and API_INVOKER_AUTHORIZATION_REVOKED** events.  Enhanced_event_report active at supported features.
  5. Discover APIs filtered by **aef_id**
  6. Create Security Context for Invoker.
  7. Revoke Authorization by Provider.
**Information of Test**:
  1. Check and Clean Mock Server
  2. Perform [provider registration]
  3. Perform [invoker onboarding]
  4. Event Subscription to **ACCESS_CONTROL_POLICY_UNAVAILABLE and API_INVOKER_AUTHORIZATION_REVOKED** event:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**
     2. body [event subscription request body] with:
        1. events: **['ACCESS_CONTROL_POLICY_UNAVAILABLE','API_INVOKER_AUTHORIZATION_REVOKED']**
        2. eventFilters: apiInvokerIds array with apiInvokerId of invoker
        3. supportedFeatures: binary 0100 -> string **4**
     3. Use **Invoker Certificate**
  5. Discover published APIs
  6. Create Security Context for Invoker
     * Send **PUT** **https://{CAPIF_HOSTNAME}/trustedInvokers/{apiInvokerId}**
     * body [service security body]
  7. Revoke Authorization by Provider:
     * Send **POST** **https://{CAPIF_HOSTNAME}/trustedInvokers/{apiInvokerId}/delete**
     * body [security notification body]

**Expected Result**:
  1. Response to Event Subscription must accomplish:
     1. **201 Created**
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/capif-events/{apiVersion}/{subscriberId}/subscriptions/{subscriptionId}**
     3. Response Body must follow **EventSubscription** data structure.
  2. Create security context:
     1. **201 Created** response.
     2. body returned must accomplish **ServiceSecurity** data structure.
     3. Location Header must contain the new resource URL **{apiRoot}/capif-security/v1/trustedInvokers/{apiInvokerId}**
  4. Revoke Authorization:
     1. **204 No Content** response.
  5. Mock Server received messages must accomplish:
     1. **Two Events has been received**.
     2. Validate received event follow **EventNotification** data structure, without **eventDetail** parameter.
        1. One Event should be **ACCESS_CONTROL_POLICY_UNAVAILABLE** without **eventDetail**.
        2. One Event should be **API_INVOKER_AUTHORIZATION_REVOKED** without **eventDetail**.

---
## Test Case 13: Creates a new individual CAPIF Event Subscription without supported features attribute.

**Test ID**: ***capif_api_events-13***

**Description**:

  This test case will check error when CAPIF subscriber (Invoker or Publisher) Subscribe to Events without supported features attribute.

**Pre-Conditions**:

  * CAPIF subscriber is pre-authorised (has valid InvokerId or apfId from CAPIF Authority)

**Execution Steps**:

  1. Register Invoker and Onboard Invoker at CCF
  2. Subscribe to Events without supported features
  3. Retrieve {subscriberId} and {subscriptionId} from Location Header

**Information of Test**:

  1. Perform [Invoker Onboarding]

  2. Event Subscription:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**
     2. body [event subscription request body]
        1. supportedFeatures NOT PRESENT.
     3. Use **Invoker Certificate**

**Expected Result**:

  1. Response to Onboard request must accomplish:
     1. **201 Created**
     2. Response Body must follow **APIInvokerEnrolmentDetails** data structure with:
        * apiInvokerId
        * onboardingInformation->apiInvokerCertificate must contain the public key signed.
     3. Response Header **Location** must be received with URI to new resource created, following this structure: **{apiRoot}/api-invoker-management/{apiVersion}/onboardedInvokers/{onboardingId}**

  1. Response to Event Subscription must accomplish:
     1. **400 Bad Request**
     2. Error Response Body must accomplish with **ProblemDetails** data structure with:
        * status 400
        * title with message "Bad Request"
        * detail with message "supportedFeatures not present in request".
        * cause with message "supportedFeatures not present".

810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313
## Test Case 14: Invoker receives Service API Invocation events without Enhanced Event Report

**Test ID**: ***capif_api_events-14***, ***mockserver***

**Description**:

  This test case will check that a CAPIF Invoker subscribed to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION_FAILURE, receive the notification when AEF Send **TO** logging service result of invocations to their APIs.
  Enhanced Event Report feature must be inactive.

**Pre-Conditions**:

  * CAPIF subscriber is pre-authorised (has valid InvokerId or apfId from CAPIF Authority)
  * CAPIF provider is correctly registered and published APIs.
  * API Provider had a Service API Published on CAPIF
  * **Mock Server is up and running to receive requests.**
  * **Mock Server is clean.**

**Execution Steps**:

  1. Register provider and publish one API at CCF
  2. Register Invoker and Onboard Invoker at CCF
  3. Discover published APIs and extract apiIds and apiNames
  4. Subscribe to **SERVICE_API_INVOCATION_SUCCESS** and **SERVICE_API_INVOCATION_FAILURE** event filtering by aefId. Enhanced_event_report inactive at supported features.
  5. Retrieve {subscriberId} and {subscriptionId} from Location Header
  6. Emulate Success and Failure on API invocation of provider by Invoker, using Invocation Logs API.

**Information of Test**:

  1. Perform [provider registration]
  2. Publish Service API at CCF:

     * Send **POST** to ccf_publish_url **https://{CAPIF_HOSTNAME}/published-apis/v1/{apfId}/service-apis**
     * body [service api description] with apiName **service_1**
     * Store **serviceApiId**
     * Use **APF Certificate**

  3. Perform [invoker onboarding]
  4. Discover published APIs:

     * Get **Api Ids** And **Api Names** from response.

  5. Event Subscription to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION_FAILURE of provider previously registered:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**
     2. body [event subscription request body] with:
        1. events: **['SERVICE_API_INVOCATION_SUCCESS','SERVICE_API_INVOCATION_FAILURE']**
        2. eventFilter: only receive events from provider's aefId.
        3. supportedFeatures: binary 0000 -> string **0**
     3. Use **Invoker Certificate**

  6. Create Log Entry emulating provider receive Success and Failure api invocation from invoker:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/api-invocation-logs/v1/{aefId}/logs**
     2. body [log entry request body] with:
        1. aefId from provider published.
        2. apiInvokerId from invoker onboarded.
        3. apiId of published API
        4. apiName of published API
        5. 200 and 400 results in two logs.
     3. Use **AEF Certificate**

**Expected Result**:

  1. Response to Event Subscription must accomplish:
     1. **201 Created**
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/capif-events/{apiVersion}/{subscriberId}/subscriptions/{subscriptionId}**
     3. Response Body must follow **EventSubscription** data structure.
  2. Response to creation of log entry on CCF must accomplish:
     1. **201 Created**
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/api-invocation-logs/{apiVersion}/{aefId}/subscriptions/{logId}**
  3. Mock Server received messages must accomplish:
     1. **Two Events have been received**.
     2. Validate received events follow **EventNotification** data structure, without **eventDetail** parameter.
        1. One should be **SERVICE_API_INVOCATION_SUCCESS** related with **200** result at Log.
        2. The other one must be **SERVICE_API_INVOCATION_FAILURE** related with **400** result at Log.

---
## Test Case 15: Invoker subscribe to Service API Available and Unavailable events without Enhanced Event Report

**Test ID**: ***capif_api_events-15***, ***mockserver***

**Description**:

  This test case will check that a CAPIF Invoker subscribed to SERVICE_API_AVAILABLE and SERVICE_API_UNAVAILABLE, receive the notification when AEF publish and remove it.
  Enhanced Event Report feature must be inactive.

**Pre-Conditions**:

  * CAPIF subscriber is pre-authorised (has valid InvokerId or apfId from CAPIF Authority)
  * CAPIF provider is correctly registered and published APIs.
  * **Mock Server is up and running to receive requests.**
  * **Mock Server is clean.**

**Execution Steps**:

  1. Register provider and publish one API at CCF
  2. Register Invoker and Onboard Invoker at CCF
  3. Discover published APIs and extract apiIds and apiNames
  4. Subscribe to **SERVICE_API_AVAILABLE** and **SERVICE_API_UNAVAILABLE** event filtering by aefId. Enhanced_event_report inactive at supported features.
  5. Retrieve {subscriberId} and {subscriptionId} from Location Header
  6. Provider publish new API.
  7. Provider remove published API.

**Information of Test**:

  1. Perform [provider registration]
  2. Publish Service API at CCF:

     * Send **POST** to ccf_publish_url **https://{CAPIF_HOSTNAME}/published-apis/v1/{apfId}/service-apis**
     * body [service api description] with apiName **service_1**
     * Store **serviceApiId**
     * Use **APF Certificate**

  3. Perform [invoker onboarding]
  4. Discover published APIs:

     * Get **Api Ids** And **Api Names** from response.

  5. Event Subscription to SERVICE_API_AVAILABLE and SERVICE_API_UNAVAILABLE of provider previously registered:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**
     2. body [event subscription request body] with:
        1. events: **['SERVICE_API_AVAILABLE','SERVICE_API_UNAVAILABLE']**
        2. eventFilter: only receive events from provider's aefId.
        3. supportedFeatures: binary 0000 -> string **0**
     3. Use **Invoker Certificate**

  6. Publish new Service API at CCF:

     * Send **POST** to ccf_publish_url **https://{CAPIF_HOSTNAME}/published-apis/v1/{apfId}/service-apis**
     * body [service api description] with apiName **service_2**
     * Store **serviceApiId**
     * Use **APF Certificate**

  7. Remove published Service API at CCF:
     * Send **DELETE** to resource URL **https://{CAPIF_HOSTNAME}/published-apis/v1/{apfId}/service-apis/{SERVICE_API_ID}**
     * Use **APF Certificate**


**Expected Result**:

  1. Response to Event Subscription must accomplish:
     1. **201 Created**
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/capif-events/{apiVersion}/{subscriberId}/subscriptions/{subscriptionId}**
     3. Response Body must follow **EventSubscription** data structure.

  2. Mock Server received messages must accomplish:
     1. **Two Events have been received**.
     2. Validate received events follow **EventNotification** data structure, without **eventDetail** parameter.
        1. One should be **SERVICE_API_AVAILABLE** apiId of **service_2** published API.
        2. The other one must be **SERVICE_API_UNAVAILABLE** apiId of **service_1** published API.

---
## Test Case 16: Invoker subscribe to Service API Update without Enhanced Event Report

**Test ID**: ***capif_api_events-16***, ***mockserver***

**Description**:

  This test case will check that a CAPIF Invoker subscribed to SERVICE_API_UPDATE, receive the notification when AEF Update some information on API Published.
  Enhanced Event Report feature must be inactive.

**Pre-Conditions**:

  * CAPIF subscriber is pre-authorised (has valid InvokerId or apfId from CAPIF Authority)
  * CAPIF provider is correctly registered and published APIs.
  * API Provider had a Service API Published on CAPIF
  * **Mock Server is up and running to receive requests.**
  * **Mock Server is clean.**

**Execution Steps**:

  1. Register Provider and publish one API at CCF
  2. Register Invoker and Onboard Invoker at CCF
  3. Discover published APIs and extract apiIds and apiNames
  4. Subscribe to **SERVICE_API_UPDATE** event filtering by aefId. Enhanced_event_report inactive at supported features.
  5. Retrieve {subscriberId} and {subscriptionId} from Location Header at event subscription
  6. Provider update information of Service API Published.

**Information of Test**:

  1. Check and Clean Mock Server
  2. Perform [provider registration]
  3. Publish Service API at CCF:

     * Send **POST** to ccf_publish_url **https://{CAPIF_HOSTNAME}/published-apis/v1/{apfId}/service-apis**
     * body [service api description] with apiName **service_1**
     * Use ***APF Certificate***
     * Store **serviceApiId**

  4. Perform [invoker onboarding]
  5. Discover published APIs:

     * Get **Api Ids** And **Api Names** from response.

  6. Event Subscription to SERVICE_API_UPDATE of provider previously registered:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**
     2. body [event subscription request body] with:
        1. events: **['SERVICE_API_UPDATE']**
        2. eventFilter: only receive events from provider's aefId.
        3. supportedFeatures: binary 0000 -> string **0**
     3. Use **Invoker Certificate**

  7. Update published API at CCF:
     * Send **PUT** to resource URL **https://{CAPIF_HOSTNAME}/published-apis/v1/{apfId}/service-apis/{serivceApiId}**
     * body [service api description] with overrided **apiName** to **service_1**_modified**
     * Use **APF Certificate**

**Expected Result**:

  1. Response to Event Subscription must accomplish:
     1. **201 Created**
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/capif-events/{apiVersion}/{subscriberId}/subscriptions/{subscriptionId}**
     3. Response Body must follow **EventSubscription** data structure.
  2. Response to Update Published Service API:
     1. **200 OK**
     2. Response Body must follow **ServiceAPIDescription** data structure with:
        * apiName **service_1**_modified**
  3. Mock Server received messages must accomplish:
     1. **One Event has been received**.
     2. Validate received events follow **EventNotification** data structure, with **serviceAPIDescriptions** in **eventDetail** parameter.
        1. Event should be **SERVICE_API_UPDATE** with **eventDetail** with modified **apiName**.

---
## Test Case 17: Provider subscribe to API Invoker events without Enhanced Event Report

**Test ID**: ***capif_api_events-17***, ***mockserver***

**Description**:

  This test case will check that a CAPIF Provider subscribed to API Invoker events (API_INVOKER_ONBOARDED, API_INVOKER_UPDATED and API_INVOKER_OFFBOARDED), receive the notifications when Invoker is onboarded, updated and removed respectively.
  Enhanced Event Report feature must be inactive.

**Pre-Conditions**:

  * CAPIF subscriber is pre-authorised (has valid InvokerId or apfId from CAPIF Authority)
  * CAPIF provider is correctly registered.
  * **Mock Server is up and running to receive requests.**
  * **Mock Server is clean.**

**Execution Steps**:

  1. Register Provider at CCF
  2. Subscribe Provider to **API_INVOKER_ONBOARDED, API_INVOKER_UPDATED and API_INVOKER_OFFBOARDED** events. Enhanced_event_report inactive at supported features.
  3. Register Invoker and Onboard Invoker at CCF
  4. Update Onboarding Information at CCF with a minor change on "notificationDestination"
  5. Offboard Invoker

**Information of Test**:

  1. Check and Clean Mock Server
  2. Perform [provider registration]
  3. Event Subscription to API_INVOKER_ONBOARDED, API_INVOKER_UPDATED and API_INVOKER_OFFBOARDED events:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**
     2. body [event subscription request body] with:
        1. events: **['API_INVOKER_ONBOARDED', 'API_INVOKER_UPDATED', 'API_INVOKER_OFFBOARDED']**
        2. supportedFeatures: binary 0100 -> string **4**
     3. Use **Provider AMF Certificate**
  4. Perform [invoker onboarding]
  5. Update information of previously onboarded Invoker:
     * Send **PUT** to **https://{CAPIF_HOSTNAME}/api-invoker-management/v1/onboardedInvokers/{onboardingId}**
     * Reference Request Body is: [put invoker onboarding body]
       * "notificationDestination": "**http://host.docker.internal:8086/netapp_new_callback**",
  6. Offboard:
     * Send **DELETE** to **https://{CAPIF_HOSTNAME}/api-invoker-management/v1/onboardedInvokers/{onboardingId}**

**Expected Result**:

  1. Response to Event Subscription must accomplish:
     1. **201 Created**
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/capif-events/{apiVersion}/{subscriberId}/subscriptions/{subscriptionId}**
     3. Response Body must follow **EventSubscription** data structure.
  2. Response to Onboard request must accomplish:
     1. **201 Created**
     2. Response Body must follow **APIInvokerEnrolmentDetails** data structure with:
        * apiInvokerId
        * onboardingInformation->apiInvokerCertificate must contain the public key signed.
     3. Response Header **Location** must be received with URI to new resource created, following this structure: **{apiRoot}/api-invoker-management/{apiVersion}/onboardedInvokers/{onboardingId}**
  3. Response to Update Request (PUT) with minor change must contain:
     1. **200 OK** response.
     2. notificationDestination on response must contain the new value
  4. Response to Offboard Request (DELETE) must contain:
     1. **204 No Content**
  5. Mock Server received messages must accomplish:
     1. **Three Events have been received**.
     2. Validate received events follow **EventNotification** data structure, without **eventDetail** parameter.
        1. One Event should be **API_INVOKER_ONBOARDED**
        2. One Event should be **API_INVOKER_UPDATED**
        3. One Event should be **API_INVOKER_OFFBOARDED**
---
## Test Case 18: Provider subscribed to ACL update event without Enhanced Event Report

**Test ID**: ***capif_api_events-18***, ***mockserver***

**Description**:

  This test case will check that a CAPIF Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE receive a notification when ACL Changes.
  Enhanced Event Report feature must be inactive.

**Pre-Conditions**:

  * CAPIF subscriber is pre-authorised (has valid InvokerId or apfId from CAPIF Authority)
  * CAPIF provider is correctly registered.
  * API Provider had one Service API Published on CAPIF
  * API Invoker had a Security Context for the Service API published by provider.
  * **Mock Server is up and running to receive requests.**
  * **Mock Server is clean.**

**Execution Steps**:

  1. Register Provider at CCF.
  2. Publish a provider API with name **service_1**.
  3. Register Invoker and Onboard Invoker at CCF.
  4. Subscribe Provider to **ACCESS_CONTROL_POLICY_UPDATE** event. Enhanced_event_report inactive at supported features.
  5. Discover APIs filtered by **aef_id**
  6. Create Security Context for Invoker.
  7. Provider Retrieve ACL

**Information of Test**:

  1. Check and Clean Mock Server
  2. Perform [provider registration]
  3. Perform [invoker onboarding]
  4. Event Subscription to **ACCESS_CONTROL_POLICY_UPDATE** event:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**
     2. body [event subscription request body] with:
        1. events: **['ACCESS_CONTROL_POLICY_UPDATE']**
        2. eventFilters: apiInvokerIds array with apiInvokerId of invoker
        3. supportedFeatures: binary 0000 -> string **0**
     3. Use **Provider AMF Certificate**
  5. Discover published APIs
  6. Create Security Context for Invoker
     * Send **PUT** **https://{CAPIF_HOSTNAME}/trustedInvokers/{apiInvokerId}**
     * body [service security body]
     * Use **Invoker Certificate**
  7. Provider Retrieve ACL
     * Send **GET** **https://{CAPIF_HOSTNAME}/access-control-policy/v1/accessControlPolicyList/${serviceApiId}?aef-id=${aef_id}**
     * Use **serviceApiId** and **aefId**
     * Use AEF Provider Certificate

**Expected Result**:

  1. Response to Event Subscription must accomplish:
     1. **201 Created**
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/capif-events/{apiVersion}/{subscriberId}/subscriptions/{subscriptionId}**
     3. Response Body must follow **EventSubscription** data structure.
  2. Create security context:
     1. **201 Created** response.
     2. body returned must accomplish **ServiceSecurity** data structure.
     3. Location Header must contain the new resource URL **{apiRoot}/capif-security/v1/trustedInvokers/{apiInvokerId}**
  3. ACL Response:
     1. **200 OK** Response.
     2. body returned must accomplish **AccessControlPolicyList** data structure.
     3. apiInvokerPolicies must:
        1. contain only one object.
        2. apiInvokerId must match apiInvokerId registered previously.
  4. Mock Server received messages must accomplish:
     1. **One Event has been received**.
     2. Validate received event follow **EventNotification** data structure, without **eventDetail** parameter.
        1. One Event should be **ACCESS_CONTROL_POLICY_UPDATE**.

---
## Test Case 19: Provider receives an ACL unavailable event when invoker remove Security Context without Enhanced Event Report

**Test ID**: ***capif_api_events-19***, ***mockserver***

**Description**:

  This test case will check that a CAPIF Invoker subscribed to ACCESS_CONTROL_POLICY_UNAVAILABLE will receive the notification when AEF remove Security Context created previously.
  Enhanced Event Report feature must be inactive.

**Pre-Conditions**:

  * CAPIF subscriber is pre-authorised (has valid InvokerId or apfId from CAPIF Authority)
  * CAPIF provider is correctly registered.
  * API Provider had one Service API Published on CAPIF
  * **Mock Server is up and running to receive requests.**
  * **Mock Server is clean.**

**Execution Steps**:

  1. Register Provider at CCF.
  2. Publish a provider API with name **service_1**.
  3. Register Invoker and Onboard Invoker at CCF.
  4. Subscribe Invoker to **ACCESS_CONTROL_POLICY_UNAVAILABLE** event. Enhanced_event_report inactive at supported features.
  5. Discover APIs filtered by **aef_id**
  6. Create Security Context for Invoker.
  7. Provider Retrieve ACL.
  8. Remove Security Context for Invoker.

**Information of Test**:

  1. Check and Clean Mock Server
  2. Perform [provider registration]
  3. Perform [invoker onboarding]
  4. Event Subscription to **ACCESS_CONTROL_POLICY_UNAVAILABLE** event:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**
     2. body [event subscription request body] with:
        1. events: **['ACCESS_CONTROL_POLICY_UNAVAILABLE']**
        2. eventFilters: apiInvokerIds array with apiInvokerId of invoker
        3. supportedFeatures: binary 0000 -> string **0**
     3. Use **Invoker Certificate**
  5. Discover published APIs
  6. Create Security Context for Invoker
     * Send **PUT** **https://{CAPIF_HOSTNAME}/trustedInvokers/{apiInvokerId}**
     * body [service security body]
     * Use **Invoker Certificate**
  7. Provider Retrieve ACL
     * Send **GET** **https://{CAPIF_HOSTNAME}/access-control-policy/v1/accessControlPolicyList/${serviceApiId}?aef-id=${aef_id}**
     * Use **serviceApiId** and **aefId**
     * Use **AEF Provider Certificate**
  8. Delete Security Context of Invoker by Provider:
     * Send **DELETE** **https://{CAPIF_HOSTNAME}/trustedInvokers/{apiInvokerId}**
     * Use **AEF Certificate**

**Expected Result**:

  1. Response to Event Subscription must accomplish:
     1. **201 Created**
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/capif-events/{apiVersion}/{subscriberId}/subscriptions/{subscriptionId}**
     3. Response Body must follow **EventSubscription** data structure.
  2. Create security context:
     1. **201 Created** response.
     2. body returned must accomplish **ServiceSecurity** data structure.
     3. Location Header must contain the new resource URL **{apiRoot}/capif-security/v1/trustedInvokers/{apiInvokerId}**
  3. ACL Response:
     1. **200 OK** Response.
     2. body returned must accomplish **AccessControlPolicyList** data structure.
     3. apiInvokerPolicies must:
        1. contain only one object.
        2. apiInvokerId must match apiInvokerId registered previously.
  4. Delete security context:
     1. **204 No Content** response.
  5. Mock Server received messages must accomplish:
     1. **One Event has been received**.
     2. Validate received event follow **EventNotification** data structure, without **eventDetail** parameter.
        1. One Event should be **ACCESS_CONTROL_POLICY_UNAVAILABLE** without **eventDetail**.
---
## Test Case 20: Invoker receives an Invoker Authorization Revoked and ACL unavailable event when Provider revoke Invoker Authorization without Enhanced Event Report

**Test ID**: ***capif_api_events-20***, ***mockserver***

**Description**:

  This test case will check that a CAPIF Invoker subscribed to API_INVOKER_AUTHORIZATION_REVOKED and ACCESS_CONTROL_POLICY_UNAVAILABLE receive both notification when AEF revoke invoker's authorization.
  Enhanced Event Report feature must be inactive.

**Pre-Conditions**:

  * CAPIF subscriber is pre-authorised (has valid InvokerId or apfId from CAPIF Authority)
  * CAPIF provider is correctly registered.
  * API Provider had one Service API Published on CAPIF
  * **Mock Server is up and running to receive requests.**
  * **Mock Server is clean.**

**Execution Steps**:

  1. Register Provider at CCF.
  2. Publish a provider API with name **service_1**.
  3. Register Invoker and Onboard Invoker at CCF.
  4. Subscribe Invoker to **ACCESS_CONTROL_POLICY_UNAVAILABLE and API_INVOKER_AUTHORIZATION_REVOKED** events.
  5. Discover APIs filtered by **aef_id**
  6. Create Security Context for Invoker.
  7. Revoke Authorization by Provider.

**Information of Test**:

  1. Check and Clean Mock Server
  2. Perform [provider registration]
  3. Perform [invoker onboarding]
  4. Event Subscription to **ACCESS_CONTROL_POLICY_UNAVAILABLE and API_INVOKER_AUTHORIZATION_REVOKED** event:
     1. Send **POST** to **https://{CAPIF_HOSTNAME}/capif-events/v1/{subscriberId}/subscriptions**
     2. body [event subscription request body] with:
        1. events: **['ACCESS_CONTROL_POLICY_UNAVAILABLE','API_INVOKER_AUTHORIZATION_REVOKED']**
        2. eventFilters: apiInvokerIds array with apiInvokerId of invoker
     3. Use **Invoker Certificate**
  5. Discover published APIs
  6. Create Security Context for Invoker
     * Send **PUT** **https://{CAPIF_HOSTNAME}/trustedInvokers/{apiInvokerId}**
     * body [service security body]
     * Use **Invoker Certificate**
  7. Revoke Authorization by Provider:
     * Send **POST** **https://{CAPIF_HOSTNAME}/trustedInvokers/{apiInvokerId}/delete**
     * body [security notification body]
     * Using **AEF Certificate**.

**Expected Result**:

  1. Response to Event Subscription must accomplish:
     1. **201 Created**
     2. The URI of the created resource shall be returned in the "Location" HTTP header, following this structure: **{apiRoot}/capif-events/{apiVersion}/{subscriberId}/subscriptions/{subscriptionId}**
     3. Response Body must follow **EventSubscription** data structure.
  2. Create security context:
     1. **201 Created** response.
     2. body returned must accomplish **ServiceSecurity** data structure.
     3. Location Header must contain the new resource URL **{apiRoot}/capif-security/v1/trustedInvokers/{apiInvokerId}**
  4. Revoke Authorization:
     1. **204 No Content** response.
  5. Mock Server received messages must accomplish:
     1. **Two Events has been received**.
     2. Validate received event follow **EventNotification** data structure, without **eventDetail** parameter.
        1. One Event should be **ACCESS_CONTROL_POLICY_UNAVAILABLE** without **eventDetail**.
        2. One Event should be **API_INVOKER_AUTHORIZATION_REVOKED** without **eventDetail**.

---


[invoker onboard request body]: ../api_invoker_management/invoker_details_post_example.json  "API Invoker Request"
[event subscription request body]: ./event_subscription.json  "Event Subscription Request"
[invoker onboarding]: ../common_operations/README.md#onboard-an-invoker "Invoker Onboarding"
[provider registration]: ../common_operations/README.md#register-a-provider "Provider Registration"
[log entry request body]: ../api_logging_service/invocation_log.json "Log Request Body"
[put register body]: ./invoker_details_put_example.json  "API Invoker Update Request"
[service security body]: ../api_security_service/service_security.json  "Service Security Request"
Jorge Moratinos's avatar
Jorge Moratinos committed
[security notification body]: ../api_security_service/security_notification.json  "Security Notification Request"

[Return To All Test Plans]: ../README.md