Commit f721f5cd authored by M. Rehan Abbasi's avatar M. Rehan Abbasi
Browse files

add PATCH method to individual threshod in PM API

parent 7e945f91
Loading
Loading
Loading
Loading
+32 −99
Original line number Diff line number Diff line
*** Settings ***
Library           JSONSchemaLibrary    schemas/
Resource          environment/variables.txt    # Generic Parameters
Library           JSONLibrary
Library           REST    ${NFVMANO_SCHEMA}://${NFVMANO_HOST}:${NFVMANO_PORT}    ssl_verify=false
Library           OperatingSystem
Resource          environment/individualThresholds.txt
Resource          NFVMANOPMKeywords.robot

*** Test Cases ***
POST Individual Threshold - Method not implemented
@@ -57,17 +52,18 @@ PUT Individual Threshold - Method not implemented
    Send Put request for individual Performance Threshold
    Check HTTP Response Status Code Is    405

PATCH Individual Threshold - Method not implemented
PATCH Individual Threshold
    [Documentation]    Test ID: 8.3.2.5.5
    ...    Test title: PATCH Individual Threshold - Method not implemented
    ...    Test objective: The objective is to test that PATCH method is not allowed to modify an existing Performance threshold
    ...    Pre-conditions: none
    ...    Test title: PATCH Individual Threshold
    ...    Test objective: The objective is to test that PATCH method modify an existing NFV_MANO performance threshold.
    ...    Pre-conditions: A NFV-MANO instance is instantiated. One or more performance thresholds are set.
    ...    Reference: clause 6.5.7.3.4 - ETSI GS NFV-SOL 009 [7] v3.5.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none
    ...    Post-Conditions: Threshold resource is modified.
    Send Patch request for individual Performance Threshold
    Check HTTP Response Status Code Is    405
    Check HTTP Response Status Code Is    200
    Check HTTP Response Body Json Schema Is    ThresholdModifications
    
DELETE Individual Threshold
    [Documentation]    Test ID: 8.3.2.5.6
@@ -94,91 +90,28 @@ DELETE Individual Threshold with invalid resource identifier
    Send Delete request for individual Performance Threshold with invalid resource identifier
    Check HTTP Response Status Code Is    404

*** Keywords ***
GET Individual Performance Threshold
    Log    Trying to get a Threhsold present in the NFV-MANO
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
    ${output}=    Output    response
    Set Suite Variable    @{response}    ${output}

GET individual Performance Threshold with invalid resource identifier
    Log    Trying to get a Threhsold with invalid resource endpoint
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${erroneousThresholdId}
    ${output}=    Output    response
    Set Suite Variable    @{response}    ${output}

Send Delete request for individual Performance Threshold
    Log    Trying to delete a Threhsold in the NFV-MANO
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    DELETE    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
    ${output}=    Output    response
    Set Suite Variable    @{response}    ${output}

Send Delete request for individual Performance Threshold with invalid resource identifier
    Log    Trying to delete a Threhsold in the NFV-MANO with invalid id
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    DELETE    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${erroneousThresholdId}
    ${output}=    Output    response
    Set Suite Variable    @{response}    ${output}

Send Post request for individual Performance Threshold
    Log    Trying to create new threshold
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    POST    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${newThresholdId}
    ${output}=    Output    response
    Set Suite Variable    @{response}    ${output}

Send Put request for individual Performance Threshold
    Log    Trying to PUT threshold
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
    ${origOutput}=    Output    response
    Set Suite Variable    ${origResponse}    ${origOutput}
    PUT    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
    ${output}=    Output    response
    Set Suite Variable    @{response}    ${output}

Send Patch request for individual Performance Threshold
    Log    Trying to PUT threshold
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
    ${origOutput}=    Output    response
    Set Suite Variable    ${origResponse}    ${origOutput}
    PATCH    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
    ${output}=    Output    response
    Set Suite Variable    @{response}    ${output}

Check Postcondition Performance Threshold is Deleted
    Log    Check Postcondition Threshold is deleted
    GET individual Performance Threshold
    Check HTTP Response Status Code Is    404
    
Check HTTP Response Body Threshold Identifier matches the requested Threshold
    Log    Trying to check response ID
    Should Be Equal    ${response['body']['id']}    ${thresholdId} 
    Log    Pm Job identifier as expected
    
Check HTTP Response Status Code Is
    [Arguments]    ${expected_status}
    ${status}=    Convert To Integer    ${expected_status}    
    Should Be Equal    ${response['status']}    ${status} 
    Log    Status code validated

Check HTTP Response Header Contains
    [Arguments]    ${CONTENT_TYPE}
    Should Contain    ${response['headers']}    ${CONTENT_TYPE}
    Log    Header is present
    
Check HTTP Response Body Json Schema Is
    [Arguments]    ${input}
    Run Keyword If    '${input}' == 'ProblemDetails'    Should Contain    ${response['headers']['Content-Type']}    application/problem+json
    ...    ELSE    Should Contain    ${response['headers']['Content-Type']}    application/json
    ${schema} =    Catenate    SEPARATOR=    ${input}    .schema.json
    Validate Json    ${schema}    ${response['body']}
    Log    Json Schema Validation OK
