Commit fbde6eca authored by Najam UI Hassan's avatar Najam UI Hassan Committed by Giacomo Bernini
Browse files

Added Test Cases for Subscriptions.robot

parent 99d0a817
Loading
Loading
Loading
Loading
+125 −1
Original line number Original line Diff line number Diff line
@@ -563,3 +563,127 @@ Send Delete request for Individual Peer Entity
    Delete    ${apiRoot}/${apiName}/${apiMajorVersion}/peer_entities/${peerEntityId}
    Delete    ${apiRoot}/${apiName}/${apiMajorVersion}/peer_entities/${peerEntityId}
    ${outputResponse}=    Output    response
    ${outputResponse}=    Output    response
	Set Global Variable    @{response}    ${outputResponse}
	Set Global Variable    @{response}    ${outputResponse}
	


	
Create Sessions
    Pass Execution If    ${NFVMANO_CHECKS_NOTIF_ENDPOINT} == 0   MockServer not necessary to run    
    Start Process  java  -jar  ${MOCK_SERVER_JAR}    -serverPort  ${callback_port}  alias=mockInstance
    Wait For Process  handle=mockInstance  timeout=5s  on_timeout=continue
    Create Mock Session  ${callback_uri}:${callback_port}
    
Check Notification Endpoint
    &{notification_request}=  Create Mock Request Matcher	GET  ${callback_endpoint}    
    &{notification_response}=  Create Mock Response	headers="Content-Type: application/json"  status_code=204
    Create Mock Expectation  ${notification_request}  ${notification_response}
    Wait Until Keyword Succeeds    ${total_polling_time}   ${polling_interval}   Verify Mock Expectation    ${notification_request}
    Clear Requests  ${callback_endpoint}

    
Get all Subscriptions
    [Documentation]    The api consumer can use this method to query the list of active subscriptions to log management notifications
    Set headers    {"Accept": "application/json"}
    Set headers    {"Content-Type": "application/json"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    
 Get Subscriptions with attribute-based filters
    [Documentation]    The api consumer can use this method to query the list of active subscriptions to log management notifications
    Set headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions?${filter_ok}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    
Get Subscriptions with invalid attribute-based filters
    [Documentation]    The api consumer can use this method to query the list of active subscriptions to log management notifications
    Set headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions?${filter_ko}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    
Send Post Request for Subscription
    Set headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    Set headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    ${body_request}=    Get File    jsons/CimSubscriptionRequest.json
    POST    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions    ${body_request}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    Run Keyword If    ${NFVMANO_CHECKS_NOTIF_ENDPOINT} == 1
    ...       Check Notification Endpoint

Check HTTP Response Body CimSubscription Attributes Values Match the Issued Subscription
    Log    Check Response matches subscription
    ${body}=    Get File    jsons/subscriptions.json
    ${subscription}=    evaluate    json.loads('''${body}''')    json
    Should Be Equal As Strings    ${response['body']['callbackUri']}    ${subscription['callbackUri']}

Check Postcondition Subscription Is Set
    Log    Check Postcondition subscription exist
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions/${response['body']['id']}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    Check HTTP Response Status Code Is    200
    
Send Post Request for Duplicated Subscription
    Set headers    {"Content-Type": "${CONTENT_TYPE_JSON}"}
    Set headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
    ${body_request}=    Get File    jsons/CimSubscriptionRequest.json
    POST    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions    ${body_request}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}  
    
Check HTTP Response Body Is Empty
    Should Be Empty    ${response['body']}    
    Log    No json schema is provided. Validation OK  
    
Check Postcondition Subscription Resource Returned in Location Header Is Available
    Log    Going to check postcondition
    GET    ${response['headers']['Location']}
    Integer    response status    200
    Log    Received a 200 OK as expected
    ${contentType}=    Output    response headers Content-Type
    Should Contain    ${contentType}    application/json
    ${result}=    Output    response body
    Validate Json    CimSubscription.schema.json    ${result}
    Log    Validated CimSubscription schema
    ${body}=    Get File    jsons/subscriptions.json
    ${subscription}=    evaluate    json.loads('''${body}''')    json
    Should Be Equal    ${result['callbackUri']}    ${subscription['callbackUri']}
    Log    Validated Issued subscription is same as original
    
