Commit aa17986b authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

fix(029_10): make the subscription expire before updating its expiration date

parent 67c9bbcb
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
*** Settings ***
Documentation     Check that you can update a subscription: If only expiresAt is included and refers to a DateTime in the future or is null, then status shall be updated to "active", if and only if the previous value of status was "expired"
Documentation     Check that you can update a subscription: If only expiresAt is included and refers to a DateTime in the future, then status shall be updated to "active", if and only if the previous value of status was "expired"
Resource          ${EXECDIR}/resources/ApiUtils.resource
Resource          ${EXECDIR}/resources/AssertionUtils.resource
Resource          ${EXECDIR}/resources/JsonUtils.resource
@@ -8,15 +8,20 @@ Suite Teardown Delete Initial Subscriptions

*** Variable ***
${subscription_id_prefix}=    urn:ngsi-ld:Subscription:
${subscription_payload_file_path}=    subscriptions/subscription-inactive-sample.jsonld
${subscription_payload_file_path}=    subscriptions/subscription-sample.jsonld
${subscription_update_fragment_file_path}=    subscriptions/fragments/subscription-expiresAt-future-update-sample.json

*** Test Case ***
Activate Expired Subscription
    [Documentation]    Check that you can update a subscription: If only expiresAt is included and refers to a DateTime in the future or is null, then status shall be updated to "active", if and only if the previous value of status was "expired"
    [Documentation]    Check that you can update a subscription: If only expiresAt is included and refers to a DateTime in the future, then status shall be updated to "active", if and only if the previous value of status was "expired"
    [Tags]    sub-update    5_8_2
    # Update subscription to expired
    Update Subscription    ${subscription_id}    subscriptions/fragments/subscription-expiresAt-update-sample.json    ${CONTENT_TYPE_JSON}
    # Update subscription to expire in 5 seconds
    ${now} =     Get Current Date   time_zone=UTC
    ${in_5_seconds} =   Add Time To Date    ${now}      5s      result_format=%Y-%m-%dT%H:%M:%SZ
    ${update_template_fragment}=    Load Json From File    ${EXECDIR}/data/subscriptions/fragments/subscription-expiresAt-update-sample.json
    ${update_fragment}=    Update Value To Json    ${update_template_fragment}     $..expiresAt   ${in_5_seconds}
    Update Subscription With Payload    ${subscription_id}    ${update_fragment}    ${CONTENT_TYPE_JSON}
    Sleep   10s 
    Update Subscription    ${subscription_id}    ${subscription_update_fragment_file_path}    ${CONTENT_TYPE_JSON}
    Check Response Status Code Set To    204
    Retrieve Subscription    ${subscription_id}
+1 −8
Original line number Diff line number Diff line
{
   "type":"Subscription",
   "expiresAt": "2030-08-01T22:07:00Z",
   "notification":{
      "format":"keyValues",
      "endpoint":{
         "uri":"http://my.endpoint.org/notify",
         "accept":"application/json"
      }
   }
   "expiresAt": "2030-08-01T22:07:00Z"
}
 No newline at end of file
+11 −0
Original line number Diff line number Diff line
@@ -721,6 +721,17 @@ Update Subscription
    Set Test Variable  ${response}
    [return]   ${response}

Update Subscription With Payload
    [Arguments]  ${subscription_id}     ${payload}    ${content_type}    ${accept}=${EMPTY}   ${context}=${EMPTY}
    &{headers}=  Create Dictionary  Content-Type=${content_type}
    Run Keyword If     '${accept}'!=''       Set To Dictionary   ${headers}   Accept    ${accept}
    Run Keyword If     '${context}'!=''       Set To Dictionary   ${headers}    Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json"
    ${response}=  PATCH  ${SUBSCRIPTION_ENDPOINT_PATH}${subscription_id}    body=${payload}     headers=${headers}
    Output  request
    Output  response
    Set Test Variable  ${response}
    [return]   ${response}

Delete Subscription
    [Arguments]  ${subscription_id}
    ${response}=  DELETE  ${SUBSCRIPTION_ENDPOINT_PATH}${subscription_id}