From 9c850eddda4bad52cd50e43eb5b3e38e4a7fb4fe Mon Sep 17 00:00:00 2001 From: Elian Kraja Date: Fri, 27 Sep 2019 09:54:59 +0200 Subject: [PATCH] Adding missing notifications TCs and an example for unauthorized cases --- MEO/PKGM/PackageManagement.robot | 18 +++- MEPM/PKGM/PackageManagement.robot | 16 +++- MEX/ANY/ANY.robot | 154 ++++++++++++++++++++++++++++-- MEX/ANY/environment/resources.txt | 6 ++ MEX/LCM/LifeCycleManagement.robot | 18 +++- 5 files changed, 199 insertions(+), 13 deletions(-) create mode 100644 MEX/ANY/environment/resources.txt diff --git a/MEO/PKGM/PackageManagement.robot b/MEO/PKGM/PackageManagement.robot index f65e148..f8a767a 100644 --- a/MEO/PKGM/PackageManagement.robot +++ b/MEO/PKGM/PackageManagement.robot @@ -233,7 +233,23 @@ Remove a APP Package subscription using non existant subscription id Delete an App Package Subscription identified by ${NON_EXISTENT_SUBSCRIPTION_ID} Check HTTP Response Status Code Is 404 - + +Post Application Package Notification + [Documentation] TP_MEC_MEO_PKGM_011_OK + ... Check that the MEO service sends a application package notification + ... if the MEO service has an associated subscription and the event is generated + ... ETSI GS MEC 010-2 2.0.10, clause 7.3.5.1 + ${json}= Get File schemas/AppPkgNotification.schema.json + Log Creating mock request and response to handle Application Package Notification + &{req}= Create Mock Request Matcher POST ${callback_endpoint} body_type="JSON_SCHEMA" body=${json} + &{rsp}= Create Mock Response headers="Content-Type: application/json" status_code=204 + Create Mock Expectation ${req} ${rsp} + Wait Until Keyword Succeeds ${total_polling_time} ${polling_interval} Verify Mock Expectation ${req} + Log Verifying results + Verify Mock Expectation ${req} + Log Cleaning the endpoint + Clear Requests ${callback_endpoint} + *** Keywords *** Post Request to create new App Package Resource diff --git a/MEPM/PKGM/PackageManagement.robot b/MEPM/PKGM/PackageManagement.robot index 1e7f422..526b5ea 100644 --- a/MEPM/PKGM/PackageManagement.robot +++ b/MEPM/PKGM/PackageManagement.robot @@ -178,7 +178,21 @@ Remove a APP Package subscription using non existant subscription id Check HTTP Response Status Code Is 404 - +Post Application Package Notification + [Documentation] TP_MEC_MEPM_PKGM_009_OK + ... Check that the MEPM service sends a application package notification + ... if the MEPM service has an associated subscription and the event is generated + ... ETSI GS MEC 010-2 2.0.10, clause 7.4.7.3.1 + ${json}= Get File schemas/AppPkgNotification.schema.json + Log Creating mock request and response to handle Application Package Notification + &{req}= Create Mock Request Matcher POST ${callback_endpoint} body_type="JSON_SCHEMA" body=${json} + &{rsp}= Create Mock Response headers="Content-Type: application/json" status_code=204 + Create Mock Expectation ${req} ${rsp} + Wait Until Keyword Succeeds ${total_polling_time} ${polling_interval} Verify Mock Expectation ${req} + Log Verifying results + Verify Mock Expectation ${req} + Log Cleaning the endpoint + Clear Requests ${callback_endpoint} *** Keywords *** GET all APP Packages diff --git a/MEX/ANY/ANY.robot b/MEX/ANY/ANY.robot index 8978667..9a57ed1 100644 --- a/MEX/ANY/ANY.robot +++ b/MEX/ANY/ANY.robot @@ -4,31 +4,165 @@ Resource ../../GenericKeywords.robot Library REST ${PROVIDER_SCHEMA}://${PROVIDER_HOST}:${PROVIDER_PORT} ssl_verify=false Library BuiltIn Library OperatingSystem +Library Collections +Library String +*** Variable *** +@{data} https|localhost|8080|/alcmi/v1/app_instances|POST|{"key":"value"} https|localhost|8080|/alcmi/v1/app_instances|GET https|localhost|8080|/alcmi/v1/app_instances|PUT +${token} Bearer InvalidToken *** Test Cases *** -Request access to a generic resource not using token +Request access to all resources using no token [Documentation] TP_MEC_MEX_ANY_001_NT ... Check that a MEC API provider responds with an error when it ... receives a request without token ... ETSI GS MEC 009 1.1.1, clause 6.16.1 [Tags] GENERIC_TESTS INCLUDE_UNDEFINED_SCHEMAS + : FOR ${INDEX} IN RANGE 0 3 + \ @{list} Split String ${data[${INDEX}]} separator=| max_split=-1 + \ Perform a generic request using no token @{list[${INDEX}]} + : FOR ${INDEX} IN RANGE 0 3 + \ @{list} Split String ${data[${INDEX}]} separator=| max_split=-1 + \ Perform a generic request using invalid token @{data[${INDEX}]} + + + +*** Keywords *** +Perform a generic request using no token + [Arguments] @{params} + Run Keyword If '@{params[4]}' == "POST" + ... Perform a POST using no token ${params[0]} ${params[1]} ${params[2]} ${params[3]} ${params[5]} + Run Keyword If '@{params[4]}' == "GET" + ... Perform a GET using no token ${params[0]} ${params[1]} ${params[2]} ${params[3]} + Run Keyword If '@{params[4]}' == "DELETE" + ... Perform a DELETE using no token ${params[0]} ${params[1]} ${params[2]} ${params[3]} + Run Keyword If '@{params[4]}' == "PUT" + ... Perform a PUT using no token ${params[0]} ${params[1]} ${params[2]} ${params[3]} ${params[5]} + Run Keyword If '@{params[4]}' == "PATCH" + ... Perform a PATCH using no token ${params[0]} ${params[1]} ${params[2]} ${params[3]} ${params[5]} + + +Perform a generic request using invalid token + [Arguments] @{params} + Run Keyword If '@{params[4]}' == "POST" + ... Perform a POST using invalid token ${token} ${params[0]} ${params[1]} ${params[2]} ${params[3]} ${params[5]} + Run Keyword If '@{params[4]}' == "GET" + ... Perform a GET using invalid token ${token} ${params[0]} ${params[1]} ${params[2]} ${params[3]} + Run Keyword If '@{params[4]}' == "DELETE" + ... Perform a DELETE using invalid token ${token} ${params[0]} ${params[1]} ${params[2]} ${params[3]} + Run Keyword If '@{params[4]}' == "PUT" + ... Perform a PUT using invalid token ${token} ${params[0]} ${params[1]} ${params[2]} ${params[3]} ${params[5]} + Run Keyword If '@{params[4]}' == "PATCH" + ... Perform a PATCH using invalid token ${token} ${params[0]} ${params[1]} ${params[2]} ${params[3]} ${params[5]} + + +Perform a POST using no token + [Arguments] ${schema} ${ip} ${port} ${uri} ${payload} + Log "Running post" Set Headers {"Accept":"application/json"} Set Headers {"Content-Type":"application/json"} - Get ${apiRoot}/${apiName}/${apiVersion}/app_packages + POST ${schema}://${ip}:${port}/${uri} ${payload} + Log ${schema}://${ip}:${port}/${uri} ${payload} ${output}= Output response Should Be Equal As Strings 401 ${output['status']} -Request access to a generic resource using an invalid token - [Documentation] TP_MEC_MEX_ANY_001_WT - ... Check that a MEC API provider responds with an error - ... when it receives a request with a wrong token - ... ETSI GS MEC 009 1.1.1, clause 6.16.1 - [Tags] GENERIC_TESTS INCLUDE_UNDEFINED_SCHEMAS + +Perform a GET using no token + [Arguments] ${schema} ${ip} ${port} ${uri} + Set Headers {"Accept":"application/json"} + Set Headers {"Content-Type":"application/json"} + Log ${schema}://${ip}:${port}/${uri} + GET ${schema}://${ip}:${port}/${uri} + ${output}= Output response + Should Be Equal As Strings 401 ${output['status']} + + + +Perform a DELETE using no token + [Arguments] ${schema} ${ip} ${port} ${uri} + Set Headers {"Accept":"application/json"} + Set Headers {"Content-Type":"application/json"} + Log ${schema}://${ip}:${port}/${uri} + DELETE ${schema}://${ip}:${port}/${uri} + ${output}= Output response + Should Be Equal As Strings 401 ${output['status']} + + +Perform a PUT using no token + [Arguments] ${schema} ${ip} ${port} ${uri} ${payload}=None + Log "Running post" + Set Headers {"Accept":"application/json"} + Set Headers {"Content-Type":"application/json"} + Log ${schema}://${ip}:${port}/${uri} ${payload} + PUT ${schema}://${ip}:${port}/${uri} ${payload} + ${output}= Output response + Should Be Equal As Strings 401 ${output['status']} + + +Perform a PATCH using no token + [Arguments] ${schema} ${ip} ${port} ${uri} ${payload}=None + Log "Running post" + Set Headers {"Accept":"application/json"} + Set Headers {"Content-Type":"application/json"} + Log ${schema}://${ip}:${port}/${uri} ${payload} + PATCH ${schema}://${ip}:${port}/${uri} ${payload} + ${output}= Output response + Should Be Equal As Strings 401 ${output['status']} + + +Perform a POST using invalid token + [Arguments] ${token} ${schema} ${ip} ${port} ${uri} ${payload}=None + Set Headers {"Accept":"application/json"} + Set Headers {"Authorization":"${token}"} + Set Headers {"Content-Type":"application/json"} + Log ${schema}://${ip}:${port}/${uri} ${payload} + POST ${schema}://${ip}:${port}/${uri} ${payload} + ${output}= Output response + Should Be Equal As Strings 401 ${output['status']} + + + + +Perform a GET using invalid token + [Arguments] ${token} ${schema} ${ip} ${port} ${uri} + Set Headers {"Accept":"application/json"} + Set Headers {"Authorization":"${token}"} + Set Headers {"Content-Type":"application/json"} + Log ${schema}://${ip}:${port}/${uri} + GET ${schema}://${ip}:${port}/${uri} + ${output}= Output response + Should Be Equal As Strings 401 ${output['status']} + + +Perform a DELETE using invalid token + [Arguments] ${token} ${schema} ${ip} ${port} ${uri} + Set Headers {"Accept":"application/json"} + Set Headers {"Authorization":"${token}"} + Set Headers {"Content-Type":"application/json"} + Log ${schema}://${ip}:${port}/${uri} + DELETE ${schema}://${ip}:${port}/${uri} + ${output}= Output response + Should Be Equal As Strings 401 ${output['status']} + + +Perform a PUT using invalid token + [Arguments] ${token} ${schema} ${ip} ${port} ${uri} ${payload}=None + Set Headers {"Accept":"application/json"} + Set Headers {"Authorization":"${token}"} + Set Headers {"Content-Type":"application/json"} + Log ${schema}://${ip}:${port}/${uri} ${payload} + PUT ${schema}://${ip}:${port}/${uri} ${payload} + ${output}= Output response + Should Be Equal As Strings 401 ${output['status']} + + +Perform a PATCH using invalid token + [Arguments] ${token} ${schema} ${ip} ${port} ${uri} ${payload}=None Set Headers {"Accept":"application/json"} + Set Headers {"Authorization":"${token}"} Set Headers {"Content-Type":"application/json"} - Set Headers {"Authorization":"${INVALID_TOKEN}"} - Get ${apiRoot}/${apiName}/${apiVersion}/app_packages + Log ${schema}://${ip}:${port}/${uri} ${payload} + PATCH ${schema}://${ip}:${port}/${uri} ${payload} ${output}= Output response Should Be Equal As Strings 401 ${output['status']} diff --git a/MEX/ANY/environment/resources.txt b/MEX/ANY/environment/resources.txt new file mode 100644 index 0000000..141eeb9 --- /dev/null +++ b/MEX/ANY/environment/resources.txt @@ -0,0 +1,6 @@ +{ +["https", "localhost", "8080", "/alcmi/v1/app_instances", "POST", "{}"], +["https", "localhost", "8080", "/alcmi/v1/app_instances", "GET", ""], +["https", "localhost", "8080", "/alcmi/v1/app_instances", "PUT", "{}"], +["https", "localhost", "8080", "/alcmi/v1/app_instances", "DELETE", ""] +} \ No newline at end of file diff --git a/MEX/LCM/LifeCycleManagement.robot b/MEX/LCM/LifeCycleManagement.robot index 4db0f15..429d56d 100644 --- a/MEX/LCM/LifeCycleManagement.robot +++ b/MEX/LCM/LifeCycleManagement.robot @@ -322,7 +322,23 @@ Remove a APP Package subscription using non existant subscription id Delete an LCM Subscription identified by ${NON_EXISTENT_SUBSCRIPTION_ID} Check HTTP Response Status Code Is 404 - +Post Application Package Notification + [Documentation] TP_MEC_MEX_LCM_014_OK + ... Check that MEC API provider sends a notification to the subscriber when an application lcm change event occurs + ... ETSI GS MEC 010-2 2.0.10, clause 7.5.5.3.1 + ... ETSI GS MEC 010-2 2.0.10, table 6.2.2.18.2-1, // AppLcmOpOccNotification + ... ETSI GS MEC 010-2 2.0.10, table 6.2.2.12.2-1 // AppInstNotification + ${json}= Get File schemas/LCMNotification.schema.json + Log Creating mock request and response to handle LCM Notification + &{req}= Create Mock Request Matcher POST ${callback_endpoint} body_type="JSON_SCHEMA" body=${json} + &{rsp}= Create Mock Response headers="Content-Type: application/json" status_code=204 + Create Mock Expectation ${req} ${rsp} + Wait Until Keyword Succeeds ${total_polling_time} ${polling_interval} Verify Mock Expectation ${req} + Log Verifying results + Verify Mock Expectation ${req} + Log Cleaning the endpoint + Clear Requests ${callback_endpoint} + *** Keywords *** Post Request to create new App instance -- GitLab