Send Put Request for Subscriptions
    [Documentation]    This method is not supported. When this method is requested on this resource, the NFV-MANO shall return a "405 Method
    ...    Not Allowed" response as defined in clause 4.3.5.4.
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
    PUT    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

Send Patch Request for Subscriptions
    [Documentation]    This method is not supported. When this method is requested on this resource, the NFV-MANO shall return a "405 Method
    ...    Not Allowed" response as defined in clause 4.3.5.4.
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
    PATCH    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

Send Delete Request for Subscriptions
    [Documentation]    This method is not supported. When this method is requested on this resource, the NFV-MANO shall return a "405 Method
    ...    Not Allowed" response as defined in clause 4.3.5.4.
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
    DELETE    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    
Check Postcondition Subscriptions Exists
    Log    Checking that subscriptions exists
    Get all Subscriptions
    Check HTTP Response Status Code Is    200
 No newline at end of file
+176 −0
Original line number Original line Diff line number Diff line
*** Settings ***
Library           JSONSchemaLibrary    schemas/
Resource          environment/variables.txt    
Library           REST    ${NFVMANO_SCHEMA}://${NFVMANO_HOST}:${NFVMANO_PORT}    ssl_verify=false
Library           OperatingSystem
Library           JSONLibrary
Resource          NFVMANOCimKeywords.robot
Library           MockServerLibrary
Library           Process
Suite Setup       Create Sessions
Suite Teardown    Terminate All Processes    kill=true

*** Test Cases ***
GET all Subscriptions
    [Documentation]    Test ID: 8.3.1.10.1
    ...    Test title: GET all Subscriptions
    ...    Test objective: The objective is to test the retrieval list of active subscriptions of API consumer and perform a JSON schema validation of the returned subscriptions data structure
    ...    Pre-conditions:  At least one subscription is available in the NFV-MANO.
    ...    Reference: clause 5.5.4.3.2 - ETSI GS NFV-SOL 009 [5] V3.3.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none    
    Get all Subscriptions
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is    CimSubscriptions

GET Subscriptions with attribute-based filter
    [Documentation]    Test ID:  8.3.1.10.2
    ...    Test title: GET Subscriptions with attribute-based filter
    ...    Test objective: The objective is to test the retrieval of active subscriptions list of API consumer using attribute-based filter, perform a JSON schema validation of the collected indicators data structure, and verify that the retrieved information matches the issued attribute-based filters 
    ...    Pre-conditions: At least one subscription is available in the NFV-MANO.
    ...    Reference: clause 5.5.4.3.2 - ETSI GS NFV-SOL 009 [5] V3.3.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none
    Get Subscriptions with attribute-based filters
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is    CimSubscriptions
    
GET Subscriptions with Paged Response
    [Documentation]    Test ID: 8.3.1.10.3
    ...    Test title: GET Subscriptions with Paged Response
    ...    Test objective: The objective is to query information of active subscriptions list to of API consumer to get Paged Response.
    ...    Pre-conditions:  At least one subscription is available in the NFV-MANO.
    ...    Reference: clause 5.5.4.3.2 - ETSI GS NFV-SOL 009 [5] V3.3.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: 
    ...    Post-Conditions: 
    Get all Subscriptions
    Check HTTP Response Status Code Is    200
    Check LINK in Header

GET Subscriptions - invalid attribute-based filter
    [Documentation]    Test ID: 8.3.1.10.4
    ...    Test title: GET Subscriptions - invalid attribute-based filter
    ...    Test objective: The objective is to test that the retrieval of active subscriptions list of API consumer fails when using invalid attribute-based filters, and perform the JSON schema validation of the failed operation HTTP response. 
    ...    Pre-conditions: At least one subscription is available in the NFV-MANO.
    ...    Reference: clause 5.5.4.3.2 - ETSI GS NFV-SOL 009 [5] V3.3.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none
    Get Subscriptions with invalid attribute-based filters
    Check HTTP Response Status Code Is    400
    Check HTTP Response Body Json Schema Is   ProblemDetails 


