Commit 16c97d39 authored by Giacomo Bernini's avatar Giacomo Bernini
Browse files

[test-upd][SOL005][VNF-PKG-MGMT][v5.3.1][NFVSOL(26)000019r3][5.3.5.9.x...

[test-upd][SOL005][VNF-PKG-MGMT][v5.3.1][NFVSOL(26)000019r3][5.3.5.9.x Test-IDs] implemented support for notification validation as per item 17-2
parent 6d1934bf
Loading
Loading
Loading
Loading
+72 −2
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ Library OperatingSystem
Library    BuiltIn
Library    Collections
Library    String
Library    REST    ${NFVO_SCHEMA}://${NFVO_HOST}:${NFVO_PORT}     ssl_verify=false


*** Test Cases ***
@@ -23,6 +24,7 @@ VNF Package Onboarding Notification
    Trigger the completion of VNF Package Onboarding (external action) 
    Check Onboarding Notification Http POST Request Body Json Schema Is    VnfPackageOnboardingNotification
    Check Onboarding Notification Http POST Request Body notificationType attribute Is    VnfPackageOnboardingNotification
    Check Onboarding Notification Available

VNF Package Operational State Change Notification
    [Documentation]    Test ID: 5.3.5.9.2
@@ -37,6 +39,7 @@ VNF Package Operational State Change Notification
    Check State Change Notification Http POST Request Body Json Schema Is    VnfPackageChangeNotification
    Check State Change Notification Http POST Request Body notificationType attribute Is    VnfPackageChangeNotification
    Check State Change Notification Http POST Request Body changeType attribute Is    OP_STATE_CHANGE 
    Check State Change Notification Available

VNF Package Deletion Notification
    [Documentation]    Test ID: 5.3.5.9.3
@@ -51,7 +54,7 @@ VNF Package Deletion Notification
    Check Deletion Notification Http POST Request Body Json Schema Is    VnfPackageChangeNotification
    Check Deletion Notification Http POST Request Body notificationType attribute Is    VnfPackageChangeNotification
    Check Deletion Notification Http POST Request Body changeType attribute Is    PKG_DELETE 

    Check State Change Notification Available

*** Keywords ***
Trigger the completion of VNF Package Onboarding (external action) 
@@ -157,3 +160,70 @@ Create Sessions
    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 Onboarding Notification Available
    [Arguments]    ${expected_notification_type}=VnfPackageOnboardingNotification
    ${requests}=    Retrieve Requests    ${callback_endpoint_fwd}
    Should Not Be Empty    ${requests}    msg=No notification received at callback endpoint!

    ${request_type}=    Evaluate    type(${requests})
    Log    Request type: ${request_type}

    ${last_request}=    Run Keyword If    "${request_type}" == "<class 'list'>"
    ...    Get From List    ${requests}    -1
    ...    ELSE
    ...    Set Variable    ${requests}

    ${body}=    Get From Dictionary    ${last_request}    body
    ${body_text}=    Get From Dictionary    ${body}    string

    ${notification}=    Evaluate    json.loads(r'''${body_text}''')    json
    Log    Parsed notification: ${notification}

    Should Be Equal As Strings    ${notification['notificationType']}    ${expected_notification_type}

    ${vnfPackageId}=    Get From Dictionary    ${notification}    vnfPkgId

    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1
    ...    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}

    # Validate entity exists
    REST.GET    ${apiRoot}/${apiName}/${apiMajorVersion}/vnf_packages/${vnfPackageId}
    Integer    response status    200

    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}

Check State Change Notification Available
    [Arguments]    ${expected_notification_type}=VnfPackageChangeNotification
    ${requests}=    Retrieve Requests    ${callback_endpoint_fwd}
    Should Not Be Empty    ${requests}    msg=No notification received at callback endpoint!

    ${request_type}=    Evaluate    type(${requests})
    Log    Request type: ${request_type}

    ${last_request}=    Run Keyword If    "${request_type}" == "<class 'list'>"
    ...    Get From List    ${requests}    -1
    ...    ELSE
    ...    Set Variable    ${requests}

    ${body}=    Get From Dictionary    ${last_request}    body
    ${body_text}=    Get From Dictionary    ${body}    string

    ${notification}=    Evaluate    json.loads(r'''${body_text}''')    json
    Log    Parsed notification: ${notification}

    Should Be Equal As Strings    ${notification['notificationType']}    ${expected_notification_type}

    ${vnfPackageId}=    Get From Dictionary    ${notification}    vnfPkgId

    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1
    ...    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}

    # Validate entity exists
    REST.GET    ${apiRoot}/${apiName}/${apiMajorVersion}/vnf_packages/${vnfPackageId}
    Integer    response status    200

    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}
 No newline at end of file