PATCH Individual Threshold - Precondition failed
    [Documentation]    Test ID: 8.3.2.5.8
    ...    Test title: PATCH Individual Threshold - Precondition failed
    ...    Test objective: The objective is to test that the PATCH method cannot modify an individual NFV-MANO threshold where the precondition was not met.
    ...    Pre-conditions: A NFV-MANO instance is instantiated. One or more performance thresholds are set.
    ...    Reference: clause 6.5.7.3.4 - ETSI GS NFV-SOL 009 [7] v3.5.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: Threshold resource is not modified.
    Send Patch request for individual Performance Threshold - Etag mismatch
    Check HTTP Response Status Code Is    412
    Check HTTP Response Body Json Schema Is    ProblemDetails

PATCH Individual Threshold - Unprocessable entity
    [Documentation]    Test ID: 8.3.2.5.9
    ...    Test title: PATCH Individual Threshold - Unprocessable entity
    ...    Test objective: The objective is to test that PATCH method cannot modify an exsisting individual threshold resource when a request contains syntactically correct data but the data cannot be processed.
    ...    Pre-conditions: A NFV-MANO instance is instantiated. One or more performance thresholds are set.
    ...    Reference: clause 6.5.7.3.4 - ETSI GS NFV-SOL 009 [7] v3.5.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: Threshold resource is not modified.
    Send Patch request for individual Performance Threshold with unprocessable entity
    Check HTTP Response Status Code Is    422
    Check HTTP Response Body Json Schema Is    ProblemDetails
+102 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ Resource environment/variables.txt
Resource    environment/pmJobs.txt
Resource    environment/IndividualPmJob.txt
Resource    environment/thresholds.txt
Resource    environment/individualThresholds.txt
Library     JSONLibrary
Library     OperatingSystem
Library     REST    ${NFVMANO_SCHEMA}://${NFVMANO_HOST}:${NFVMANO_PORT}    ssl_verify=false
@@ -396,3 +397,103 @@ Check Postcondition Threshold Exists
Check HTTP Response Body Thresholds match the requested attribute-based filter
    Log    Checking that attribute-based filter is matched
    #todo

GET Individual Performance Threshold
    Log    Trying to get a Threhsold present in the NFV-MANO
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
    ${output}=    Output    response
    Set Suite Variable    @{response}    ${output}

GET individual Performance Threshold with invalid resource identifier
    Log    Trying to get a Threhsold with invalid resource endpoint
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${erroneousThresholdId}
    ${output}=    Output    response
    Set Suite Variable    @{response}    ${output}

Send Delete request for individual Performance Threshold
    Log    Trying to delete a Threhsold in the NFV-MANO
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    DELETE    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
    ${output}=    Output    response
    Set Suite Variable    @{response}    ${output}

Send Delete request for individual Performance Threshold with invalid resource identifier
    Log    Trying to delete a Threhsold in the NFV-MANO with invalid id
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    DELETE    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${erroneousThresholdId}
    ${output}=    Output    response
    Set Suite Variable    @{response}    ${output}

Send Post request for individual Performance Threshold
    Log    Trying to create new threshold
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    POST    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${newThresholdId}
    ${output}=    Output    response
    Set Suite Variable    @{response}    ${output}

Send Put request for individual Performance Threshold
    Log    Trying to PUT threshold
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
    ${origOutput}=    Output    response
    Set Suite Variable    ${origResponse}    ${origOutput}
    PUT    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
    ${output}=    Output    response
    Set Suite Variable    @{response}    ${output}

Send Patch request for individual Performance Threshold
    Log    Trying to PUT threshold
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    Check GET response from Notification Endpoint
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
    ${origOutput}=    Output    response
    Set Suite Variable    ${origResponse}    ${origOutput}
    ${template}=    Get File    jsons/ThresholdModification.json
    ${body}=    Format String    ${template}    callbackUri=${callback_uri}
    PATCH    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}    ${body}
    ${output}=    Output    response
    Set Suite Variable    @{response}    ${output}

Send Patch request for individual Performance Threshold - Etag mismatch
    Log    Trying to PUT threshold
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Set Headers    {"If-Match": "${invalid_etag}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    Check GET response from Notification Endpoint
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
    ${origOutput}=    Output    response
    Set Suite Variable    ${origResponse}    ${origOutput}
    ${template}=    Get File    jsons/ThresholdModification.json
    ${body}=    Format String    ${template}    callbackUri=${callback_uri}
    PATCH    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}    ${body}
    ${output}=    Output    response
    Set Suite Variable    @{response}    ${output}

Send Patch request for individual Performance Threshold with unprocessable entity
    Log    Trying to PUT threshold
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": ${AUTHORIZATION}"}
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
    ${origOutput}=    Output    response
    Set Suite Variable    ${origResponse}    ${origOutput}
    ${template}=    Get File    jsons/ThresholdModification.json
    ${body}=    Format String    ${template}    callbackUri=${unreachable_callback_uri}
    PATCH    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}    ${body}
    ${output}=    Output    response
    Set Suite Variable    @{response}    ${output}

Check Postcondition Performance Threshold is Deleted
    Log    Check Postcondition Threshold is deleted
    GET individual Performance Threshold
    Check HTTP Response Status Code Is    404
    
Check HTTP Response Body Threshold Identifier matches the requested Threshold
    Log    Trying to check response ID
    Should Be Equal    ${response['body']['id']}    ${thresholdId} 
    Log    Pm Job identifier as expected
+3 −0
Original line number Diff line number Diff line
{
	"callbackUri":"{callbackUri}"
}
 No newline at end of file