GET Subscriptions - Bad Request Response too Big
    [Documentation]    Test ID: 8.3.1.10.5
    ...    Test title: GET Subscriptions - Bad Request Response too Big
    ...    Test objective: The objective is to test that the retrieval of active subscriptions list of API consumer fails when response is too big, and perform the JSON schema validation of the failed operation HTTP response.
    ...    Pre-conditions: At least one subscription is available in the NFV-MANO.
    ...    Reference: clause 5.5.4.3.2 - ETSI GS NFV-SOL 009 [5] V3.3.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none
    Get all Subscriptions
    Check HTTP Response Status Code Is    400
    Check HTTP Response Body Json Schema Is    ProblemDetails

GET Subscriptions - invalid resource endpoint
    [Documentation]    Test ID: 8.3.1.10.6
    ...    Test title: GET Subscriptions - invalid resource endpoint
    ...    Test objective: The objective is to test that the retrieval of active subscriptions list of API consumer fails when using invalid resource endpoint.
    ...    Pre-conditions: At least one subscription is available in the NFV-MANO.
    ...    Reference: clause 5.5.4.3.2 - ETSI GS NFV-SOL 009 [5] V3.3.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none    
    Get all Subscriptions
    Check HTTP Response Status Code Is    404
    
    
Create new Subscription
    [Documentation]    Test ID 8.3.1.10.7
    ...    Test title: Create new Subscription
    ...    Test objective: The objective is to test the creation of a new subscription and perform a JSON schema and content validation of the returned subscription data structure
    ...    Pre-conditions: 
    ...    Reference: clause 5.5.4.3.1 - ETSI GS NFV-SOL 009 [5] V3.3.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: The subscription is successfully set and it matches the issued subscription    
    Send Post Request for Subscription
    Check HTTP Response Status Code Is    201
    Check HTTP Response Body Json Schema Is    CimSubscription
    Check HTTP Response Body CimSubscription Attributes Values Match the Issued Subscription
    Check Postcondition Subscription Is Set 


Create request for duplicated Subscription not creating duplicated subscriptions
    [Tags]    no-duplicated-subs
    [Documentation]    Test ID 8.3.1.10.8
    ...    Test title: Create request for duplicated Subscription not creating duplicated subscriptions
    ...    Test objective: The objective is to test the attempt of a creation of a duplicated subscription failed and check that no new subscription is created and a link to the original subscription is returned
    ...    Pre-conditions: At least one subscription is available in the NFV-MANO.
    ...    Reference: clause 5.5.4.3.1 - ETSI GS NFV-SOL 009 [5] V3.3.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: The NFV-MANO does not support the creation of duplicated subscriptions
    ...    Post-Conditions: The existing Subscription returned is available in the NFV-MANO 
    Send Post Request for Duplicated Subscription
    Check HTTP Response Status Code Is    303
    Check HTTP Response Body Is Empty
    Check HTTP Response Header Contains    Location
    Check Postcondition Subscription Resource Returned in Location Header Is Available

Create request for duplicated Subscription creating duplicated subscriptions
    [Tags]    duplicated-subs
    [Documentation]    Test ID 8.3.1.10.9
    ...    Test title: Create request for duplicated Subscription creating duplicated subscriptions
    ...    Test objective: The objective is to test the creation of a duplicated subscription and perform a JSON schema and content validation of the returned duplicated subscription data structure
    ...    Pre-conditions: At least one subscription is available in the NFV-MANO.
    ...    Reference: clause 5.5.4.3.1 - ETSI GS NFV-SOL 009 [5] V3.3.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: The NFV-MANO supports the creation of duplicated subscriptions
    ...    Post-Conditions: The duplicated subscription is successfully set and it matches the issued subscription
    Send Post Request for Duplicated Subscription
    Check HTTP Response Status Code Is    201
    Check HTTP Response Body Json Schema Is    PmSubscription
    Check HTTP Response Body CimSubscription Attributes Values Match the Issued Subscription
    Check Postcondition Subscription Is Set 

