Commit 2ff7a5e8 authored by Eisha Ayaz's avatar Eisha Ayaz
Browse files

[test-upd][SOL002][VNF-IND][v5.3.1][6.3.2.6.1,2 Test-IDs][NFVSOL(26)000019r3​]...

[test-upd][SOL002][VNF-IND][v5.3.1][6.3.2.6.1,2 Test-IDs][NFVSOL(26)000019r3​] Add support of received notification validation
parent 21856b19
Loading
Loading
Loading
Loading
+88 −2
Original line number Diff line number Diff line
*** Setting ***
*** Settings ***
Resource	environment/variables.txt
Suite Setup    Create Sessions
Suite Teardown    Terminate All Processes    kill=true
@@ -8,6 +8,7 @@ Library OperatingSystem
Library    BuiltIn
Library    Collections
Library    String
Library    REST    ${EM-VNF_SCHEMA}://${EM-VNF_HOST}:${EM-VNF_PORT}    ssl_verify=false


*** Test Cases ***
@@ -23,6 +24,7 @@ VNF Indicator Value Change Notification
    Trigger the availability of new indicator value in the VNF (external action) 
    Check Indicator Value Change Notification Http POST Request Body Json Schema Is    VnfIndicatorValueChangeNotification
    Check Indicator Value Change Notification Http POST Request Body notificationType attribute Is    VnfIndicatorValueChangeNotification
    Check Indicator Value Change Notification validation

Supported Indicators Change Notification
    [Documentation]    Test ID: 6.3.2.6.2
@@ -36,6 +38,7 @@ Supported Indicators Change Notification
    Trigger the availability of new indicator value in the VNF (external action) 
    Check Indicator Value Change Notification Http POST Request Body Json Schema Is    SupportedIndicatorsChangeNotification
    Check Indicator Value Change Notification Http POST Request Body notificationType attribute Is    SupportedIndicatorsChangeNotification
    Check Supported Indicators Change Notification validation

*** Keywords ***
Trigger the availability of new indicator value in the VNF (external action) 
@@ -77,3 +80,86 @@ 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 Indicator Value Change Notification validation
    [Arguments]    ${expected_notification_type}=VnfIndicatorValueChangeNotification
    ${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}

    ${vnfInstanceId}=    Get From Dictionary    ${notification}    vnfInstanceId
    ${indicatorId}=    Get From Dictionary    ${notification}    vnfIndicatorId
    ${subscriptionId}=    Get From Dictionary    ${notification}    subscriptionId

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

    # Validate Subscription exists
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions/${subscriptionId}
    Integer    response status    200

    # Validate Indicator resource
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/indicators/${vnfInstanceId}/${indicatorId}
    Integer    response status    200

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

Check Supported Indicators Change Notification validation
    [Arguments]    ${expected_notification_type}=SupportedIndicatorsChangeNotification
    ${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}

    ${vnfInstanceId}=    Get From Dictionary    ${notification}    vnfInstanceId
    ${subscriptionId}=    Get From Dictionary    ${notification}    subscriptionId

    Dictionary Should Contain Key    ${notification}    supportedIndicators
    ${supportedIndicators}=    Get From Dictionary    ${notification}    supportedIndicators
    Should Not Be Empty    ${supportedIndicators}

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

    # Validate Subscription exists
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions/${subscriptionId}
    Integer    response status    200

    # Validate VNF Instance indicators list exists
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/indicators/${vnfInstanceId}
    Integer    response status    200

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