Skip to content
NotificationEndpoint.robot 3.82 KiB
Newer Older
Resource    environment/variables.txt 
Suite Setup    Create Sessions
Suite Teardown    Terminate All Processes    kill=true
Library    MockServerLibrary
Library    Process
Library    OperatingSystem

*** Test Cases ***
Deliver a notification - Alarm
    log    The POST method delivers a notification - Information of a VNF alarm.
    ${json}=	Get File	schemas/alarmNotification.schema.json
    ${BODY}=	evaluate	json.loads('''${json}''')	json
    Log  Creating mock request and response to handle alarmNotification
Elian Kraja's avatar
Elian Kraja committed
    &{req}=  Create Mock Request Matcher Schema 	POST    ${callback_uri}  body=${BODY}
    &{rsp}=  Create Mock Response Schema	headers="Content-Type: application/json"  status_code=204
    Create Mock Expectation  ${req}  ${rsp}
    Sleep  ${sleep_interval}
    Log  Verifying results
    Verify Mock Expectation  ${req}
    Log  Cleaning the endpoint
Elian Kraja's avatar
Elian Kraja committed
    Clear Requests  ${callback_uri}

Deliver a notification - Alarm Clearance
    log    The POST method delivers a notification - Information of a VNF alarm.
    ${json}=	Get File	schemas/alarmClearedNotification.schema.json
    ${BODY}=	evaluate	json.loads('''${json}''')	json
    Log  Creating mock request and response to handle alarmNotification
Elian Kraja's avatar
Elian Kraja committed
    &{req}=  Create Mock Request Matcher Schema	POST  ${callback_uri}  body=${BODY}
    &{rsp}=  Create Mock Response Schema	headers="Content-Type: application/json"  status_code=204
    Create Mock Expectation  ${req}  ${rsp}
    Sleep  ${sleep_interval}
    Log  Verifying results
    Verify Mock Expectation  ${req}
    Log  Cleaning the endpoint
Elian Kraja's avatar
Elian Kraja committed
    Clear Requests  ${callback_uri}

Deliver a notification - Alarm List Rebuilt
    log    The POST method delivers a notification - Information of a VNF alarm.
    ${json}=	Get File	schemas/alarmListRebuiltNotification.schema.json
    ${BODY}=	evaluate	json.loads('''${json}''')	json
    Log  Creating mock request and response to handle alarmNotification
Elian Kraja's avatar
Elian Kraja committed
    &{req}=  Create Mock Request Matcher Schema	POST  ${callback_endpoint}  body=${BODY}
    &{rsp}=  Create Mock Response Schema	headers="Content-Type: application/json"  status_code=204
    Create Mock Expectation  ${req}  ${rsp}
    Sleep  ${sleep_interval}
    Log  Verifying results
    Verify Mock Expectation  ${req}
    Log  Cleaning the endpoint
Elian Kraja's avatar
Elian Kraja committed
    Clear Requests  ${callback_endpoint}

Test a notification end point
    log    The GET method allows the server to test the notification endpoint
Elian Kraja's avatar
Elian Kraja committed
    &{req}=  Create Mock Request Matcher Schema	GET  ${callback_endpoint}
    &{rsp}=  Create Mock Response Schema	headers="Content-Type: application/json"  status_code=204
    Create Mock Expectation  ${req}  ${rsp}
    Sleep  ${sleep_interval}
    Verify Mock Expectation  ${req}
Elian Kraja's avatar
Elian Kraja committed
    Clear Requests  ${callback_endpoint}

PUT notification - Method not implemented
    log    Trying to perform a PUT. This method should not be implemented
Elian Kraja's avatar
Elian Kraja committed
    Put    ${callback_endpoint}
    Log    Validate Status code
    Output    response
    Integer    response status    405

PATCH subscriptions - Method not implemented
    log    Trying to perform a PATCH. This method should not be implemented
Elian Kraja's avatar
Elian Kraja committed
    Patch    ${callback_endpoint}
    Log    Validate Status code
    Output    response
    Integer    response status    405

DELETE subscriptions - Method not implemented
    log    Trying to perform a DELETE. This method should not be implemented
Elian Kraja's avatar
Elian Kraja committed
    Delete    ${callback_endpoint}
    Log    Validate Status code
    Output    response
    Integer    response status    405
    
*** Keywords ***
Create Sessions
Elian Kraja's avatar
Elian Kraja committed
    Start Process  java  -jar  ../../bin/mockserver-netty-5.3.0-jar-with-dependencies.jar  -serverPort  ${callback_port}  alias=mockInstance
    Wait For Process  handle=mockInstance  timeout=5s  on_timeout=continue
Elian Kraja's avatar
Elian Kraja committed
    Create Mock Session  ${callback_schema}://${callback_uri}:${callback_port}     #The API producer is set to NFVO according to SOL003-7.3.4