PUT Subscriptions - Method not implemented
    [Documentation]    Test ID 8.3.1.10.10
    ...    Test title: PUT Subscriptions - Method not implemented
    ...    Test objective: The objective is to test that PUT method is not allowed to modify subscriptions
    ...    Pre-conditions: At least one subscription is available in the NFV-MANO.
    ...    Reference: clause 5.5.4.3.3 - ETSI GS NFV-SOL 009 [5] V3.3.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none
    Send Put Request for Subscriptions
    Check HTTP Response Status Code Is    405 
    
PATCH Subscriptions - Method not implemented
    [Documentation]    Test ID 8.3.1.10.11
    ...    Test title: PATCH Subscriptions - Method not implemented
    ...    Test objective: The objective is to test that PATCH method is not allowed to update subscriptions
    ...    Pre-conditions: At least one subscription is available in the NFV-MANO.
    ...    Reference: clause 5.5.4.3.4 - ETSI GS NFV-SOL 009 [5] V3.3.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none
    Send Patch Request for Subscriptions
    Check HTTP Response Status Code Is    405
    
DELETE Subscriptions - Method not implemented
    [Documentation]    Test ID 8.3.1.10.12
    ...    Test title: DELETE Subscriptions - Method not implemented
    ...    Test objective: The objective is to test that DELETE method is not allowed to delete subscriptions
    ...    Pre-conditions: At least one subscription is available in the NFV-MANO.
    ...    Reference: clause 5.5.4.3.5 - ETSI GS NFV-SOL 009 [5] V3.3.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: The subscriptions are not deleted by the failed operation   
    Send Delete Request for Subscriptions
    Check HTTP Response Status Code Is    405
    Check Postcondition Subscriptions Exists
+24 −1
Original line number Original line Diff line number Diff line
@@ -32,3 +32,26 @@ ${changeStateOpOccId}
${manoServiceInterfaceId}
${manoServiceInterfaceId}


${peerEntityId}
${peerEntityId}

${callback_port}    9091
${callback_uri}    http://172.22.1.7:${callback_port}
${callback_endpoint}    /nfvmanocim/subscriptions
${filter_ok}      callbackUri=${callbackUri}
${filter_ko}      erroneousFilter=erroneous
${callback_endpoint_fwd}    /endpoint/check
${callback_endpoint_error}    /subs_404
${sleep_interval}    20s

${total_polling_time}   2 min
${polling_interval}     10 sec

${notification_request}    []
${notification_response}    []

${MOCK_SERVER_JAR}    ../../../bin/mockserver-netty-5.5.0-jar-with-dependencies.jar

${subscriptionId}    17563e75-0e14-4bd7-94b4-6bbb869c79aa
${erroneousSubscriptionId}    erroneousSubscriptionId
${newSubscriptionId}    newSubsciptionId

${origResponse}    {}
 No newline at end of file
+3 −0
Original line number Original line Diff line number Diff line
{
	"callbackUri":	"http://172.22.1.7:9091"
}
 No newline at end of file
