Commit d63fe999 authored by Giacomo Bernini's avatar Giacomo Bernini
Browse files

[test-upd][SOL009][NFV-MANO-CIM][v5.3.1][NFVSOL(26)000019r3][8.3.1.12.x...

[test-upd][SOL009][NFV-MANO-CIM][v5.3.1][NFVSOL(26)000019r3][8.3.1.12.x Test-IDs] implemented support for notification validation as per item 17-2
parent f8222a55
Loading
Loading
Loading
Loading
+81 −4
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ Library OperatingSystem
Library    BuiltIn
Library    Collections
Library    String
Library    REST    ${NFVMANO_SCHEMA}://${NFVMANO_HOST}:${NFVMANO_PORT}    ssl_verify=false


*** Test Cases ***
@@ -23,6 +24,7 @@ Information Changed Notification
    Trigger the availability of Information Changed Notification (external action) 
    Check Information Changed Notification Available Http POST Request Body Json Schema Is    InformationChangedNotification
    Check Information Changed Notification Available Http POST Request Body notificationType attribute Is    InformationChangedNotification
    Check Information Changed Notification Validation

Change State Notification
    [Documentation]    Test ID: 8.3.1.12.2
@@ -36,6 +38,7 @@ Change State Notification
    Trigger the cross of Change State (external action) 
    Check Change State Notification Http POST Request Body Json Schema Is    ChangeStateNotification
    Check Change State Notification Http POST Request Body notificationType attribute Is    ChangeStateNotification
    Check Change State Notification Validation


*** Keywords ***
@@ -56,8 +59,8 @@ Check Information Changed Notification Available Http POST Request Body notifica
    [Arguments]    ${type}
    Configure Notification Information Changed Notification Available Handler    ${callback_endpoint_fwd}    ${type}
    Wait Until Keyword Succeeds    2 min   10 sec   Verify Mock Expectation    ${notification_request}
    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}
    #Clear Requests    ${callback_endpoint}
    #Clear Requests    ${callback_endpoint_fwd}

Check Change State Notification Http POST Request Body Json Schema Is    
    [Arguments]    ${element}
@@ -69,8 +72,8 @@ Check Change State Notification Http POST Request Body notificationType attribut
    [Arguments]    ${type}
    Configure Notification State Crossed Handler    ${callback_endpoint_fwd}    ${type}
    Wait Until Keyword Succeeds    2 min   10 sec   Verify Mock Expectation    ${notification_request}
    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}
    #Clear Requests    ${callback_endpoint}
    #Clear Requests    ${callback_endpoint_fwd}
    
    
Check Change State Notification Http POST Request Body changeType attribute Is
@@ -108,6 +111,80 @@ Configure Notification Forward
    &{notification_fwd}=  Create Mock Http Forward  ${endpoint_fwd}
    Create Mock Expectation With Http Forward  ${notification_tmp}  ${notification_fwd}

Check Information Changed Notification Validation
    [Arguments]    ${expected_notification_type}=InformationChangedNotification
    ${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}

    ${manoEntityId}=    Get From Dictionary    ${notification}    manoEntityId

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

    # Validate entity exists
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/mano_entity
    Integer    response status    200
    ${output}=    Output    response
    Should Be Equal    ${output['body']['id']}    ${manoEntityId} 

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

Check Change State Notification Validation
    [Arguments]    ${expected_notification_type}=ChangeStateNotification
    ${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}

    ${managedObjectRef}=    Get From Dictionary    ${notification}    managedObjectRef

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

    # Validate entity exists
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/mano_entity
    Integer    response status    200
    ${output}=    Output    response
    Should Be Equal    ${output['body']['id']}    ${managedObjectRef['objectId']} 

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

Create Sessions
    Start Process  java  -jar  ${MOCK_SERVER_JAR}  -serverPort  ${callback_port}  alias=mockInstance
    Wait For Process  handle=mockInstance  timeout=5s  on_timeout=continue
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ ${CONTENT_TYPE_JSON} application/json
${ACCEPT_JSON}    application/json
${CONTENT_TYPE_PATCH}    application/merge-patch+json
${AUTH_USAGE}     1
${API_VERSION}      2.15.0     

${NFVMANO_CHECKS_NOTIF_ENDPOINT}    1        ## If true, during subscription, the FUT performs a get to the notification endpoint