+113 −0
Original line number Original line Diff line number Diff line
{
    "description": "This type represents a subscription related to notifications about  NFV-MANO configuration and information management changes\n",
    "type": "object",
    "properties": {
      "id": {
        "description": "An identifier with the intention of being globally unique.\n",
        "type": "string"
      },
      "filter": {
        "description": "This type represents a subscription filter related to notifications  about NFV-MANO configuration and information management. \n",
        "type": "object",
        "properties": {
          "manoEntitySubscriptionFilter": {
            "description": "This type represents subscription filter criteria to match NFV-MANO functional  entities and their associated managed objects. \n",
            "type": "object",
            "properties": {
              "manoEntityId": {
                "description": "An identifier with the intention of being globally unique.\n",
                "type": "string"
              },
              "manoServiceIds": {
                "description": "manoServiceIds\tIdentifierInManoEntity\t0..N\tIf present, match NFV-MANO  services with an instance identifier listed in this attribute.\nThe attributes \"manoServiceIds\" and \"manoServiceNames\" are alternatives  to reference to NFV-MANO services in a filter. They should not be used  together in the same filter instance, but one alternative should be chosen.\n",
                "type": "array",
                "items": {
                  "description": "An identifier that is unique for the respective type within a NFV-MANO functional entity, but that need not be globally unique. Representation: string of variable length..\n",
                  "type": "string"
                }
              },
              "manoServiceNames": {
                "description": "If present, match NFV-MANO services with an NFV-MANO service name listed  in this attribute.\nThe attributes \"manoServiceIds\" and \"manoServiceNames\" are alternatives  to reference to NFV-MANO services in a filter. They should not be used  together in the same filter instance, but one alternative should be chosen.\n",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "manoServiceInterfaceIds": {
                "description": "If present, match NFV-MANO functional entity produced interfaces with an  instance identifier listed in this attribute.\nThe attributes \"manoServiceInterfaceIds\" and \"manoServiceInterfaceNames\"  are alternatives to reference to NFV-MANO functional entity produced  interfaces in a filter. They should not be used both in the same filter  instance, but one alternative should be chosen.\n",
                "type": "array",
                "items": {
                  "description": "An identifier that is unique for the respective type within a NFV-MANO functional entity, but that need not be globally unique. Representation: string of variable length..\n",
                  "type": "string"
                }
              },
              "manoServiceInterfaceNames": {
                "description": "If present, match NFV-MANO functional entity produced interfaces with an  instance Name listed in this attribute.\nThe attributes \"manoServiceInterfaceIds\" and \"manoServiceInterfaceNames\"  are alternatives to reference to NFV-MANO functional entity produced  interfaces in a filter. They should not be used both in the same filter  instance, but one alternative should be chosen.\n",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "consumedManoInterfaceIds": {
                "description": "If present, match NFV-MANO functional entity consumed interfaces with an  instance identifier listed in this attribute.\nThe attributes \"consumedManoInterfaceIds\" and \"consumedManoInterfaceNames\"  are alternatives to reference to NFV-MANO functional entity consumed  interfaces in a filter. They should not be used both in the same filter  instance, but one alternative should be chosen.\n",
                "type": "array",
                "items": {
                  "description": "An identifier with the intention of being globally unique.\n",
                  "type": "string"
                }
              },
              "consumedManoInterfaceNames": {
                "description": "If present, match NFV-MANO functional entity consumed interfaces with an  instance Name listed in this attribute.\nThe attributes \"consumedManoInterfaceIds\" and \"consumedManoInterfaceNames\"  are alternatives to reference to NFV-MANO functional entity consumed  interfaces in a filter. They should not be used both in the same filter  instance, but one alternative should be chosen.\n",
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "notificationTypes": {
            "description": "Match particular notification types. \nPermitted values:\n  - InformationChangedNotification\n  - ChangeStateNotification\n\nNOTE:\tThe permitted values of the \"notificationTypes\" attribute are  spelled exactly as the names of the notification types to facilitate  automated code generation systems.\n",
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "InformationChangedNotification",
                "ChangeStateNotification"
              ]
            }
          }
        }
      },
      "callbackUri": {
        "description": "String formatted according to IETF RFC 3986.\n",
        "type": "string"
      },
      "_links": {
        "description": "Links to resources related to this resource.\n",
        "type": "object",
        "properties": {
          "self": {
            "description": "This type represents a link to a resource using an absolute URI.\n",
            "type": "object",
            "required": [
              "href"
            ],
            "properties": {
              "href": {
                "description": "String formatted according to IETF RFC 3986.\n",
                "type": "string"
              }
            }
          }
        },
        "required": [
          "self"
        ]
      }
    },
    "required": [
      "id",
      "callbackUri",
      "_links"
    ]
  }
 No newline at end of file
Loading